• Home
  • Raw
  • Download

Lines Matching full:runtime

92 	struct snd_rawmidi_runtime *runtime = substream->runtime;  in snd_rawmidi_ready()  local
94 return runtime->avail >= runtime->avail_min; in snd_rawmidi_ready()
100 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
102 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
103 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
108 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
111 if (runtime->event) in snd_rawmidi_input_event_work()
112 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
115 /* buffer refcount management: call with runtime->lock held */
116 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_ref() argument
118 runtime->buffer_ref++; in snd_rawmidi_buffer_ref()
121 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_unref() argument
123 runtime->buffer_ref--; in snd_rawmidi_buffer_unref()
128 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
130 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
131 if (!runtime) in snd_rawmidi_runtime_create()
133 runtime->substream = substream; in snd_rawmidi_runtime_create()
134 spin_lock_init(&runtime->lock); in snd_rawmidi_runtime_create()
135 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
136 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
137 runtime->event = NULL; in snd_rawmidi_runtime_create()
138 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
139 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
141 runtime->avail = 0; in snd_rawmidi_runtime_create()
143 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
144 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
145 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
146 kfree(runtime); in snd_rawmidi_runtime_create()
149 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
150 substream->runtime = runtime; in snd_rawmidi_runtime_create()
156 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
158 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
159 kfree(runtime); in snd_rawmidi_runtime_free()
160 substream->runtime = NULL; in snd_rawmidi_runtime_free()
177 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
180 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
183 runtime->drain = 0; in __reset_runtime_ptrs()
184 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
185 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
188 static void reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in reset_runtime_ptrs() argument
193 spin_lock_irqsave(&runtime->lock, flags); in reset_runtime_ptrs()
194 __reset_runtime_ptrs(runtime, is_input); in reset_runtime_ptrs()
195 spin_unlock_irqrestore(&runtime->lock, flags); in reset_runtime_ptrs()
201 reset_runtime_ptrs(substream->runtime, false); in snd_rawmidi_drop_output()
210 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_drain_output() local
213 runtime->drain = 1; in snd_rawmidi_drain_output()
214 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
215 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
219 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
222 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
225 runtime->drain = 0; in snd_rawmidi_drain_output()
241 reset_runtime_ptrs(substream->runtime, true); in snd_rawmidi_drain_input()
465 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
466 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
467 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
468 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
507 if (substream->runtime->private_free) in close_substream()
508 substream->runtime->private_free(substream); in close_substream()
660 static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime, in resize_runtime_buffer() argument
670 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
674 spin_lock_irq(&runtime->lock); in resize_runtime_buffer()
675 if (runtime->buffer_ref) { in resize_runtime_buffer()
676 spin_unlock_irq(&runtime->lock); in resize_runtime_buffer()
680 oldbuf = runtime->buffer; in resize_runtime_buffer()
681 runtime->buffer = newbuf; in resize_runtime_buffer()
682 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
683 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
684 spin_unlock_irq(&runtime->lock); in resize_runtime_buffer()
687 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
698 return resize_runtime_buffer(substream->runtime, params, false); in snd_rawmidi_output_params()
706 return resize_runtime_buffer(substream->runtime, params, true); in snd_rawmidi_input_params()
713 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
717 spin_lock_irq(&runtime->lock); in snd_rawmidi_output_status()
718 status->avail = runtime->avail; in snd_rawmidi_output_status()
719 spin_unlock_irq(&runtime->lock); in snd_rawmidi_output_status()
726 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
730 spin_lock_irq(&runtime->lock); in snd_rawmidi_input_status()
731 status->avail = runtime->avail; in snd_rawmidi_input_status()
732 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
733 runtime->xruns = 0; in snd_rawmidi_input_status()
734 spin_unlock_irq(&runtime->lock); in snd_rawmidi_input_status()
912 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_receive() local
916 if (runtime->buffer == NULL) { in snd_rawmidi_receive()
921 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_receive()
924 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
925 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
926 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
927 runtime->avail++; in snd_rawmidi_receive()
930 runtime->xruns++; in snd_rawmidi_receive()
934 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
937 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
938 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
939 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
940 runtime->hw_ptr += count1; in snd_rawmidi_receive()
941 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
942 runtime->avail += count1; in snd_rawmidi_receive()
948 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
949 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
950 runtime->xruns += count - count1; in snd_rawmidi_receive()
953 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
954 runtime->hw_ptr = count1; in snd_rawmidi_receive()
955 runtime->avail += count1; in snd_rawmidi_receive()
961 if (runtime->event) in snd_rawmidi_receive()
962 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
964 wake_up(&runtime->sleep); in snd_rawmidi_receive()
966 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_receive()
977 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
981 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
982 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_read1()
983 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
984 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
987 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
988 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
990 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_read1()
991 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
992 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
993 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
994 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
997 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
999 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
1001 runtime->buffer + appl_ptr, count1)) in snd_rawmidi_kernel_read1()
1003 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
1011 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_read1()
1012 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_read1()
1031 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1037 runtime = substream->runtime; in snd_rawmidi_read()
1041 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1046 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1050 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1052 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1054 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1059 if (!runtime->avail) in snd_rawmidi_read()
1061 spin_lock_irq(&runtime->lock); in snd_rawmidi_read()
1063 spin_unlock_irq(&runtime->lock); in snd_rawmidi_read()
1085 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_empty() local
1089 if (runtime->buffer == NULL) { in snd_rawmidi_transmit_empty()
1094 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1095 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1096 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_empty()
1113 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1115 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1121 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1126 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1129 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1132 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1133 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1134 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1138 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1139 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1140 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1166 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_peek() local
1170 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1172 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_peek()
1186 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1188 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1193 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1194 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1195 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1196 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1199 if (runtime->drain || snd_rawmidi_ready(substream)) in __snd_rawmidi_transmit_ack()
1200 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1219 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit_ack() local
1223 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1225 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit_ack()
1243 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_transmit() local
1247 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_transmit()
1257 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_transmit()
1269 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1274 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1278 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1280 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1281 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1285 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_write1()
1286 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1287 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1290 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1291 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1293 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_write1()
1294 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1295 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1296 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1297 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1300 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1303 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1304 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1306 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1310 spin_lock_irqsave(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1316 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1317 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_write1()
1318 spin_unlock_irqrestore(&runtime->lock, flags); in snd_rawmidi_kernel_write1()
1337 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1342 runtime = substream->runtime; in snd_rawmidi_write()
1344 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1348 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1353 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1357 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1359 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1361 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1366 if (!runtime->avail && !timeout) in snd_rawmidi_write()
1368 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1370 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1381 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1382 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1384 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1387 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1389 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1391 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1394 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1396 spin_lock_irq(&runtime->lock); in snd_rawmidi_write()
1398 spin_unlock_irq(&runtime->lock); in snd_rawmidi_write()
1406 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1411 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1413 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1416 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1417 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1447 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1465 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1470 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1471 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1472 (unsigned long) runtime->avail); in snd_rawmidi_proc_info_read()
1489 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1494 (unsigned long) runtime->buffer_size, in snd_rawmidi_proc_info_read()
1495 (unsigned long) runtime->avail, in snd_rawmidi_proc_info_read()
1496 (unsigned long) runtime->xruns); in snd_rawmidi_proc_info_read()
1770 if (s->runtime) in snd_rawmidi_dev_disconnect()
1771 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()