Lines Matching refs:runtime
98 static inline bool __snd_rawmidi_ready(struct snd_rawmidi_runtime *runtime) in __snd_rawmidi_ready() argument
100 return runtime->avail >= runtime->avail_min; in __snd_rawmidi_ready()
109 ready = __snd_rawmidi_ready(substream->runtime); in snd_rawmidi_ready()
117 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
119 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
120 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
125 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
128 if (runtime->event) in snd_rawmidi_input_event_work()
129 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
133 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_ref() argument
135 runtime->buffer_ref++; in snd_rawmidi_buffer_ref()
138 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_unref() argument
140 runtime->buffer_ref--; in snd_rawmidi_buffer_unref()
148 while (substream->runtime->buffer_ref) { in snd_rawmidi_buffer_ref_sync()
162 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
164 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
165 if (!runtime) in snd_rawmidi_runtime_create()
167 runtime->substream = substream; in snd_rawmidi_runtime_create()
168 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
169 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
170 runtime->event = NULL; in snd_rawmidi_runtime_create()
171 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
172 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
174 runtime->avail = 0; in snd_rawmidi_runtime_create()
176 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
177 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
178 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
179 kfree(runtime); in snd_rawmidi_runtime_create()
182 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
183 substream->runtime = runtime; in snd_rawmidi_runtime_create()
189 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
191 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
192 kfree(runtime); in snd_rawmidi_runtime_free()
193 substream->runtime = NULL; in snd_rawmidi_runtime_free()
210 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
213 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
216 runtime->drain = 0; in __reset_runtime_ptrs()
217 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
218 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
227 if (substream->opened && substream->runtime) in reset_runtime_ptrs()
228 __reset_runtime_ptrs(substream->runtime, is_input); in reset_runtime_ptrs()
244 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_drain_output() local
247 runtime = substream->runtime; in snd_rawmidi_drain_output()
248 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_drain_output()
251 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_drain_output()
252 runtime->drain = 1; in snd_rawmidi_drain_output()
258 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
259 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
265 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
268 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
271 runtime->drain = 0; in snd_rawmidi_drain_output()
284 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_drain_output()
521 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
522 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
523 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
524 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
568 if (substream->runtime->private_free) in close_substream()
569 substream->runtime->private_free(substream); in close_substream()
723 struct snd_rawmidi_runtime *runtime = substream->runtime; in resize_runtime_buffer() local
733 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
738 if (runtime->buffer_ref) { in resize_runtime_buffer()
743 oldbuf = runtime->buffer; in resize_runtime_buffer()
744 runtime->buffer = newbuf; in resize_runtime_buffer()
745 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
746 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
750 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
803 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
808 status->avail = runtime->avail; in snd_rawmidi_output_status()
816 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
821 status->avail = runtime->avail; in snd_rawmidi_input_status()
822 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
823 runtime->xruns = 0; in snd_rawmidi_input_status()
1050 struct snd_rawmidi_runtime *runtime = substream->runtime; in receive_with_tstamp_framing() local
1058 if (snd_BUG_ON((runtime->hw_ptr & 0x1f) != 0)) in receive_with_tstamp_framing()
1062 if ((int)(runtime->buffer_size - runtime->avail) < frame_size) { in receive_with_tstamp_framing()
1063 runtime->xruns += src_count; in receive_with_tstamp_framing()
1075 dest_ptr = (struct snd_rawmidi_framing_tstamp *) (runtime->buffer + runtime->hw_ptr); in receive_with_tstamp_framing()
1077 runtime->avail += frame_size; in receive_with_tstamp_framing()
1078 runtime->hw_ptr += frame_size; in receive_with_tstamp_framing()
1079 runtime->hw_ptr %= runtime->buffer_size; in receive_with_tstamp_framing()
1119 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_receive() local
1126 runtime = substream->runtime; in snd_rawmidi_receive()
1127 if (!runtime || !runtime->buffer) { in snd_rawmidi_receive()
1138 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
1139 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
1140 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1141 runtime->avail++; in snd_rawmidi_receive()
1144 runtime->xruns++; in snd_rawmidi_receive()
1148 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
1151 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
1152 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1153 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
1154 runtime->hw_ptr += count1; in snd_rawmidi_receive()
1155 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1156 runtime->avail += count1; in snd_rawmidi_receive()
1162 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
1163 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1164 runtime->xruns += count - count1; in snd_rawmidi_receive()
1167 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
1168 runtime->hw_ptr = count1; in snd_rawmidi_receive()
1169 runtime->avail += count1; in snd_rawmidi_receive()
1175 if (runtime->event) in snd_rawmidi_receive()
1176 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
1177 else if (__snd_rawmidi_ready(runtime)) in snd_rawmidi_receive()
1178 wake_up(&runtime->sleep); in snd_rawmidi_receive()
1192 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
1197 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_read1()
1198 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
1199 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1202 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
1203 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
1206 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1207 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
1208 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
1209 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
1212 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
1216 runtime->buffer + appl_ptr, count1)) in snd_rawmidi_kernel_read1()
1226 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_read1()
1246 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1252 runtime = substream->runtime; in snd_rawmidi_read()
1257 while (!__snd_rawmidi_ready(runtime)) { in snd_rawmidi_read()
1265 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1269 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1275 if (!runtime->avail) { in snd_rawmidi_read()
1302 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_transmit_empty() local
1307 runtime = substream->runtime; in snd_rawmidi_transmit_empty()
1308 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_transmit_empty()
1313 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1332 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1334 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1340 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1345 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1348 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1351 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1352 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1353 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1357 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1358 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1359 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1388 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_peek()
1407 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1409 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1414 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1415 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1416 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1417 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1420 if (runtime->drain || __snd_rawmidi_ready(runtime)) in __snd_rawmidi_transmit_ack()
1421 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1443 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_ack()
1491 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proceed() local
1496 runtime = substream->runtime; in snd_rawmidi_proceed()
1497 if (substream->opened && runtime && in snd_rawmidi_proceed()
1498 runtime->avail < runtime->buffer_size) { in snd_rawmidi_proceed()
1499 count = runtime->buffer_size - runtime->avail; in snd_rawmidi_proceed()
1514 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1519 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1525 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1530 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_write1()
1531 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1532 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1535 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1536 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1539 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1540 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1541 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1542 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1545 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1549 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1561 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1562 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_write1()
1582 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1587 runtime = substream->runtime; in snd_rawmidi_write()
1589 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1602 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1606 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1612 if (!runtime->avail && !timeout) { in snd_rawmidi_write()
1629 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1631 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1634 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1638 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1641 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1653 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1658 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1660 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1663 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1664 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1694 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1715 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1717 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1718 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1724 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1742 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1744 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1745 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1746 xruns = runtime->xruns; in snd_rawmidi_proc_info_read()
2033 if (s->runtime) in snd_rawmidi_dev_disconnect()
2034 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()