Lines Matching refs:tea

93 static void snd_tea575x_write(struct snd_tea575x *tea, unsigned int val)  in snd_tea575x_write()  argument
98 if (tea->ops->write_val) in snd_tea575x_write()
99 return tea->ops->write_val(tea, val); in snd_tea575x_write()
101 tea->ops->set_direction(tea, 1); in snd_tea575x_write()
107 tea->ops->set_pins(tea, data | TEA575X_WREN); in snd_tea575x_write()
109 tea->ops->set_pins(tea, data | TEA575X_WREN | TEA575X_CLK); in snd_tea575x_write()
111 tea->ops->set_pins(tea, data | TEA575X_WREN); in snd_tea575x_write()
115 if (!tea->mute) in snd_tea575x_write()
116 tea->ops->set_pins(tea, 0); in snd_tea575x_write()
119 static u32 snd_tea575x_read(struct snd_tea575x *tea) in snd_tea575x_read() argument
124 if (tea->ops->read_val) in snd_tea575x_read()
125 return tea->ops->read_val(tea); in snd_tea575x_read()
127 tea->ops->set_direction(tea, 0); in snd_tea575x_read()
128 tea->ops->set_pins(tea, 0); in snd_tea575x_read()
132 tea->ops->set_pins(tea, TEA575X_CLK); in snd_tea575x_read()
135 tea->tuned = tea->ops->get_pins(tea) & TEA575X_MOST ? 0 : 1; in snd_tea575x_read()
136 tea->ops->set_pins(tea, 0); in snd_tea575x_read()
139 rdata = tea->ops->get_pins(tea); in snd_tea575x_read()
141 tea->stereo = (rdata & TEA575X_MOST) ? 0 : 1; in snd_tea575x_read()
147 if (tea->mute) in snd_tea575x_read()
148 tea->ops->set_pins(tea, TEA575X_WREN); in snd_tea575x_read()
153 static u32 snd_tea575x_val_to_freq(struct snd_tea575x *tea, u32 val) in snd_tea575x_val_to_freq() argument
160 switch (tea->band) { in snd_tea575x_val_to_freq()
181 return clamp(freq * 16, bands[tea->band].rangelow, in snd_tea575x_val_to_freq()
182 bands[tea->band].rangehigh); /* from kHz */ in snd_tea575x_val_to_freq()
185 static u32 snd_tea575x_get_freq(struct snd_tea575x *tea) in snd_tea575x_get_freq() argument
187 return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea)); in snd_tea575x_get_freq()
190 void snd_tea575x_set_freq(struct snd_tea575x *tea) in snd_tea575x_set_freq() argument
192 u32 freq = tea->freq / 16; /* to kHz */ in snd_tea575x_set_freq()
195 switch (tea->band) { in snd_tea575x_set_freq()
219 tea->val &= ~(TEA575X_BIT_FREQ_MASK | TEA575X_BIT_BAND_MASK); in snd_tea575x_set_freq()
220 tea->val |= band; in snd_tea575x_set_freq()
221 tea->val |= freq & TEA575X_BIT_FREQ_MASK; in snd_tea575x_set_freq()
222 snd_tea575x_write(tea, tea->val); in snd_tea575x_set_freq()
223 tea->freq = snd_tea575x_val_to_freq(tea, tea->val); in snd_tea575x_set_freq()
234 struct snd_tea575x *tea = video_drvdata(file); in vidioc_querycap() local
236 strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); in vidioc_querycap()
237 strlcpy(v->card, tea->card, sizeof(v->card)); in vidioc_querycap()
238 strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); in vidioc_querycap()
239 strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); in vidioc_querycap()
241 if (!tea->cannot_read_data) in vidioc_querycap()
247 int snd_tea575x_enum_freq_bands(struct snd_tea575x *tea, in snd_tea575x_enum_freq_bands() argument
257 if (tea->tea5759) in snd_tea575x_enum_freq_bands()
263 if (tea->has_am) { in snd_tea575x_enum_freq_bands()
273 if (!tea->cannot_read_data) in snd_tea575x_enum_freq_bands()
283 struct snd_tea575x *tea = video_drvdata(file); in vidioc_enum_freq_bands() local
285 return snd_tea575x_enum_freq_bands(tea, band); in vidioc_enum_freq_bands()
288 int snd_tea575x_g_tuner(struct snd_tea575x *tea, struct v4l2_tuner *v) in snd_tea575x_g_tuner() argument
295 snd_tea575x_read(tea); in snd_tea575x_g_tuner()
296 snd_tea575x_enum_freq_bands(tea, &band_fm); in snd_tea575x_g_tuner()
299 strlcpy(v->name, tea->has_am ? "FM/AM" : "FM", sizeof(v->name)); in snd_tea575x_g_tuner()
302 v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : band_fm.rangelow; in snd_tea575x_g_tuner()
304 v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; in snd_tea575x_g_tuner()
305 v->audmode = (tea->val & TEA575X_BIT_MONO) ? in snd_tea575x_g_tuner()
307 v->signal = tea->tuned ? 0xffff : 0; in snd_tea575x_g_tuner()
315 struct snd_tea575x *tea = video_drvdata(file); in vidioc_g_tuner() local
317 return snd_tea575x_g_tuner(tea, v); in vidioc_g_tuner()
323 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_tuner() local
324 u32 orig_val = tea->val; in vidioc_s_tuner()
328 tea->val &= ~TEA575X_BIT_MONO; in vidioc_s_tuner()
330 tea->val |= TEA575X_BIT_MONO; in vidioc_s_tuner()
332 if (tea->band != BAND_AM && tea->val != orig_val) in vidioc_s_tuner()
333 snd_tea575x_set_freq(tea); in vidioc_s_tuner()
341 struct snd_tea575x *tea = video_drvdata(file); in vidioc_g_frequency() local
346 f->frequency = tea->freq; in vidioc_g_frequency()
353 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_frequency() local
358 if (tea->has_am && f->frequency < (20000 * 16)) in vidioc_s_frequency()
359 tea->band = BAND_AM; in vidioc_s_frequency()
360 else if (tea->tea5759) in vidioc_s_frequency()
361 tea->band = BAND_FM_JAPAN; in vidioc_s_frequency()
363 tea->band = BAND_FM; in vidioc_s_frequency()
365 tea->freq = clamp_t(u32, f->frequency, bands[tea->band].rangelow, in vidioc_s_frequency()
366 bands[tea->band].rangehigh); in vidioc_s_frequency()
367 snd_tea575x_set_freq(tea); in vidioc_s_frequency()
371 int snd_tea575x_s_hw_freq_seek(struct file *file, struct snd_tea575x *tea, in snd_tea575x_s_hw_freq_seek() argument
377 if (tea->cannot_read_data) in snd_tea575x_s_hw_freq_seek()
387 if ((i == BAND_FM && tea->tea5759) || in snd_tea575x_s_hw_freq_seek()
388 (i == BAND_FM_JAPAN && !tea->tea5759) || in snd_tea575x_s_hw_freq_seek()
389 (i == BAND_AM && !tea->has_am)) in snd_tea575x_s_hw_freq_seek()
397 if (i != tea->band) { in snd_tea575x_s_hw_freq_seek()
398 tea->band = i; in snd_tea575x_s_hw_freq_seek()
399 tea->freq = clamp(tea->freq, bands[i].rangelow, in snd_tea575x_s_hw_freq_seek()
401 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
405 spacing = (tea->band == BAND_AM) ? 5 : 50; /* kHz */ in snd_tea575x_s_hw_freq_seek()
408 tea->val &= ~TEA575X_BIT_FREQ_MASK; in snd_tea575x_s_hw_freq_seek()
409 tea->val |= TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
411 tea->val |= TEA575X_BIT_UPDOWN; in snd_tea575x_s_hw_freq_seek()
413 tea->val &= ~TEA575X_BIT_UPDOWN; in snd_tea575x_s_hw_freq_seek()
414 snd_tea575x_write(tea, tea->val); in snd_tea575x_s_hw_freq_seek()
421 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
422 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
425 if (!(snd_tea575x_read(tea) & TEA575X_BIT_SEARCH)) { in snd_tea575x_s_hw_freq_seek()
431 freq = snd_tea575x_get_freq(tea); in snd_tea575x_s_hw_freq_seek()
441 if (abs(tea->freq - freq) < 16 * spacing || in snd_tea575x_s_hw_freq_seek()
442 (a->seek_upward && freq < tea->freq) || in snd_tea575x_s_hw_freq_seek()
443 (!a->seek_upward && freq > tea->freq)) { in snd_tea575x_s_hw_freq_seek()
444 snd_tea575x_write(tea, tea->val); in snd_tea575x_s_hw_freq_seek()
447 tea->freq = freq; in snd_tea575x_s_hw_freq_seek()
448 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
452 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
453 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
461 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_hw_freq_seek() local
463 return snd_tea575x_s_hw_freq_seek(file, tea, a); in vidioc_s_hw_freq_seek()
468 struct snd_tea575x *tea = container_of(ctrl->handler, struct snd_tea575x, ctrl_handler); in tea575x_s_ctrl() local
472 tea->mute = ctrl->val; in tea575x_s_ctrl()
473 snd_tea575x_set_freq(tea); in tea575x_s_ctrl()
510 int snd_tea575x_hw_init(struct snd_tea575x *tea) in snd_tea575x_hw_init() argument
512 tea->mute = true; in snd_tea575x_hw_init()
516 if (!tea->cannot_read_data) { in snd_tea575x_hw_init()
517 snd_tea575x_write(tea, 0x55AA); in snd_tea575x_hw_init()
518 if (snd_tea575x_read(tea) != 0x55AA) in snd_tea575x_hw_init()
522 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_5_28; in snd_tea575x_hw_init()
523 tea->freq = 90500 * 16; /* 90.5Mhz default */ in snd_tea575x_hw_init()
524 snd_tea575x_set_freq(tea); in snd_tea575x_hw_init()
530 int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner) in snd_tea575x_init() argument
532 int retval = snd_tea575x_hw_init(tea); in snd_tea575x_init()
537 tea->vd = tea575x_radio; in snd_tea575x_init()
538 video_set_drvdata(&tea->vd, tea); in snd_tea575x_init()
539 mutex_init(&tea->mutex); in snd_tea575x_init()
540 strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); in snd_tea575x_init()
541 tea->vd.lock = &tea->mutex; in snd_tea575x_init()
542 tea->vd.v4l2_dev = tea->v4l2_dev; in snd_tea575x_init()
543 tea->fops = tea575x_fops; in snd_tea575x_init()
544 tea->fops.owner = owner; in snd_tea575x_init()
545 tea->vd.fops = &tea->fops; in snd_tea575x_init()
547 if (tea->cannot_read_data) in snd_tea575x_init()
548 v4l2_disable_ioctl(&tea->vd, VIDIOC_S_HW_FREQ_SEEK); in snd_tea575x_init()
550 if (!tea->cannot_mute) { in snd_tea575x_init()
551 tea->vd.ctrl_handler = &tea->ctrl_handler; in snd_tea575x_init()
552 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); in snd_tea575x_init()
553 v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, in snd_tea575x_init()
555 retval = tea->ctrl_handler.error; in snd_tea575x_init()
557 v4l2_err(tea->v4l2_dev, "can't initialize controls\n"); in snd_tea575x_init()
558 v4l2_ctrl_handler_free(&tea->ctrl_handler); in snd_tea575x_init()
562 if (tea->ext_init) { in snd_tea575x_init()
563 retval = tea->ext_init(tea); in snd_tea575x_init()
565 v4l2_ctrl_handler_free(&tea->ctrl_handler); in snd_tea575x_init()
570 v4l2_ctrl_handler_setup(&tea->ctrl_handler); in snd_tea575x_init()
573 retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->radio_nr); in snd_tea575x_init()
575 v4l2_err(tea->v4l2_dev, "can't register video device!\n"); in snd_tea575x_init()
576 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in snd_tea575x_init()
584 void snd_tea575x_exit(struct snd_tea575x *tea) in snd_tea575x_exit() argument
586 video_unregister_device(&tea->vd); in snd_tea575x_exit()
587 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in snd_tea575x_exit()