Lines Matching refs:chip
53 static void dac_audio_start_timer(struct snd_sh_dac *chip)
55 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second,
59 static void dac_audio_stop_timer(struct snd_sh_dac *chip)
61 hrtimer_cancel(&chip->hrtimer);
64 static void dac_audio_reset(struct snd_sh_dac *chip)
66 dac_audio_stop_timer(chip);
67 chip->buffer_begin = chip->buffer_end = chip->data_buffer;
68 chip->processed = 0;
69 chip->empty = 1;
72 static void dac_audio_set_rate(struct snd_sh_dac *chip)
74 chip->wakeups_per_second = 1000000000 / chip->rate;
100 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
105 chip->substream = substream;
106 chip->buffer_begin = chip->buffer_end = chip->data_buffer;
107 chip->processed = 0;
108 chip->empty = 1;
110 chip->pdata->start(chip->pdata);
117 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
119 chip->substream = NULL;
121 dac_audio_stop_timer(chip);
122 chip->pdata->stop(chip->pdata);
129 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
130 struct snd_pcm_runtime *runtime = chip->substream->runtime;
132 chip->buffer_size = runtime->buffer_size;
133 memset(chip->data_buffer, 0, chip->pdata->buffer_size);
140 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
144 dac_audio_start_timer(chip);
147 chip->buffer_begin = chip->buffer_end = chip->data_buffer;
148 chip->processed = 0;
149 chip->empty = 1;
150 dac_audio_stop_timer(chip);
164 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
166 if (copy_from_iter_toio(chip->data_buffer + pos, src, count))
168 chip->buffer_end = chip->data_buffer + pos + count;
170 if (chip->empty) {
171 chip->empty = 0;
172 dac_audio_start_timer(chip);
183 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
185 memset_io(chip->data_buffer + pos, 0, count);
186 chip->buffer_end = chip->data_buffer + pos + count;
188 if (chip->empty) {
189 chip->empty = 0;
190 dac_audio_start_timer(chip);
199 struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
200 int pointer = chip->buffer_begin - chip->data_buffer;
217 static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device)
223 err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm);
227 pcm->private_data = chip;
247 static int snd_sh_dac_free(struct snd_sh_dac *chip)
250 kfree(chip->data_buffer);
251 kfree(chip);
258 struct snd_sh_dac *chip = device->device_data;
260 return snd_sh_dac_free(chip);
265 struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac,
267 struct snd_pcm_runtime *runtime = chip->substream->runtime;
270 if (!chip->empty) {
271 sh_dac_output(*chip->buffer_begin, chip->pdata->channel);
272 chip->buffer_begin++;
274 chip->processed++;
275 if (chip->processed >= b_ps) {
276 chip->processed -= b_ps;
277 snd_pcm_period_elapsed(chip->substream);
280 if (chip->buffer_begin == (chip->data_buffer +
281 chip->buffer_size - 1))
282 chip->buffer_begin = chip->data_buffer;
284 if (chip->buffer_begin == chip->buffer_end)
285 chip->empty = 1;
289 if (!chip->empty)
290 hrtimer_start(&chip->hrtimer, chip->wakeups_per_second,
296 /* create -- chip-specific constructor for the cards components */
301 struct snd_sh_dac *chip;
310 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
311 if (chip == NULL)
314 chip->card = card;
316 hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
317 chip->hrtimer.function = sh_dac_audio_timer;
319 dac_audio_reset(chip);
320 chip->rate = 8000;
321 dac_audio_set_rate(chip);
323 chip->pdata = devptr->dev.platform_data;
325 chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL);
326 if (chip->data_buffer == NULL) {
327 kfree(chip);
331 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
333 snd_sh_dac_free(chip);
337 *rchip = chip;
345 struct snd_sh_dac *chip;
355 err = snd_sh_dac_create(card, devptr, &chip);
359 err = snd_sh_dac_pcm(chip, 0);