Lines Matching full:runtime

101 static inline bool __snd_rawmidi_ready(struct snd_rawmidi_runtime *runtime)  in __snd_rawmidi_ready()  argument
103 return runtime->avail >= runtime->avail_min; in __snd_rawmidi_ready()
112 ready = __snd_rawmidi_ready(substream->runtime); in snd_rawmidi_ready()
120 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_ready_append() local
122 return runtime->avail >= runtime->avail_min && in snd_rawmidi_ready_append()
123 (!substream->append || runtime->avail >= count); in snd_rawmidi_ready_append()
128 struct snd_rawmidi_runtime *runtime = in snd_rawmidi_input_event_work() local
131 if (runtime->event) in snd_rawmidi_input_event_work()
132 runtime->event(runtime->substream); in snd_rawmidi_input_event_work()
136 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_ref() argument
138 runtime->buffer_ref++; in snd_rawmidi_buffer_ref()
141 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime) in snd_rawmidi_buffer_unref() argument
143 runtime->buffer_ref--; in snd_rawmidi_buffer_unref()
151 while (substream->runtime->buffer_ref) { in snd_rawmidi_buffer_ref_sync()
165 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_runtime_create() local
167 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); in snd_rawmidi_runtime_create()
168 if (!runtime) in snd_rawmidi_runtime_create()
170 runtime->substream = substream; in snd_rawmidi_runtime_create()
171 init_waitqueue_head(&runtime->sleep); in snd_rawmidi_runtime_create()
172 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); in snd_rawmidi_runtime_create()
173 runtime->event = NULL; in snd_rawmidi_runtime_create()
174 runtime->buffer_size = PAGE_SIZE; in snd_rawmidi_runtime_create()
175 runtime->avail_min = 1; in snd_rawmidi_runtime_create()
177 runtime->avail = 0; in snd_rawmidi_runtime_create()
179 runtime->avail = runtime->buffer_size; in snd_rawmidi_runtime_create()
180 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL); in snd_rawmidi_runtime_create()
181 if (!runtime->buffer) { in snd_rawmidi_runtime_create()
182 kfree(runtime); in snd_rawmidi_runtime_create()
185 runtime->appl_ptr = runtime->hw_ptr = 0; in snd_rawmidi_runtime_create()
186 substream->runtime = runtime; in snd_rawmidi_runtime_create()
188 runtime->align = 3; in snd_rawmidi_runtime_create()
193 static inline int get_align(struct snd_rawmidi_runtime *runtime) in get_align() argument
196 return runtime->align; in get_align()
202 #define get_aligned_size(runtime, size) ((size) & ~get_align(runtime)) argument
206 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_runtime_free() local
208 kvfree(runtime->buffer); in snd_rawmidi_runtime_free()
209 kfree(runtime); in snd_rawmidi_runtime_free()
210 substream->runtime = NULL; in snd_rawmidi_runtime_free()
227 cancel_work_sync(&substream->runtime->event_work); in snd_rawmidi_input_trigger()
230 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime, in __reset_runtime_ptrs() argument
233 runtime->drain = 0; in __reset_runtime_ptrs()
234 runtime->appl_ptr = runtime->hw_ptr = 0; in __reset_runtime_ptrs()
235 runtime->avail = is_input ? 0 : runtime->buffer_size; in __reset_runtime_ptrs()
244 if (substream->opened && substream->runtime) in reset_runtime_ptrs()
245 __reset_runtime_ptrs(substream->runtime, is_input); in reset_runtime_ptrs()
261 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_drain_output() local
264 runtime = substream->runtime; in snd_rawmidi_drain_output()
265 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_drain_output()
268 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_drain_output()
269 runtime->drain = 1; in snd_rawmidi_drain_output()
275 timeout = wait_event_interruptible_timeout(runtime->sleep, in snd_rawmidi_drain_output()
276 (runtime->avail >= runtime->buffer_size), in snd_rawmidi_drain_output()
282 if (runtime->avail < runtime->buffer_size && !timeout) { in snd_rawmidi_drain_output()
285 (long)runtime->avail, (long)runtime->buffer_size); in snd_rawmidi_drain_output()
288 runtime->drain = 0; in snd_rawmidi_drain_output()
301 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_drain_output()
529 if (rawmidi_file->input && rawmidi_file->input->runtime) in snd_rawmidi_open()
530 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
531 if (rawmidi_file->output && rawmidi_file->output->runtime) in snd_rawmidi_open()
532 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); in snd_rawmidi_open()
576 if (substream->runtime->private_free) in close_substream()
577 substream->runtime->private_free(substream); in close_substream()
731 struct snd_rawmidi_runtime *runtime = substream->runtime; in resize_runtime_buffer() local
741 if (params->buffer_size & get_align(runtime)) in resize_runtime_buffer()
743 if (params->buffer_size != runtime->buffer_size) { in resize_runtime_buffer()
748 if (runtime->buffer_ref) { in resize_runtime_buffer()
753 oldbuf = runtime->buffer; in resize_runtime_buffer()
754 runtime->buffer = newbuf; in resize_runtime_buffer()
755 runtime->buffer_size = params->buffer_size; in resize_runtime_buffer()
756 __reset_runtime_ptrs(runtime, is_input); in resize_runtime_buffer()
760 runtime->avail_min = params->avail_min; in resize_runtime_buffer()
813 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_output_status() local
818 status->avail = runtime->avail; in snd_rawmidi_output_status()
826 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_input_status() local
831 status->avail = runtime->avail; in snd_rawmidi_input_status()
832 status->xruns = runtime->xruns; in snd_rawmidi_input_status()
833 runtime->xruns = 0; in snd_rawmidi_input_status()
1104 struct snd_rawmidi_runtime *runtime = substream->runtime; in receive_with_tstamp_framing() local
1109 int align = get_align(runtime); in receive_with_tstamp_framing()
1112 if (snd_BUG_ON((runtime->hw_ptr & 0x1f) != 0)) in receive_with_tstamp_framing()
1116 if ((int)(runtime->buffer_size - runtime->avail) < frame_size) { in receive_with_tstamp_framing()
1117 runtime->xruns += src_count; in receive_with_tstamp_framing()
1123 frame.length = get_aligned_size(runtime, src_count); in receive_with_tstamp_framing()
1131 dest_ptr = (struct snd_rawmidi_framing_tstamp *) (runtime->buffer + runtime->hw_ptr); in receive_with_tstamp_framing()
1133 runtime->avail += frame_size; in receive_with_tstamp_framing()
1134 runtime->hw_ptr += frame_size; in receive_with_tstamp_framing()
1135 runtime->hw_ptr %= runtime->buffer_size; in receive_with_tstamp_framing()
1174 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_receive() local
1181 runtime = substream->runtime; in snd_rawmidi_receive()
1182 if (!runtime || !runtime->buffer) { in snd_rawmidi_receive()
1189 count = get_aligned_size(runtime, count); in snd_rawmidi_receive()
1197 if (runtime->avail < runtime->buffer_size) { in snd_rawmidi_receive()
1198 runtime->buffer[runtime->hw_ptr++] = buffer[0]; in snd_rawmidi_receive()
1199 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1200 runtime->avail++; in snd_rawmidi_receive()
1203 runtime->xruns++; in snd_rawmidi_receive()
1207 count1 = runtime->buffer_size - runtime->hw_ptr; in snd_rawmidi_receive()
1210 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in snd_rawmidi_receive()
1211 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1212 count1 = get_aligned_size(runtime, count1); in snd_rawmidi_receive()
1215 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); in snd_rawmidi_receive()
1216 runtime->hw_ptr += count1; in snd_rawmidi_receive()
1217 runtime->hw_ptr %= runtime->buffer_size; in snd_rawmidi_receive()
1218 runtime->avail += count1; in snd_rawmidi_receive()
1224 if (count1 > (int)(runtime->buffer_size - runtime->avail)) { in snd_rawmidi_receive()
1225 count1 = runtime->buffer_size - runtime->avail; in snd_rawmidi_receive()
1226 runtime->xruns += count - count1; in snd_rawmidi_receive()
1229 memcpy(runtime->buffer, buffer, count1); in snd_rawmidi_receive()
1230 runtime->hw_ptr = count1; in snd_rawmidi_receive()
1231 runtime->avail += count1; in snd_rawmidi_receive()
1237 if (runtime->event) in snd_rawmidi_receive()
1238 schedule_work(&runtime->event_work); in snd_rawmidi_receive()
1239 else if (__snd_rawmidi_ready(runtime)) in snd_rawmidi_receive()
1240 wake_up(&runtime->sleep); in snd_rawmidi_receive()
1254 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_read1() local
1259 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_read1()
1260 while (count > 0 && runtime->avail) { in snd_rawmidi_kernel_read1()
1261 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1264 if (count1 > (int)runtime->avail) in snd_rawmidi_kernel_read1()
1265 count1 = runtime->avail; in snd_rawmidi_kernel_read1()
1267 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_read1()
1268 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_read1()
1269 runtime->appl_ptr += count1; in snd_rawmidi_kernel_read1()
1270 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_read1()
1271 runtime->avail -= count1; in snd_rawmidi_kernel_read1()
1274 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); in snd_rawmidi_kernel_read1()
1278 runtime->buffer + appl_ptr, count1)) in snd_rawmidi_kernel_read1()
1288 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_read1()
1308 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_read() local
1314 runtime = substream->runtime; in snd_rawmidi_read()
1319 while (!__snd_rawmidi_ready(runtime)) { in snd_rawmidi_read()
1327 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1331 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_read()
1337 if (!runtime->avail) { in snd_rawmidi_read()
1364 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_transmit_empty() local
1369 runtime = substream->runtime; in snd_rawmidi_transmit_empty()
1370 if (!substream->opened || !runtime || !runtime->buffer) { in snd_rawmidi_transmit_empty()
1375 result = runtime->avail >= runtime->buffer_size; in snd_rawmidi_transmit_empty()
1394 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_peek() local
1396 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_peek()
1402 if (runtime->avail >= runtime->buffer_size) { in __snd_rawmidi_transmit_peek()
1407 *buffer = runtime->buffer[runtime->hw_ptr]; in __snd_rawmidi_transmit_peek()
1410 count1 = runtime->buffer_size - runtime->hw_ptr; in __snd_rawmidi_transmit_peek()
1413 if (count1 > (int)(runtime->buffer_size - runtime->avail)) in __snd_rawmidi_transmit_peek()
1414 count1 = runtime->buffer_size - runtime->avail; in __snd_rawmidi_transmit_peek()
1415 count1 = get_aligned_size(runtime, count1); in __snd_rawmidi_transmit_peek()
1418 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1); in __snd_rawmidi_transmit_peek()
1422 if (count > (int)(runtime->buffer_size - runtime->avail - count1)) in __snd_rawmidi_transmit_peek()
1423 count = runtime->buffer_size - runtime->avail - count1; in __snd_rawmidi_transmit_peek()
1424 count = get_aligned_size(runtime, count); in __snd_rawmidi_transmit_peek()
1427 memcpy(buffer + count1, runtime->buffer, count); in __snd_rawmidi_transmit_peek()
1456 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_peek()
1475 struct snd_rawmidi_runtime *runtime = substream->runtime; in __snd_rawmidi_transmit_ack() local
1477 if (runtime->buffer == NULL) { in __snd_rawmidi_transmit_ack()
1482 snd_BUG_ON(runtime->avail + count > runtime->buffer_size); in __snd_rawmidi_transmit_ack()
1483 count = get_aligned_size(runtime, count); in __snd_rawmidi_transmit_ack()
1484 runtime->hw_ptr += count; in __snd_rawmidi_transmit_ack()
1485 runtime->hw_ptr %= runtime->buffer_size; in __snd_rawmidi_transmit_ack()
1486 runtime->avail += count; in __snd_rawmidi_transmit_ack()
1489 if (runtime->drain || __snd_rawmidi_ready(runtime)) in __snd_rawmidi_transmit_ack()
1490 wake_up(&runtime->sleep); in __snd_rawmidi_transmit_ack()
1512 if (!substream->opened || !substream->runtime) in snd_rawmidi_transmit_ack()
1560 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proceed() local
1565 runtime = substream->runtime; in snd_rawmidi_proceed()
1566 if (substream->opened && runtime && in snd_rawmidi_proceed()
1567 runtime->avail < runtime->buffer_size) { in snd_rawmidi_proceed()
1568 count = runtime->buffer_size - runtime->avail; in snd_rawmidi_proceed()
1583 struct snd_rawmidi_runtime *runtime = substream->runtime; in snd_rawmidi_kernel_write1() local
1588 if (snd_BUG_ON(!runtime->buffer)) in snd_rawmidi_kernel_write1()
1594 if ((long)runtime->avail < count) { in snd_rawmidi_kernel_write1()
1599 snd_rawmidi_buffer_ref(runtime); in snd_rawmidi_kernel_write1()
1600 while (count > 0 && runtime->avail > 0) { in snd_rawmidi_kernel_write1()
1601 count1 = runtime->buffer_size - runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1604 if (count1 > (long)runtime->avail) in snd_rawmidi_kernel_write1()
1605 count1 = runtime->avail; in snd_rawmidi_kernel_write1()
1607 /* update runtime->appl_ptr before unlocking for userbuf */ in snd_rawmidi_kernel_write1()
1608 appl_ptr = runtime->appl_ptr; in snd_rawmidi_kernel_write1()
1609 runtime->appl_ptr += count1; in snd_rawmidi_kernel_write1()
1610 runtime->appl_ptr %= runtime->buffer_size; in snd_rawmidi_kernel_write1()
1611 runtime->avail -= count1; in snd_rawmidi_kernel_write1()
1614 memcpy(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1618 if (copy_from_user(runtime->buffer + appl_ptr, in snd_rawmidi_kernel_write1()
1630 count1 = runtime->avail < runtime->buffer_size; in snd_rawmidi_kernel_write1()
1631 snd_rawmidi_buffer_unref(runtime); in snd_rawmidi_kernel_write1()
1651 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_write() local
1656 runtime = substream->runtime; in snd_rawmidi_write()
1658 if (substream->append && count > runtime->buffer_size) in snd_rawmidi_write()
1671 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1675 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1681 if (!runtime->avail && !timeout) { in snd_rawmidi_write()
1698 while (runtime->avail != runtime->buffer_size) { in snd_rawmidi_write()
1700 unsigned int last_avail = runtime->avail; in snd_rawmidi_write()
1703 add_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1707 remove_wait_queue(&runtime->sleep, &wait); in snd_rawmidi_write()
1710 if (runtime->avail == last_avail && !timeout) in snd_rawmidi_write()
1722 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_poll() local
1727 runtime = rfile->input->runtime; in snd_rawmidi_poll()
1729 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1732 runtime = rfile->output->runtime; in snd_rawmidi_poll()
1733 poll_wait(file, &runtime->sleep, wait); in snd_rawmidi_poll()
1763 struct snd_rawmidi_runtime *runtime; in snd_rawmidi_proc_info_read() local
1789 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1791 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1792 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1798 runtime->oss ? "OSS compatible" : "native", in snd_rawmidi_proc_info_read()
1816 runtime = substream->runtime; in snd_rawmidi_proc_info_read()
1818 buffer_size = runtime->buffer_size; in snd_rawmidi_proc_info_read()
1819 avail = runtime->avail; in snd_rawmidi_proc_info_read()
1820 xruns = runtime->xruns; in snd_rawmidi_proc_info_read()
2124 if (s->runtime) in snd_rawmidi_dev_disconnect()
2125 wake_up(&s->runtime->sleep); in snd_rawmidi_dev_disconnect()