Lines Matching refs:chip

53 static void dac_audio_start_timer(struct snd_sh_dac *chip)  in dac_audio_start_timer()  argument
55 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in dac_audio_start_timer()
59 static void dac_audio_stop_timer(struct snd_sh_dac *chip) in dac_audio_stop_timer() argument
61 hrtimer_cancel(&chip->hrtimer); in dac_audio_stop_timer()
64 static void dac_audio_reset(struct snd_sh_dac *chip) in dac_audio_reset() argument
66 dac_audio_stop_timer(chip); in dac_audio_reset()
67 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in dac_audio_reset()
68 chip->processed = 0; in dac_audio_reset()
69 chip->empty = 1; in dac_audio_reset()
72 static void dac_audio_set_rate(struct snd_sh_dac *chip) in dac_audio_set_rate() argument
74 chip->wakeups_per_second = 1000000000 / chip->rate; in dac_audio_set_rate()
100 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_open() local
105 chip->substream = substream; in snd_sh_dac_pcm_open()
106 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_open()
107 chip->processed = 0; in snd_sh_dac_pcm_open()
108 chip->empty = 1; in snd_sh_dac_pcm_open()
110 chip->pdata->start(chip->pdata); in snd_sh_dac_pcm_open()
117 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_close() local
119 chip->substream = NULL; in snd_sh_dac_pcm_close()
121 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_close()
122 chip->pdata->stop(chip->pdata); in snd_sh_dac_pcm_close()
129 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_prepare() local
130 struct snd_pcm_runtime *runtime = chip->substream->runtime; in snd_sh_dac_pcm_prepare()
132 chip->buffer_size = runtime->buffer_size; in snd_sh_dac_pcm_prepare()
133 memset(chip->data_buffer, 0, chip->pdata->buffer_size); in snd_sh_dac_pcm_prepare()
140 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_trigger() local
144 dac_audio_start_timer(chip); in snd_sh_dac_pcm_trigger()
147 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_trigger()
148 chip->processed = 0; in snd_sh_dac_pcm_trigger()
149 chip->empty = 1; in snd_sh_dac_pcm_trigger()
150 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_trigger()
164 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_copy() local
166 if (copy_from_user_toio(chip->data_buffer + pos, src, count)) in snd_sh_dac_pcm_copy()
168 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_copy()
170 if (chip->empty) { in snd_sh_dac_pcm_copy()
171 chip->empty = 0; in snd_sh_dac_pcm_copy()
172 dac_audio_start_timer(chip); in snd_sh_dac_pcm_copy()
183 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_copy_kernel() local
185 memcpy_toio(chip->data_buffer + pos, src, count); in snd_sh_dac_pcm_copy_kernel()
186 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_copy_kernel()
188 if (chip->empty) { in snd_sh_dac_pcm_copy_kernel()
189 chip->empty = 0; in snd_sh_dac_pcm_copy_kernel()
190 dac_audio_start_timer(chip); in snd_sh_dac_pcm_copy_kernel()
201 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_silence() local
203 memset_io(chip->data_buffer + pos, 0, count); in snd_sh_dac_pcm_silence()
204 chip->buffer_end = chip->data_buffer + pos + count; in snd_sh_dac_pcm_silence()
206 if (chip->empty) { in snd_sh_dac_pcm_silence()
207 chip->empty = 0; in snd_sh_dac_pcm_silence()
208 dac_audio_start_timer(chip); in snd_sh_dac_pcm_silence()
217 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_pointer() local
218 int pointer = chip->buffer_begin - chip->data_buffer; in snd_sh_dac_pcm_pointer()
236 static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) in snd_sh_dac_pcm() argument
242 err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); in snd_sh_dac_pcm()
246 pcm->private_data = chip; in snd_sh_dac_pcm()
267 static int snd_sh_dac_free(struct snd_sh_dac *chip) in snd_sh_dac_free() argument
270 kfree(chip->data_buffer); in snd_sh_dac_free()
271 kfree(chip); in snd_sh_dac_free()
278 struct snd_sh_dac *chip = device->device_data; in snd_sh_dac_dev_free() local
280 return snd_sh_dac_free(chip); in snd_sh_dac_dev_free()
285 struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, in sh_dac_audio_timer() local
287 struct snd_pcm_runtime *runtime = chip->substream->runtime; in sh_dac_audio_timer()
290 if (!chip->empty) { in sh_dac_audio_timer()
291 sh_dac_output(*chip->buffer_begin, chip->pdata->channel); in sh_dac_audio_timer()
292 chip->buffer_begin++; in sh_dac_audio_timer()
294 chip->processed++; in sh_dac_audio_timer()
295 if (chip->processed >= b_ps) { in sh_dac_audio_timer()
296 chip->processed -= b_ps; in sh_dac_audio_timer()
297 snd_pcm_period_elapsed(chip->substream); in sh_dac_audio_timer()
300 if (chip->buffer_begin == (chip->data_buffer + in sh_dac_audio_timer()
301 chip->buffer_size - 1)) in sh_dac_audio_timer()
302 chip->buffer_begin = chip->data_buffer; in sh_dac_audio_timer()
304 if (chip->buffer_begin == chip->buffer_end) in sh_dac_audio_timer()
305 chip->empty = 1; in sh_dac_audio_timer()
309 if (!chip->empty) in sh_dac_audio_timer()
310 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in sh_dac_audio_timer()
321 struct snd_sh_dac *chip; in snd_sh_dac_create() local
330 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_sh_dac_create()
331 if (chip == NULL) in snd_sh_dac_create()
334 chip->card = card; in snd_sh_dac_create()
336 hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in snd_sh_dac_create()
337 chip->hrtimer.function = sh_dac_audio_timer; in snd_sh_dac_create()
339 dac_audio_reset(chip); in snd_sh_dac_create()
340 chip->rate = 8000; in snd_sh_dac_create()
341 dac_audio_set_rate(chip); in snd_sh_dac_create()
343 chip->pdata = devptr->dev.platform_data; in snd_sh_dac_create()
345 chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); in snd_sh_dac_create()
346 if (chip->data_buffer == NULL) { in snd_sh_dac_create()
347 kfree(chip); in snd_sh_dac_create()
351 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_sh_dac_create()
353 snd_sh_dac_free(chip); in snd_sh_dac_create()
357 *rchip = chip; in snd_sh_dac_create()
365 struct snd_sh_dac *chip; in snd_sh_dac_probe() local
375 err = snd_sh_dac_create(card, devptr, &chip); in snd_sh_dac_probe()
379 err = snd_sh_dac_pcm(chip, 0); in snd_sh_dac_probe()