Lines Matching refs:chip
69 static void dac_audio_start_timer(struct snd_sh_dac *chip) in dac_audio_start_timer() argument
71 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in dac_audio_start_timer()
75 static void dac_audio_stop_timer(struct snd_sh_dac *chip) in dac_audio_stop_timer() argument
77 hrtimer_cancel(&chip->hrtimer); in dac_audio_stop_timer()
80 static void dac_audio_reset(struct snd_sh_dac *chip) in dac_audio_reset() argument
82 dac_audio_stop_timer(chip); in dac_audio_reset()
83 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in dac_audio_reset()
84 chip->processed = 0; in dac_audio_reset()
85 chip->empty = 1; in dac_audio_reset()
88 static void dac_audio_set_rate(struct snd_sh_dac *chip) in dac_audio_set_rate() argument
90 chip->wakeups_per_second = ktime_set(0, 1000000000 / chip->rate); in dac_audio_set_rate()
116 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_open() local
121 chip->substream = substream; in snd_sh_dac_pcm_open()
122 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_open()
123 chip->processed = 0; in snd_sh_dac_pcm_open()
124 chip->empty = 1; in snd_sh_dac_pcm_open()
126 chip->pdata->start(chip->pdata); in snd_sh_dac_pcm_open()
133 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_close() local
135 chip->substream = NULL; in snd_sh_dac_pcm_close()
137 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_close()
138 chip->pdata->stop(chip->pdata); in snd_sh_dac_pcm_close()
157 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_prepare() local
158 struct snd_pcm_runtime *runtime = chip->substream->runtime; in snd_sh_dac_pcm_prepare()
160 chip->buffer_size = runtime->buffer_size; in snd_sh_dac_pcm_prepare()
161 memset(chip->data_buffer, 0, chip->pdata->buffer_size); in snd_sh_dac_pcm_prepare()
168 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_trigger() local
172 dac_audio_start_timer(chip); in snd_sh_dac_pcm_trigger()
175 chip->buffer_begin = chip->buffer_end = chip->data_buffer; in snd_sh_dac_pcm_trigger()
176 chip->processed = 0; in snd_sh_dac_pcm_trigger()
177 chip->empty = 1; in snd_sh_dac_pcm_trigger()
178 dac_audio_stop_timer(chip); in snd_sh_dac_pcm_trigger()
191 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_copy() local
202 memcpy_toio(chip->data_buffer + b_pos, src, b_count); in snd_sh_dac_pcm_copy()
203 chip->buffer_end = chip->data_buffer + b_pos + b_count; in snd_sh_dac_pcm_copy()
205 if (chip->empty) { in snd_sh_dac_pcm_copy()
206 chip->empty = 0; in snd_sh_dac_pcm_copy()
207 dac_audio_start_timer(chip); in snd_sh_dac_pcm_copy()
218 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_silence() local
229 memset_io(chip->data_buffer + b_pos, 0, b_count); in snd_sh_dac_pcm_silence()
230 chip->buffer_end = chip->data_buffer + b_pos + b_count; in snd_sh_dac_pcm_silence()
232 if (chip->empty) { in snd_sh_dac_pcm_silence()
233 chip->empty = 0; in snd_sh_dac_pcm_silence()
234 dac_audio_start_timer(chip); in snd_sh_dac_pcm_silence()
243 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); in snd_sh_dac_pcm_pointer() local
244 int pointer = chip->buffer_begin - chip->data_buffer; in snd_sh_dac_pcm_pointer()
264 static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) in snd_sh_dac_pcm() argument
270 err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); in snd_sh_dac_pcm()
274 pcm->private_data = chip; in snd_sh_dac_pcm()
299 static int snd_sh_dac_free(struct snd_sh_dac *chip) in snd_sh_dac_free() argument
302 kfree(chip->data_buffer); in snd_sh_dac_free()
303 kfree(chip); in snd_sh_dac_free()
310 struct snd_sh_dac *chip = device->device_data; in snd_sh_dac_dev_free() local
312 return snd_sh_dac_free(chip); in snd_sh_dac_dev_free()
317 struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, in sh_dac_audio_timer() local
319 struct snd_pcm_runtime *runtime = chip->substream->runtime; in sh_dac_audio_timer()
322 if (!chip->empty) { in sh_dac_audio_timer()
323 sh_dac_output(*chip->buffer_begin, chip->pdata->channel); in sh_dac_audio_timer()
324 chip->buffer_begin++; in sh_dac_audio_timer()
326 chip->processed++; in sh_dac_audio_timer()
327 if (chip->processed >= b_ps) { in sh_dac_audio_timer()
328 chip->processed -= b_ps; in sh_dac_audio_timer()
329 snd_pcm_period_elapsed(chip->substream); in sh_dac_audio_timer()
332 if (chip->buffer_begin == (chip->data_buffer + in sh_dac_audio_timer()
333 chip->buffer_size - 1)) in sh_dac_audio_timer()
334 chip->buffer_begin = chip->data_buffer; in sh_dac_audio_timer()
336 if (chip->buffer_begin == chip->buffer_end) in sh_dac_audio_timer()
337 chip->empty = 1; in sh_dac_audio_timer()
341 if (!chip->empty) in sh_dac_audio_timer()
342 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, in sh_dac_audio_timer()
353 struct snd_sh_dac *chip; in snd_sh_dac_create() local
362 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_sh_dac_create()
363 if (chip == NULL) in snd_sh_dac_create()
366 chip->card = card; in snd_sh_dac_create()
368 hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in snd_sh_dac_create()
369 chip->hrtimer.function = sh_dac_audio_timer; in snd_sh_dac_create()
371 dac_audio_reset(chip); in snd_sh_dac_create()
372 chip->rate = 8000; in snd_sh_dac_create()
373 dac_audio_set_rate(chip); in snd_sh_dac_create()
375 chip->pdata = devptr->dev.platform_data; in snd_sh_dac_create()
377 chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); in snd_sh_dac_create()
378 if (chip->data_buffer == NULL) { in snd_sh_dac_create()
379 kfree(chip); in snd_sh_dac_create()
383 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_sh_dac_create()
385 snd_sh_dac_free(chip); in snd_sh_dac_create()
389 *rchip = chip; in snd_sh_dac_create()
397 struct snd_sh_dac *chip; in snd_sh_dac_probe() local
407 err = snd_sh_dac_create(card, devptr, &chip); in snd_sh_dac_probe()
411 err = snd_sh_dac_pcm(chip, 0); in snd_sh_dac_probe()