Lines Matching full:runtime
77 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready() local
79 return runtime->avail >= runtime->avail_min; in snd_rawmidi_ready()
85 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
87 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
88 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
93 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
96 if (runtime->event) in snd_rawmidi_input_event_work()
97 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
102 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
104 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
105 if (!runtime) in snd_rawmidi_runtime_create()
107 runtime->substream = substream; in snd_rawmidi_runtime_create()
108 spin_lock_init(&runtime->lock); in snd_rawmidi_runtime_create()
109 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
110 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
111 runtime->event = NULL; in snd_rawmidi_runtime_create()
112 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
113 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
115 runtime->avail = 0; in snd_rawmidi_runtime_create()
117 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
118 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
119 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
120 kfree(runtime); in snd_rawmidi_runtime_create()
123 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
124 substream->runtime = runtime; in snd_rawmidi_runtime_create()
130 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
132 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
133 kfree(runtime); in snd_rawmidi_runtime_free()
134 substream->runtime = NULL; in snd_rawmidi_runtime_free()
151 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
154 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
157 runtime->drain = 0; in __reset_runtime_ptrs()
158 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
159 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
162 static void reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in reset_runtime_ptrs() argument
167 spin_lock_irqsave(&runtime->lock, flags); in reset_runtime_ptrs()
168 __reset_runtime_ptrs(runtime, is_input); in reset_runtime_ptrs()
169 spin_unlock_irqrestore(&runtime->lock, flags); in reset_runtime_ptrs()
175 reset_runtime_ptrs(substream->runtime, false); in snd_rawmidi_drop_output()
184 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drain_output() local
187 runtime->drain = 1; in snd_rawmidi_drain_output()
188 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
189 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
193 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
196 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
199 runtime->drain = 0; in snd_rawmidi_drain_output()
215 reset_runtime_ptrs(substream->runtime, true); in snd_rawmidi_drain_input()
439 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
440 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
441 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
442 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
481 if (substream->runtime->private_free) in close_substream()
482 substream->runtime->private_free(substream); in close_substream()
634 static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime, in resize_runtime_buffer() argument
644 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
648 spin_lock_irq(&runtime->lock); in resize_runtime_buffer()
649 oldbuf = runtime->buffer; in resize_runtime_buffer()
650 runtime->buffer = newbuf; in resize_runtime_buffer()
651 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
652 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
653 spin_unlock_irq(&runtime->lock); in resize_runtime_buffer()
656 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
667 return resize_runtime_buffer(substream->runtime, params, false); in snd_rawmidi_output_params()
675 return resize_runtime_buffer(substream->runtime, params, true); in snd_rawmidi_input_params()
682 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
686 spin_lock_irq(&runtime->lock); in snd_rawmidi_output_status()
687 status->avail = runtime->avail; in snd_rawmidi_output_status()
688 spin_unlock_irq(&runtime->lock); in snd_rawmidi_output_status()
695 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
699 spin_lock_irq(&runtime->lock); in snd_rawmidi_input_status()
700 status->avail = runtime->avail; in snd_rawmidi_input_status()
701 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
702 runtime->xruns = 0; in snd_rawmidi_input_status()
703 spin_unlock_irq(&runtime->lock); in snd_rawmidi_input_status()
881 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_receive() local
885 if (runtime->buffer == NULL) { in snd_rawmidi_receive()
890 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_receive()
893 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
894 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
895 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
896 runtime->avail++; in snd_rawmidi_receive()
899 runtime->xruns++; in snd_rawmidi_receive()
903 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
906 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
907 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
908 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
909 runtime->hw_ptr += count1; in snd_rawmidi_receive()
910 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
911 runtime->avail += count1; in snd_rawmidi_receive()
917 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
918 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
919 runtime->xruns += count - count1; in snd_rawmidi_receive()
922 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
923 runtime->hw_ptr = count1; in snd_rawmidi_receive()
924 runtime->avail += count1; in snd_rawmidi_receive()
930 if (runtime->event) in snd_rawmidi_receive()
931 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
933 wake_up(&runtime->sleep); in snd_rawmidi_receive()
935 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_receive()
946 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
949 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
950 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
951 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
954 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
955 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
957 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_read1()
958 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
959 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
960 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
961 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
964 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
966 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
968 runtime->buffer + appl_ptr, count1)) { in snd_rawmidi_kernel_read1()
971 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
976 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
995 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1001 runtime = substream->runtime; in snd_rawmidi_read()
1005 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1010 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1014 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1016 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1018 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1023 if (!runtime->avail) in snd_rawmidi_read()
1025 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1027 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1049 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_empty() local
1053 if (runtime->buffer == NULL) { in snd_rawmidi_transmit_empty()
1058 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1059 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1060 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1077 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1079 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1085 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1090 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1093 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1096 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1097 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1098 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1102 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1103 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1104 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1130 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_peek() local
1134 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1136 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1150 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1152 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1157 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1158 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1159 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1160 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1163 if (runtime->drain || snd_rawmidi_ready(substream)) in __snd_rawmidi_transmit_ack()
1164 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1183 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_ack() local
1187 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1189 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1207 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit() local
1211 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit()
1221 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit()
1234 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_proceed() local
1238 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_proceed()
1239 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_proceed()
1240 count = runtime->buffer_size - runtime->avail; in snd_rawmidi_proceed()
1243 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_proceed()
1255 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1260 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1264 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1266 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1267 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1271 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1272 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1275 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1276 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1278 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_write1()
1279 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1280 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1281 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1282 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1285 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1288 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1289 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1291 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1295 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1301 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1302 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1321 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1326 runtime = substream->runtime; in snd_rawmidi_write()
1328 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1332 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1337 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1341 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1343 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1345 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1350 if (!runtime->avail && !timeout) in snd_rawmidi_write()
1352 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1354 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1365 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1366 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1368 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1371 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1373 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1375 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1378 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1380 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1382 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1390 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1395 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1397 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1400 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1401 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1431 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1449 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1454 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1455 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1456 (unsigned long) runtime->avail); in snd_rawmidi_proc_info_read()
1473 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1478 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1479 (unsigned long) runtime->avail, in snd_rawmidi_proc_info_read()
1480 (unsigned long) runtime->xruns); in snd_rawmidi_proc_info_read()
1754 if (s->runtime) in snd_rawmidi_dev_disconnect()
1755 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()