Lines Matching refs:drvdata
56 static void snd_serial_generic_tx_wakeup(struct snd_serial_generic *drvdata) in snd_serial_generic_tx_wakeup() argument
58 if (test_and_set_bit(SERIAL_TX_STATE_ACTIVE, &drvdata->tx_state)) in snd_serial_generic_tx_wakeup()
59 set_bit(SERIAL_TX_STATE_WAKEUP, &drvdata->tx_state); in snd_serial_generic_tx_wakeup()
61 schedule_work(&drvdata->tx_work); in snd_serial_generic_tx_wakeup()
70 struct snd_serial_generic *drvdata = container_of(work, struct snd_serial_generic, in snd_serial_generic_tx_work() local
72 struct snd_rawmidi_substream *substream = drvdata->midi_output; in snd_serial_generic_tx_work()
74 clear_bit(SERIAL_TX_STATE_WAKEUP, &drvdata->tx_state); in snd_serial_generic_tx_work()
78 if (!test_bit(SERIAL_MODE_OUTPUT_OPEN, &drvdata->filemode)) in snd_serial_generic_tx_work()
82 num_bytes = serdev_device_write_buf(drvdata->serdev, buf, num_bytes); in snd_serial_generic_tx_work()
89 if (!test_bit(SERIAL_TX_STATE_WAKEUP, &drvdata->tx_state)) in snd_serial_generic_tx_work()
93 clear_bit(SERIAL_TX_STATE_ACTIVE, &drvdata->tx_state); in snd_serial_generic_tx_work()
98 struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev); in snd_serial_generic_write_wakeup() local
100 snd_serial_generic_tx_wakeup(drvdata); in snd_serial_generic_write_wakeup()
107 struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev); in snd_serial_generic_receive_buf() local
109 if (!test_bit(SERIAL_MODE_INPUT_OPEN, &drvdata->filemode)) in snd_serial_generic_receive_buf()
112 ret = snd_rawmidi_receive(drvdata->midi_input, buf, count); in snd_serial_generic_receive_buf()
121 static int snd_serial_generic_ensure_serdev_open(struct snd_serial_generic *drvdata) in snd_serial_generic_ensure_serdev_open() argument
126 if (drvdata->filemode) in snd_serial_generic_ensure_serdev_open()
129 dev_dbg(drvdata->card->dev, "Opening serial port for card %s\n", in snd_serial_generic_ensure_serdev_open()
130 drvdata->card->shortname); in snd_serial_generic_ensure_serdev_open()
131 err = serdev_device_open(drvdata->serdev); in snd_serial_generic_ensure_serdev_open()
135 actual_baud = serdev_device_set_baudrate(drvdata->serdev, in snd_serial_generic_ensure_serdev_open()
136 drvdata->baudrate); in snd_serial_generic_ensure_serdev_open()
137 if (actual_baud != drvdata->baudrate) { in snd_serial_generic_ensure_serdev_open()
138 dev_warn(drvdata->card->dev, "requested %d baud for card %s but it was actually set to %d\n", in snd_serial_generic_ensure_serdev_open()
139 drvdata->baudrate, drvdata->card->shortname, actual_baud); in snd_serial_generic_ensure_serdev_open()
148 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_input_open() local
150 dev_dbg(drvdata->card->dev, "Opening input for card %s\n", in snd_serial_generic_input_open()
151 drvdata->card->shortname); in snd_serial_generic_input_open()
153 err = snd_serial_generic_ensure_serdev_open(drvdata); in snd_serial_generic_input_open()
157 set_bit(SERIAL_MODE_INPUT_OPEN, &drvdata->filemode); in snd_serial_generic_input_open()
158 drvdata->midi_input = substream; in snd_serial_generic_input_open()
164 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_input_close() local
166 dev_dbg(drvdata->card->dev, "Closing input for card %s\n", in snd_serial_generic_input_close()
167 drvdata->card->shortname); in snd_serial_generic_input_close()
169 clear_bit(SERIAL_MODE_INPUT_OPEN, &drvdata->filemode); in snd_serial_generic_input_close()
170 clear_bit(SERIAL_MODE_INPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_input_close()
172 drvdata->midi_input = NULL; in snd_serial_generic_input_close()
174 if (!drvdata->filemode) in snd_serial_generic_input_close()
175 serdev_device_close(drvdata->serdev); in snd_serial_generic_input_close()
182 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_input_trigger() local
185 set_bit(SERIAL_MODE_INPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_input_trigger()
187 clear_bit(SERIAL_MODE_INPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_input_trigger()
192 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_output_open() local
195 dev_dbg(drvdata->card->dev, "Opening output for card %s\n", in snd_serial_generic_output_open()
196 drvdata->card->shortname); in snd_serial_generic_output_open()
198 err = snd_serial_generic_ensure_serdev_open(drvdata); in snd_serial_generic_output_open()
202 set_bit(SERIAL_MODE_OUTPUT_OPEN, &drvdata->filemode); in snd_serial_generic_output_open()
204 drvdata->midi_output = substream; in snd_serial_generic_output_open()
210 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_output_close() local
212 dev_dbg(drvdata->card->dev, "Closing output for card %s\n", in snd_serial_generic_output_close()
213 drvdata->card->shortname); in snd_serial_generic_output_close()
215 clear_bit(SERIAL_MODE_OUTPUT_OPEN, &drvdata->filemode); in snd_serial_generic_output_close()
216 clear_bit(SERIAL_MODE_OUTPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_output_close()
218 if (!drvdata->filemode) in snd_serial_generic_output_close()
219 serdev_device_close(drvdata->serdev); in snd_serial_generic_output_close()
221 drvdata->midi_output = NULL; in snd_serial_generic_output_close()
229 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_output_trigger() local
232 set_bit(SERIAL_MODE_OUTPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_output_trigger()
234 clear_bit(SERIAL_MODE_OUTPUT_TRIGGERED, &drvdata->filemode); in snd_serial_generic_output_trigger()
237 snd_serial_generic_tx_wakeup(drvdata); in snd_serial_generic_output_trigger()
242 struct snd_serial_generic *drvdata = substream->rmidi->card->private_data; in snd_serial_generic_output_drain() local
245 serdev_device_write_flush(drvdata->serdev); in snd_serial_generic_output_drain()
246 cancel_work_sync(&drvdata->tx_work); in snd_serial_generic_output_drain()
263 struct snd_serial_generic *drvdata) in snd_serial_generic_parse_dt() argument
268 &drvdata->baudrate); in snd_serial_generic_parse_dt()
270 dev_dbg(drvdata->card->dev, in snd_serial_generic_parse_dt()
273 drvdata->baudrate = 38400; in snd_serial_generic_parse_dt()
287 static int snd_serial_generic_rmidi(struct snd_serial_generic *drvdata, in snd_serial_generic_rmidi() argument
293 err = snd_rawmidi_new(drvdata->card, drvdata->card->driver, 0, in snd_serial_generic_rmidi()
303 strcpy(rrawmidi->name, drvdata->card->shortname); in snd_serial_generic_rmidi()
306 drvdata->serdev->ctrl->nr); in snd_serial_generic_rmidi()
308 drvdata->serdev->ctrl->nr); in snd_serial_generic_rmidi()
322 struct snd_serial_generic *drvdata; in snd_serial_generic_probe() local
336 drvdata = card->private_data; in snd_serial_generic_probe()
338 drvdata->serdev = serdev; in snd_serial_generic_probe()
339 drvdata->card = card; in snd_serial_generic_probe()
341 snd_serial_generic_parse_dt(serdev, drvdata); in snd_serial_generic_probe()
343 INIT_WORK(&drvdata->tx_work, snd_serial_generic_tx_work); in snd_serial_generic_probe()
345 err = snd_serial_generic_rmidi(drvdata, 1, 1, &drvdata->rmidi); in snd_serial_generic_probe()
350 serdev_device_set_drvdata(drvdata->serdev, drvdata); in snd_serial_generic_probe()