Lines Matching refs:runtime
91 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready() local
93 return runtime->avail >= runtime->avail_min; in snd_rawmidi_ready()
99 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
101 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
102 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
107 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
110 if (runtime->event) in snd_rawmidi_input_event_work()
111 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
116 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
118 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
119 if (!runtime) in snd_rawmidi_runtime_create()
121 runtime->substream = substream; in snd_rawmidi_runtime_create()
122 spin_lock_init(&runtime->lock); in snd_rawmidi_runtime_create()
123 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
124 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
125 runtime->event = NULL; in snd_rawmidi_runtime_create()
126 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
127 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
129 runtime->avail = 0; in snd_rawmidi_runtime_create()
131 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
132 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
133 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
134 kfree(runtime); in snd_rawmidi_runtime_create()
137 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
138 substream->runtime = runtime; in snd_rawmidi_runtime_create()
144 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
146 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
147 kfree(runtime); in snd_rawmidi_runtime_free()
148 substream->runtime = NULL; in snd_rawmidi_runtime_free()
165 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
168 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
171 runtime->drain = 0; in __reset_runtime_ptrs()
172 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
173 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
176 static void reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in reset_runtime_ptrs() argument
181 spin_lock_irqsave(&runtime->lock, flags); in reset_runtime_ptrs()
182 __reset_runtime_ptrs(runtime, is_input); in reset_runtime_ptrs()
183 spin_unlock_irqrestore(&runtime->lock, flags); in reset_runtime_ptrs()
189 reset_runtime_ptrs(substream->runtime, false); in snd_rawmidi_drop_output()
198 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drain_output() local
201 runtime->drain = 1; in snd_rawmidi_drain_output()
202 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
203 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
207 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
210 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
213 runtime->drain = 0; in snd_rawmidi_drain_output()
229 reset_runtime_ptrs(substream->runtime, true); in snd_rawmidi_drain_input()
453 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
454 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
455 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
456 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
495 if (substream->runtime->private_free) in close_substream()
496 substream->runtime->private_free(substream); in close_substream()
647 static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime, in resize_runtime_buffer() argument
657 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
661 spin_lock_irq(&runtime->lock); in resize_runtime_buffer()
662 oldbuf = runtime->buffer; in resize_runtime_buffer()
663 runtime->buffer = newbuf; in resize_runtime_buffer()
664 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
665 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
666 spin_unlock_irq(&runtime->lock); in resize_runtime_buffer()
669 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
680 return resize_runtime_buffer(substream->runtime, params, false); in snd_rawmidi_output_params()
688 return resize_runtime_buffer(substream->runtime, params, true); in snd_rawmidi_input_params()
695 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
699 spin_lock_irq(&runtime->lock); in snd_rawmidi_output_status()
700 status->avail = runtime->avail; in snd_rawmidi_output_status()
701 spin_unlock_irq(&runtime->lock); in snd_rawmidi_output_status()
708 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
712 spin_lock_irq(&runtime->lock); in snd_rawmidi_input_status()
713 status->avail = runtime->avail; in snd_rawmidi_input_status()
714 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
715 runtime->xruns = 0; in snd_rawmidi_input_status()
716 spin_unlock_irq(&runtime->lock); in snd_rawmidi_input_status()
894 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_receive() local
898 if (runtime->buffer == NULL) { in snd_rawmidi_receive()
903 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_receive()
906 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
907 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
908 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
909 runtime->avail++; in snd_rawmidi_receive()
912 runtime->xruns++; in snd_rawmidi_receive()
916 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
919 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
920 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
921 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
922 runtime->hw_ptr += count1; in snd_rawmidi_receive()
923 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
924 runtime->avail += count1; in snd_rawmidi_receive()
930 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
931 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
932 runtime->xruns += count - count1; in snd_rawmidi_receive()
935 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
936 runtime->hw_ptr = count1; in snd_rawmidi_receive()
937 runtime->avail += count1; in snd_rawmidi_receive()
943 if (runtime->event) in snd_rawmidi_receive()
944 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
946 wake_up(&runtime->sleep); in snd_rawmidi_receive()
948 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_receive()
959 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
962 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
963 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
964 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
967 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
968 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
971 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
972 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
973 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
974 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
977 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
979 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
981 runtime->buffer + appl_ptr, count1)) { in snd_rawmidi_kernel_read1()
984 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
989 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
1008 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1014 runtime = substream->runtime; in snd_rawmidi_read()
1018 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1023 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1027 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1029 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1031 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1036 if (!runtime->avail) in snd_rawmidi_read()
1038 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1040 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1062 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_empty() local
1066 if (runtime->buffer == NULL) { in snd_rawmidi_transmit_empty()
1071 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1072 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1073 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1090 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1092 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1098 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1103 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1106 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1109 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1110 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1111 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1115 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1116 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1117 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1143 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_peek() local
1147 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1149 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1163 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1165 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1170 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1171 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1172 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1173 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1176 if (runtime->drain || snd_rawmidi_ready(substream)) in __snd_rawmidi_transmit_ack()
1177 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1196 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_ack() local
1200 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1202 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1220 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit() local
1224 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit()
1234 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit()
1246 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1251 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1255 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1257 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1258 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1262 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1263 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1266 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1267 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1270 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1271 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1272 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1273 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1276 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1279 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1280 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1282 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1286 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1292 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1293 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1312 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1317 runtime = substream->runtime; in snd_rawmidi_write()
1319 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1323 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1328 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1332 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1334 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1336 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1341 if (!runtime->avail && !timeout) in snd_rawmidi_write()
1343 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1345 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1356 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1357 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1359 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1362 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1364 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1366 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1369 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1371 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1373 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1381 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1386 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1388 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1391 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1392 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1422 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1440 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1445 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1446 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1447 (unsigned long) runtime->avail); in snd_rawmidi_proc_info_read()
1464 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1469 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1470 (unsigned long) runtime->avail, in snd_rawmidi_proc_info_read()
1471 (unsigned long) runtime->xruns); in snd_rawmidi_proc_info_read()
1745 if (s->runtime) in snd_rawmidi_dev_disconnect()
1746 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()