Lines Matching refs:runtime

98 static inline bool __snd_rawmidi_ready(struct snd_rawmidi_runtime *runtime)  in __snd_rawmidi_ready()  argument
100 return runtime->avail >= runtime->avail_min; in __snd_rawmidi_ready()
109 ready = __snd_rawmidi_ready(substream->runtime); in snd_rawmidi_ready()
117 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
119 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
120 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
125 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
128 if (runtime->event) in snd_rawmidi_input_event_work()
129 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
133 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_ref() argument
135 runtime->buffer_ref++; in snd_rawmidi_buffer_ref()
138 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_unref() argument
140 runtime->buffer_ref--; in snd_rawmidi_buffer_unref()
148 while (substream->runtime->buffer_ref) { in snd_rawmidi_buffer_ref_sync()
162 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
164 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
165 if (!runtime) in snd_rawmidi_runtime_create()
167 runtime->substream = substream; in snd_rawmidi_runtime_create()
168 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
169 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
170 runtime->event = NULL; in snd_rawmidi_runtime_create()
171 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
172 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
174 runtime->avail = 0; in snd_rawmidi_runtime_create()
176 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
177 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
178 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
179 kfree(runtime); in snd_rawmidi_runtime_create()
182 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
183 substream->runtime = runtime; in snd_rawmidi_runtime_create()
189 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
191 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
192 kfree(runtime); in snd_rawmidi_runtime_free()
193 substream->runtime = NULL; in snd_rawmidi_runtime_free()
210 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
213 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
216 runtime->drain = 0; in __reset_runtime_ptrs()
217 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
218 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
227 if (substream->opened && substream->runtime) in reset_runtime_ptrs()
228 __reset_runtime_ptrs(substream->runtime, is_input); in reset_runtime_ptrs()
244 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_drain_output() local
247 runtime = substream->runtime; in snd_rawmidi_drain_output()
248 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_drain_output()
251 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_drain_output()
252 runtime->drain = 1; in snd_rawmidi_drain_output()
258 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
259 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
265 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
268 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
271 runtime->drain = 0; in snd_rawmidi_drain_output()
284 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_drain_output()
521 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
522 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
523 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
524 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
568 if (substream->runtime->private_free) in close_substream()
569 substream->runtime->private_free(substream); in close_substream()
723 struct snd_rawmidi_runtime *runtime = substream->runtime; in resize_runtime_buffer() local
733 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
738 if (runtime->buffer_ref) { in resize_runtime_buffer()
743 oldbuf = runtime->buffer; in resize_runtime_buffer()
744 runtime->buffer = newbuf; in resize_runtime_buffer()
745 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
746 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
750 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
803 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
808 status->avail = runtime->avail; in snd_rawmidi_output_status()
816 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
821 status->avail = runtime->avail; in snd_rawmidi_input_status()
822 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
823 runtime->xruns = 0; in snd_rawmidi_input_status()
1050 struct snd_rawmidi_runtime *runtime = substream->runtime; in receive_with_tstamp_framing() local
1057 if (snd_BUG_ON((runtime->hw_ptr & 0x1f) != 0)) in receive_with_tstamp_framing()
1061 if ((int)(runtime->buffer_size - runtime->avail) < frame_size) { in receive_with_tstamp_framing()
1062 runtime->xruns += src_count; in receive_with_tstamp_framing()
1074 dest_ptr = (struct snd_rawmidi_framing_tstamp *) (runtime->buffer + runtime->hw_ptr); in receive_with_tstamp_framing()
1076 runtime->avail += frame_size; in receive_with_tstamp_framing()
1077 runtime->hw_ptr += frame_size; in receive_with_tstamp_framing()
1078 runtime->hw_ptr %= runtime->buffer_size; in receive_with_tstamp_framing()
1117 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_receive() local
1124 runtime = substream->runtime; in snd_rawmidi_receive()
1125 if (!runtime || !runtime->buffer) { in snd_rawmidi_receive()
1136 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
1137 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
1138 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1139 runtime->avail++; in snd_rawmidi_receive()
1142 runtime->xruns++; in snd_rawmidi_receive()
1146 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
1149 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
1150 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1151 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
1152 runtime->hw_ptr += count1; in snd_rawmidi_receive()
1153 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1154 runtime->avail += count1; in snd_rawmidi_receive()
1160 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
1161 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1162 runtime->xruns += count - count1; in snd_rawmidi_receive()
1165 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
1166 runtime->hw_ptr = count1; in snd_rawmidi_receive()
1167 runtime->avail += count1; in snd_rawmidi_receive()
1173 if (runtime->event) in snd_rawmidi_receive()
1174 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
1175 else if (__snd_rawmidi_ready(runtime)) in snd_rawmidi_receive()
1176 wake_up(&runtime->sleep); in snd_rawmidi_receive()
1190 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
1195 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_read1()
1196 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
1197 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1200 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
1201 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
1204 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1205 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
1206 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
1207 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
1210 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
1214 runtime->buffer + appl_ptr, count1)) in snd_rawmidi_kernel_read1()
1224 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_read1()
1244 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1250 runtime = substream->runtime; in snd_rawmidi_read()
1255 while (!__snd_rawmidi_ready(runtime)) { in snd_rawmidi_read()
1263 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1267 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1273 if (!runtime->avail) { in snd_rawmidi_read()
1300 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_transmit_empty() local
1305 runtime = substream->runtime; in snd_rawmidi_transmit_empty()
1306 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_transmit_empty()
1311 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1330 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1332 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1338 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1343 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1346 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1349 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1350 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1351 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1355 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1356 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1357 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1386 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_peek()
1405 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1407 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1412 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1413 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1414 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1415 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1418 if (runtime->drain || __snd_rawmidi_ready(runtime)) in __snd_rawmidi_transmit_ack()
1419 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1441 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_ack()
1489 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proceed() local
1494 runtime = substream->runtime; in snd_rawmidi_proceed()
1495 if (substream->opened && runtime && in snd_rawmidi_proceed()
1496 runtime->avail < runtime->buffer_size) { in snd_rawmidi_proceed()
1497 count = runtime->buffer_size - runtime->avail; in snd_rawmidi_proceed()
1512 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1517 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1523 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1528 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_write1()
1529 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1530 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1533 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1534 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1537 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1538 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1539 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1540 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1543 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1547 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1559 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1560 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_write1()
1580 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1585 runtime = substream->runtime; in snd_rawmidi_write()
1587 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1600 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1604 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1610 if (!runtime->avail && !timeout) { in snd_rawmidi_write()
1627 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1629 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1632 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1636 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1639 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1651 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1656 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1658 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1661 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1662 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1692 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1713 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1715 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1716 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1722 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1740 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1742 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1743 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1744 xruns = runtime->xruns; in snd_rawmidi_proc_info_read()
2031 if (s->runtime) in snd_rawmidi_dev_disconnect()
2032 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()