Lines Matching full:runtime

101 static inline bool __snd_rawmidi_ready(struct snd_rawmidi_runtime *runtime)  in __snd_rawmidi_ready()  argument
103 return runtime->avail >= runtime->avail_min; in __snd_rawmidi_ready()
109 return __snd_rawmidi_ready(substream->runtime); in snd_rawmidi_ready()
115 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
117 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
118 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
123 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
126 if (runtime->event) in snd_rawmidi_input_event_work()
127 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
131 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_ref() argument
133 runtime->buffer_ref++; in snd_rawmidi_buffer_ref()
136 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_unref() argument
138 runtime->buffer_ref--; in snd_rawmidi_buffer_unref()
146 while (substream->runtime->buffer_ref) { in snd_rawmidi_buffer_ref_sync()
160 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
162 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
163 if (!runtime) in snd_rawmidi_runtime_create()
165 runtime->substream = substream; in snd_rawmidi_runtime_create()
166 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
167 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
168 runtime->event = NULL; in snd_rawmidi_runtime_create()
169 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
170 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
172 runtime->avail = 0; in snd_rawmidi_runtime_create()
174 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
175 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
176 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
177 kfree(runtime); in snd_rawmidi_runtime_create()
180 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
181 substream->runtime = runtime; in snd_rawmidi_runtime_create()
183 runtime->align = 3; in snd_rawmidi_runtime_create()
188 static inline int get_align(struct snd_rawmidi_runtime *runtime) in get_align() argument
191 return runtime->align; in get_align()
197 #define get_aligned_size(runtime, size) ((size) & ~get_align(runtime)) argument
201 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
203 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
204 kfree(runtime); in snd_rawmidi_runtime_free()
205 substream->runtime = NULL; in snd_rawmidi_runtime_free()
222 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
225 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
228 runtime->drain = 0; in __reset_runtime_ptrs()
229 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
230 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
237 if (substream->opened && substream->runtime) in reset_runtime_ptrs()
238 __reset_runtime_ptrs(substream->runtime, is_input); in reset_runtime_ptrs()
253 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_drain_output() local
256 runtime = substream->runtime; in snd_rawmidi_drain_output()
257 if (!substream->opened || !runtime || !runtime->buffer) in snd_rawmidi_drain_output()
259 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_drain_output()
260 runtime->drain = 1; in snd_rawmidi_drain_output()
263 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
264 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
270 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
273 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
276 runtime->drain = 0; in snd_rawmidi_drain_output()
289 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_drain_output()
514 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
515 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
516 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
517 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
561 if (substream->runtime->private_free) in close_substream()
562 substream->runtime->private_free(substream); in close_substream()
714 struct snd_rawmidi_runtime *runtime = substream->runtime; in resize_runtime_buffer() local
724 if (params->buffer_size & get_align(runtime)) in resize_runtime_buffer()
726 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
731 if (runtime->buffer_ref) { in resize_runtime_buffer()
736 oldbuf = runtime->buffer; in resize_runtime_buffer()
737 runtime->buffer = newbuf; in resize_runtime_buffer()
738 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
739 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
743 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
792 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
797 status->avail = runtime->avail; in snd_rawmidi_output_status()
804 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
809 status->avail = runtime->avail; in snd_rawmidi_input_status()
810 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
811 runtime->xruns = 0; in snd_rawmidi_input_status()
1079 struct snd_rawmidi_runtime *runtime = substream->runtime; in receive_with_tstamp_framing() local
1084 int align = get_align(runtime); in receive_with_tstamp_framing()
1087 if (snd_BUG_ON((runtime->hw_ptr & 0x1f) != 0)) in receive_with_tstamp_framing()
1091 if ((int)(runtime->buffer_size - runtime->avail) < frame_size) { in receive_with_tstamp_framing()
1092 runtime->xruns += src_count; in receive_with_tstamp_framing()
1098 frame.length = get_aligned_size(runtime, src_count); in receive_with_tstamp_framing()
1106 dest_ptr = (struct snd_rawmidi_framing_tstamp *) (runtime->buffer + runtime->hw_ptr); in receive_with_tstamp_framing()
1108 runtime->avail += frame_size; in receive_with_tstamp_framing()
1109 runtime->hw_ptr += frame_size; in receive_with_tstamp_framing()
1110 runtime->hw_ptr %= runtime->buffer_size; in receive_with_tstamp_framing()
1148 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_receive() local
1153 runtime = substream->runtime; in snd_rawmidi_receive()
1154 if (!runtime || !runtime->buffer) { in snd_rawmidi_receive()
1160 count = get_aligned_size(runtime, count); in snd_rawmidi_receive()
1168 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
1169 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
1170 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1171 runtime->avail++; in snd_rawmidi_receive()
1174 runtime->xruns++; in snd_rawmidi_receive()
1178 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
1181 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
1182 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1183 count1 = get_aligned_size(runtime, count1); in snd_rawmidi_receive()
1186 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
1187 runtime->hw_ptr += count1; in snd_rawmidi_receive()
1188 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1189 runtime->avail += count1; in snd_rawmidi_receive()
1195 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
1196 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1197 runtime->xruns += count - count1; in snd_rawmidi_receive()
1200 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
1201 runtime->hw_ptr = count1; in snd_rawmidi_receive()
1202 runtime->avail += count1; in snd_rawmidi_receive()
1208 if (runtime->event) in snd_rawmidi_receive()
1209 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
1210 else if (__snd_rawmidi_ready(runtime)) in snd_rawmidi_receive()
1211 wake_up(&runtime->sleep); in snd_rawmidi_receive()
1223 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
1228 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_read1()
1229 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
1230 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1233 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
1234 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
1236 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_read1()
1237 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1238 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
1239 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
1240 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
1243 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
1247 runtime->buffer + appl_ptr, count1)) in snd_rawmidi_kernel_read1()
1257 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_read1()
1277 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1283 runtime = substream->runtime; in snd_rawmidi_read()
1288 while (!__snd_rawmidi_ready(runtime)) { in snd_rawmidi_read()
1296 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1300 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1306 if (!runtime->avail) { in snd_rawmidi_read()
1333 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_transmit_empty() local
1336 runtime = substream->runtime; in snd_rawmidi_transmit_empty()
1337 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_transmit_empty()
1342 return (runtime->avail >= runtime->buffer_size); in snd_rawmidi_transmit_empty()
1358 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1360 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1366 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1371 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1374 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1377 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1378 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1379 count1 = get_aligned_size(runtime, count1); in __snd_rawmidi_transmit_peek()
1382 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1386 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1387 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1388 count = get_aligned_size(runtime, count); in __snd_rawmidi_transmit_peek()
1391 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1417 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_peek()
1433 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1435 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1440 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1441 count = get_aligned_size(runtime, count); in __snd_rawmidi_transmit_ack()
1442 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1443 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1444 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1447 if (runtime->drain || __snd_rawmidi_ready(runtime)) in __snd_rawmidi_transmit_ack()
1448 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1467 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_ack()
1504 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proceed() local
1508 runtime = substream->runtime; in snd_rawmidi_proceed()
1509 if (substream->opened && runtime && in snd_rawmidi_proceed()
1510 runtime->avail < runtime->buffer_size) { in snd_rawmidi_proceed()
1511 count = runtime->buffer_size - runtime->avail; in snd_rawmidi_proceed()
1525 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1530 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1536 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1541 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_write1()
1542 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1543 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1546 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1547 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1549 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_write1()
1550 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1551 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1552 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1553 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1556 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1560 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1572 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1573 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_write1()
1593 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1598 runtime = substream->runtime; in snd_rawmidi_write()
1600 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1613 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1617 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1623 if (!runtime->avail && !timeout) { in snd_rawmidi_write()
1640 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1642 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1645 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1649 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1652 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1664 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1669 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1671 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1674 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1675 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1705 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1731 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1733 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1734 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1740 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1758 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1760 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1761 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1762 xruns = runtime->xruns; in snd_rawmidi_proc_info_read()
2063 if (s->runtime) in snd_rawmidi_dev_disconnect()
2064 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()