Lines Matching refs:runtime
90 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready() local
91 return runtime->avail >= runtime->avail_min; in snd_rawmidi_ready()
97 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
98 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
99 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
104 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
106 if (runtime->event) in snd_rawmidi_input_event_work()
107 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
112 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
114 if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) in snd_rawmidi_runtime_create()
116 runtime->substream = substream; in snd_rawmidi_runtime_create()
117 spin_lock_init(&runtime->lock); in snd_rawmidi_runtime_create()
118 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
119 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
120 runtime->event = NULL; in snd_rawmidi_runtime_create()
121 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
122 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
124 runtime->avail = 0; in snd_rawmidi_runtime_create()
126 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
127 if ((runtime->buffer = kmalloc(runtime->buffer_size, GFP_KERNEL)) == NULL) { in snd_rawmidi_runtime_create()
128 kfree(runtime); in snd_rawmidi_runtime_create()
131 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
132 substream->runtime = runtime; in snd_rawmidi_runtime_create()
138 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
140 kfree(runtime->buffer); in snd_rawmidi_runtime_free()
141 kfree(runtime); in snd_rawmidi_runtime_free()
142 substream->runtime = NULL; in snd_rawmidi_runtime_free()
159 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
165 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drop_output() local
168 runtime->drain = 0; in snd_rawmidi_drop_output()
169 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_drop_output()
170 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_drop_output()
171 runtime->avail = runtime->buffer_size; in snd_rawmidi_drop_output()
172 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_drop_output()
181 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drain_output() local
184 runtime->drain = 1; in snd_rawmidi_drain_output()
185 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
186 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
190 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
193 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
196 runtime->drain = 0; in snd_rawmidi_drain_output()
212 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drain_input() local
215 runtime->drain = 0; in snd_rawmidi_drain_input()
216 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_drain_input()
217 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_drain_input()
218 runtime->avail = 0; in snd_rawmidi_drain_input()
219 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_drain_input()
445 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
446 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
447 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
448 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
487 if (substream->runtime->private_free) in close_substream()
488 substream->runtime->private_free(substream); in close_substream()
630 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_params() local
641 if (params->buffer_size != runtime->buffer_size) { in snd_rawmidi_output_params()
642 newbuf = krealloc(runtime->buffer, params->buffer_size, in snd_rawmidi_output_params()
646 runtime->buffer = newbuf; in snd_rawmidi_output_params()
647 runtime->buffer_size = params->buffer_size; in snd_rawmidi_output_params()
648 runtime->avail = runtime->buffer_size; in snd_rawmidi_output_params()
650 runtime->avail_min = params->avail_min; in snd_rawmidi_output_params()
660 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_params() local
669 if (params->buffer_size != runtime->buffer_size) { in snd_rawmidi_input_params()
670 newbuf = krealloc(runtime->buffer, params->buffer_size, in snd_rawmidi_input_params()
674 runtime->buffer = newbuf; in snd_rawmidi_input_params()
675 runtime->buffer_size = params->buffer_size; in snd_rawmidi_input_params()
677 runtime->avail_min = params->avail_min; in snd_rawmidi_input_params()
685 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
689 spin_lock_irq(&runtime->lock); in snd_rawmidi_output_status()
690 status->avail = runtime->avail; in snd_rawmidi_output_status()
691 spin_unlock_irq(&runtime->lock); in snd_rawmidi_output_status()
698 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
702 spin_lock_irq(&runtime->lock); in snd_rawmidi_input_status()
703 status->avail = runtime->avail; in snd_rawmidi_input_status()
704 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
705 runtime->xruns = 0; in snd_rawmidi_input_status()
706 spin_unlock_irq(&runtime->lock); in snd_rawmidi_input_status()
879 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_receive() local
883 if (runtime->buffer == NULL) { in snd_rawmidi_receive()
888 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_receive()
891 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
892 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
893 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
894 runtime->avail++; in snd_rawmidi_receive()
897 runtime->xruns++; in snd_rawmidi_receive()
901 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
904 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
905 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
906 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
907 runtime->hw_ptr += count1; in snd_rawmidi_receive()
908 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
909 runtime->avail += count1; in snd_rawmidi_receive()
915 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
916 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
917 runtime->xruns += count - count1; in snd_rawmidi_receive()
920 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
921 runtime->hw_ptr = count1; in snd_rawmidi_receive()
922 runtime->avail += count1; in snd_rawmidi_receive()
928 if (runtime->event) in snd_rawmidi_receive()
929 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
931 wake_up(&runtime->sleep); in snd_rawmidi_receive()
933 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_receive()
944 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
947 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
948 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
949 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
952 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
953 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
956 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
957 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
958 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
959 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
962 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
964 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
966 runtime->buffer + appl_ptr, count1)) { in snd_rawmidi_kernel_read1()
969 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
974 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
993 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
999 runtime = substream->runtime; in snd_rawmidi_read()
1003 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1007 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1011 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1013 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1015 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1020 if (!runtime->avail) in snd_rawmidi_read()
1022 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1024 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1046 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_empty() local
1050 if (runtime->buffer == NULL) { in snd_rawmidi_transmit_empty()
1055 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1056 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1057 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1074 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1076 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1082 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1087 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1090 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1093 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1094 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1095 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1099 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1100 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1101 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1127 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_peek() local
1131 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1133 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1147 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1149 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1154 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1155 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1156 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1157 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1160 if (runtime->drain || snd_rawmidi_ready(substream)) in __snd_rawmidi_transmit_ack()
1161 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1180 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_ack() local
1184 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1186 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1204 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit() local
1208 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit()
1218 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit()
1230 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1235 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1239 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1241 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1242 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1246 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1247 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1250 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1251 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1254 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1255 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1256 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1257 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1260 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1263 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1264 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1266 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1270 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1276 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1277 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1296 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1301 runtime = substream->runtime; in snd_rawmidi_write()
1303 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1307 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1311 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1315 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1317 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1319 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1324 if (!runtime->avail && !timeout) in snd_rawmidi_write()
1326 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1328 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1339 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1340 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1342 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1344 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1346 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1348 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1351 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1353 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1355 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1363 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1368 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1370 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1373 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1374 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1405 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1423 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1428 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1429 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1430 (unsigned long) runtime->avail); in snd_rawmidi_proc_info_read()
1447 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1452 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1453 (unsigned long) runtime->avail, in snd_rawmidi_proc_info_read()
1454 (unsigned long) runtime->xruns); in snd_rawmidi_proc_info_read()
1717 if (s->runtime) in snd_rawmidi_dev_disconnect()
1718 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()