Lines Matching full:chip

54 static void dac_audio_start_timer(struct snd_sh_dac *chip)  in dac_audio_start_timer()  argument
56 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in dac_audio_start_timer()
60 static void dac_audio_stop_timer(struct snd_sh_dac *chip) in dac_audio_stop_timer() argument
62 hrtimer_cancel(&chip->hrtimer); in dac_audio_stop_timer()
65 static void dac_audio_reset(struct snd_sh_dac *chip) in dac_audio_reset() argument
67 dac_audio_stop_timer(chip); in dac_audio_reset()
68 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in dac_audio_reset()
69 chip->processed = 0; in dac_audio_reset()
70 chip->empty = 1; in dac_audio_reset()
73 static void dac_audio_set_rate(struct snd_sh_dac *chip) in dac_audio_set_rate() argument
75 chip->wakeups_per_second = 1000000000 / chip->rate; in dac_audio_set_rate()
101 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_open() local
106 chip->substream = substream; in snd_sh_dac_pcm_open()
107 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_open()
108 chip->processed = 0; in snd_sh_dac_pcm_open()
109 chip->empty = 1; in snd_sh_dac_pcm_open()
111 chip->pdata->start(chip->pdata); in snd_sh_dac_pcm_open()
118 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_close() local
120 chip->substream = NULL; in snd_sh_dac_pcm_close()
122 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_close()
123 chip->pdata->stop(chip->pdata); in snd_sh_dac_pcm_close()
142 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_prepare() local
143 struct snd_pcm_runtime *runtime = chip->substream->runtime; in snd_sh_dac_pcm_prepare()
145 chip->buffer_size = runtime->buffer_size; in snd_sh_dac_pcm_prepare()
146 memset(chip->data_buffer, 0, chip->pdata->buffer_size); in snd_sh_dac_pcm_prepare()
153 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_trigger() local
157 dac_audio_start_timer(chip); in snd_sh_dac_pcm_trigger()
160 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_trigger()
161 chip->processed = 0; in snd_sh_dac_pcm_trigger()
162 chip->empty = 1; in snd_sh_dac_pcm_trigger()
163 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_trigger()
177 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_copy() local
180 if (copy_from_user_toio(chip->data_buffer + pos, src, count)) in snd_sh_dac_pcm_copy()
182 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_copy()
184 if (chip->empty) { in snd_sh_dac_pcm_copy()
185 chip->empty = 0; in snd_sh_dac_pcm_copy()
186 dac_audio_start_timer(chip); in snd_sh_dac_pcm_copy()
197 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_copy_kernel() local
200 memcpy_toio(chip->data_buffer + pos, src, count); in snd_sh_dac_pcm_copy_kernel()
201 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_copy_kernel()
203 if (chip->empty) { in snd_sh_dac_pcm_copy_kernel()
204 chip->empty = 0; in snd_sh_dac_pcm_copy_kernel()
205 dac_audio_start_timer(chip); in snd_sh_dac_pcm_copy_kernel()
216 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_silence() local
219 memset_io(chip->data_buffer + pos, 0, count); in snd_sh_dac_pcm_silence()
220 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_silence()
222 if (chip->empty) { in snd_sh_dac_pcm_silence()
223 chip->empty = 0; in snd_sh_dac_pcm_silence()
224 dac_audio_start_timer(chip); in snd_sh_dac_pcm_silence()
233 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_pointer() local
234 int pointer = chip->buffer_begin - chip->data_buffer; in snd_sh_dac_pcm_pointer()
255 static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) in snd_sh_dac_pcm() argument
261 err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); in snd_sh_dac_pcm()
265 pcm->private_data = chip; in snd_sh_dac_pcm()
288 static int snd_sh_dac_free(struct snd_sh_dac *chip) in snd_sh_dac_free() argument
291 kfree(chip->data_buffer); in snd_sh_dac_free()
292 kfree(chip); in snd_sh_dac_free()
299 struct snd_sh_dac *chip = device->device_data; in snd_sh_dac_dev_free() local
301 return snd_sh_dac_free(chip); in snd_sh_dac_dev_free()
306 struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, in sh_dac_audio_timer() local
308 struct snd_pcm_runtime *runtime = chip->substream->runtime; in sh_dac_audio_timer()
311 if (!chip->empty) { in sh_dac_audio_timer()
312 sh_dac_output(*chip->buffer_begin, chip->pdata->channel); in sh_dac_audio_timer()
313 chip->buffer_begin++; in sh_dac_audio_timer()
315 chip->processed++; in sh_dac_audio_timer()
316 if (chip->processed >= b_ps) { in sh_dac_audio_timer()
317 chip->processed -= b_ps; in sh_dac_audio_timer()
318 snd_pcm_period_elapsed(chip->substream); in sh_dac_audio_timer()
321 if (chip->buffer_begin == (chip->data_buffer + in sh_dac_audio_timer()
322 chip->buffer_size - 1)) in sh_dac_audio_timer()
323 chip->buffer_begin = chip->data_buffer; in sh_dac_audio_timer()
325 if (chip->buffer_begin == chip->buffer_end) in sh_dac_audio_timer()
326 chip->empty = 1; in sh_dac_audio_timer()
330 if (!chip->empty) in sh_dac_audio_timer()
331 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in sh_dac_audio_timer()
337 /* create -- chip-specific constructor for the cards components */
342 struct snd_sh_dac *chip; in snd_sh_dac_create() local
351 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_sh_dac_create()
352 if (chip == NULL) in snd_sh_dac_create()
355 chip->card = card; in snd_sh_dac_create()
357 hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in snd_sh_dac_create()
358 chip->hrtimer.function = sh_dac_audio_timer; in snd_sh_dac_create()
360 dac_audio_reset(chip); in snd_sh_dac_create()
361 chip->rate = 8000; in snd_sh_dac_create()
362 dac_audio_set_rate(chip); in snd_sh_dac_create()
364 chip->pdata = devptr->dev.platform_data; in snd_sh_dac_create()
366 chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); in snd_sh_dac_create()
367 if (chip->data_buffer == NULL) { in snd_sh_dac_create()
368 kfree(chip); in snd_sh_dac_create()
372 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_sh_dac_create()
374 snd_sh_dac_free(chip); in snd_sh_dac_create()
378 *rchip = chip; in snd_sh_dac_create()
386 struct snd_sh_dac *chip; in snd_sh_dac_probe() local
396 err = snd_sh_dac_create(card, devptr, &chip); in snd_sh_dac_probe()
400 err = snd_sh_dac_pcm(chip, 0); in snd_sh_dac_probe()