Lines Matching refs:tea
82 static void snd_tea575x_write(struct snd_tea575x *tea, unsigned int val) in snd_tea575x_write() argument
87 if (tea->ops->write_val) in snd_tea575x_write()
88 return tea->ops->write_val(tea, val); in snd_tea575x_write()
90 tea->ops->set_direction(tea, 1); in snd_tea575x_write()
96 tea->ops->set_pins(tea, data | TEA575X_WREN); in snd_tea575x_write()
98 tea->ops->set_pins(tea, data | TEA575X_WREN | TEA575X_CLK); in snd_tea575x_write()
100 tea->ops->set_pins(tea, data | TEA575X_WREN); in snd_tea575x_write()
104 if (!tea->mute) in snd_tea575x_write()
105 tea->ops->set_pins(tea, 0); in snd_tea575x_write()
108 static u32 snd_tea575x_read(struct snd_tea575x *tea) in snd_tea575x_read() argument
113 if (tea->ops->read_val) in snd_tea575x_read()
114 return tea->ops->read_val(tea); in snd_tea575x_read()
116 tea->ops->set_direction(tea, 0); in snd_tea575x_read()
117 tea->ops->set_pins(tea, 0); in snd_tea575x_read()
121 tea->ops->set_pins(tea, TEA575X_CLK); in snd_tea575x_read()
124 tea->tuned = tea->ops->get_pins(tea) & TEA575X_MOST ? 0 : 1; in snd_tea575x_read()
125 tea->ops->set_pins(tea, 0); in snd_tea575x_read()
128 rdata = tea->ops->get_pins(tea); in snd_tea575x_read()
130 tea->stereo = (rdata & TEA575X_MOST) ? 0 : 1; in snd_tea575x_read()
136 if (tea->mute) in snd_tea575x_read()
137 tea->ops->set_pins(tea, TEA575X_WREN); in snd_tea575x_read()
142 static u32 snd_tea575x_val_to_freq(struct snd_tea575x *tea, u32 val) in snd_tea575x_val_to_freq() argument
149 switch (tea->band) { in snd_tea575x_val_to_freq()
170 return clamp(freq * 16, bands[tea->band].rangelow, in snd_tea575x_val_to_freq()
171 bands[tea->band].rangehigh); /* from kHz */ in snd_tea575x_val_to_freq()
174 static u32 snd_tea575x_get_freq(struct snd_tea575x *tea) in snd_tea575x_get_freq() argument
176 return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea)); in snd_tea575x_get_freq()
179 void snd_tea575x_set_freq(struct snd_tea575x *tea) in snd_tea575x_set_freq() argument
181 u32 freq = tea->freq / 16; /* to kHz */ in snd_tea575x_set_freq()
184 switch (tea->band) { in snd_tea575x_set_freq()
208 tea->val &= ~(TEA575X_BIT_FREQ_MASK | TEA575X_BIT_BAND_MASK); in snd_tea575x_set_freq()
209 tea->val |= band; in snd_tea575x_set_freq()
210 tea->val |= freq & TEA575X_BIT_FREQ_MASK; in snd_tea575x_set_freq()
211 snd_tea575x_write(tea, tea->val); in snd_tea575x_set_freq()
212 tea->freq = snd_tea575x_val_to_freq(tea, tea->val); in snd_tea575x_set_freq()
223 struct snd_tea575x *tea = video_drvdata(file); in vidioc_querycap() local
225 strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); in vidioc_querycap()
226 strscpy(v->card, tea->card, sizeof(v->card)); in vidioc_querycap()
227 strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); in vidioc_querycap()
228 strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); in vidioc_querycap()
232 int snd_tea575x_enum_freq_bands(struct snd_tea575x *tea, in snd_tea575x_enum_freq_bands() argument
242 if (tea->tea5759) in snd_tea575x_enum_freq_bands()
248 if (tea->has_am) { in snd_tea575x_enum_freq_bands()
258 if (!tea->cannot_read_data) in snd_tea575x_enum_freq_bands()
268 struct snd_tea575x *tea = video_drvdata(file); in vidioc_enum_freq_bands() local
270 return snd_tea575x_enum_freq_bands(tea, band); in vidioc_enum_freq_bands()
273 int snd_tea575x_g_tuner(struct snd_tea575x *tea, struct v4l2_tuner *v) in snd_tea575x_g_tuner() argument
280 snd_tea575x_read(tea); in snd_tea575x_g_tuner()
281 snd_tea575x_enum_freq_bands(tea, &band_fm); in snd_tea575x_g_tuner()
284 strscpy(v->name, tea->has_am ? "FM/AM" : "FM", sizeof(v->name)); in snd_tea575x_g_tuner()
287 v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : band_fm.rangelow; in snd_tea575x_g_tuner()
289 v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; in snd_tea575x_g_tuner()
290 v->audmode = (tea->val & TEA575X_BIT_MONO) ? in snd_tea575x_g_tuner()
292 v->signal = tea->tuned ? 0xffff : 0; in snd_tea575x_g_tuner()
300 struct snd_tea575x *tea = video_drvdata(file); in vidioc_g_tuner() local
302 return snd_tea575x_g_tuner(tea, v); in vidioc_g_tuner()
308 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_tuner() local
309 u32 orig_val = tea->val; in vidioc_s_tuner()
313 tea->val &= ~TEA575X_BIT_MONO; in vidioc_s_tuner()
315 tea->val |= TEA575X_BIT_MONO; in vidioc_s_tuner()
317 if (tea->band != BAND_AM && tea->val != orig_val) in vidioc_s_tuner()
318 snd_tea575x_set_freq(tea); in vidioc_s_tuner()
326 struct snd_tea575x *tea = video_drvdata(file); in vidioc_g_frequency() local
331 f->frequency = tea->freq; in vidioc_g_frequency()
338 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_frequency() local
343 if (tea->has_am && f->frequency < (20000 * 16)) in vidioc_s_frequency()
344 tea->band = BAND_AM; in vidioc_s_frequency()
345 else if (tea->tea5759) in vidioc_s_frequency()
346 tea->band = BAND_FM_JAPAN; in vidioc_s_frequency()
348 tea->band = BAND_FM; in vidioc_s_frequency()
350 tea->freq = clamp_t(u32, f->frequency, bands[tea->band].rangelow, in vidioc_s_frequency()
351 bands[tea->band].rangehigh); in vidioc_s_frequency()
352 snd_tea575x_set_freq(tea); in vidioc_s_frequency()
356 int snd_tea575x_s_hw_freq_seek(struct file *file, struct snd_tea575x *tea, in snd_tea575x_s_hw_freq_seek() argument
362 if (tea->cannot_read_data) in snd_tea575x_s_hw_freq_seek()
372 if ((i == BAND_FM && tea->tea5759) || in snd_tea575x_s_hw_freq_seek()
373 (i == BAND_FM_JAPAN && !tea->tea5759) || in snd_tea575x_s_hw_freq_seek()
374 (i == BAND_AM && !tea->has_am)) in snd_tea575x_s_hw_freq_seek()
382 if (i != tea->band) { in snd_tea575x_s_hw_freq_seek()
383 tea->band = i; in snd_tea575x_s_hw_freq_seek()
384 tea->freq = clamp(tea->freq, bands[i].rangelow, in snd_tea575x_s_hw_freq_seek()
386 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
390 spacing = (tea->band == BAND_AM) ? 5 : 50; /* kHz */ in snd_tea575x_s_hw_freq_seek()
393 tea->val &= ~TEA575X_BIT_FREQ_MASK; in snd_tea575x_s_hw_freq_seek()
394 tea->val |= TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
396 tea->val |= TEA575X_BIT_UPDOWN; in snd_tea575x_s_hw_freq_seek()
398 tea->val &= ~TEA575X_BIT_UPDOWN; in snd_tea575x_s_hw_freq_seek()
399 snd_tea575x_write(tea, tea->val); in snd_tea575x_s_hw_freq_seek()
406 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
407 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
410 if (!(snd_tea575x_read(tea) & TEA575X_BIT_SEARCH)) { in snd_tea575x_s_hw_freq_seek()
416 freq = snd_tea575x_get_freq(tea); in snd_tea575x_s_hw_freq_seek()
426 if (abs(tea->freq - freq) < 16 * spacing || in snd_tea575x_s_hw_freq_seek()
427 (a->seek_upward && freq < tea->freq) || in snd_tea575x_s_hw_freq_seek()
428 (!a->seek_upward && freq > tea->freq)) { in snd_tea575x_s_hw_freq_seek()
429 snd_tea575x_write(tea, tea->val); in snd_tea575x_s_hw_freq_seek()
432 tea->freq = freq; in snd_tea575x_s_hw_freq_seek()
433 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
437 tea->val &= ~TEA575X_BIT_SEARCH; in snd_tea575x_s_hw_freq_seek()
438 snd_tea575x_set_freq(tea); in snd_tea575x_s_hw_freq_seek()
446 struct snd_tea575x *tea = video_drvdata(file); in vidioc_s_hw_freq_seek() local
448 return snd_tea575x_s_hw_freq_seek(file, tea, a); in vidioc_s_hw_freq_seek()
453 struct snd_tea575x *tea = container_of(ctrl->handler, struct snd_tea575x, ctrl_handler); in tea575x_s_ctrl() local
457 tea->mute = ctrl->val; in tea575x_s_ctrl()
458 snd_tea575x_set_freq(tea); in tea575x_s_ctrl()
495 int snd_tea575x_hw_init(struct snd_tea575x *tea) in snd_tea575x_hw_init() argument
497 tea->mute = true; in snd_tea575x_hw_init()
501 if (!tea->cannot_read_data) { in snd_tea575x_hw_init()
502 snd_tea575x_write(tea, 0x55AA); in snd_tea575x_hw_init()
503 if (snd_tea575x_read(tea) != 0x55AA) in snd_tea575x_hw_init()
507 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_5_28; in snd_tea575x_hw_init()
508 tea->freq = 90500 * 16; /* 90.5Mhz default */ in snd_tea575x_hw_init()
509 snd_tea575x_set_freq(tea); in snd_tea575x_hw_init()
515 int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner) in snd_tea575x_init() argument
517 int retval = snd_tea575x_hw_init(tea); in snd_tea575x_init()
522 tea->vd = tea575x_radio; in snd_tea575x_init()
523 video_set_drvdata(&tea->vd, tea); in snd_tea575x_init()
524 mutex_init(&tea->mutex); in snd_tea575x_init()
525 strscpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); in snd_tea575x_init()
526 tea->vd.lock = &tea->mutex; in snd_tea575x_init()
527 tea->vd.v4l2_dev = tea->v4l2_dev; in snd_tea575x_init()
528 tea->vd.device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; in snd_tea575x_init()
529 if (!tea->cannot_read_data) in snd_tea575x_init()
530 tea->vd.device_caps |= V4L2_CAP_HW_FREQ_SEEK; in snd_tea575x_init()
531 tea->fops = tea575x_fops; in snd_tea575x_init()
532 tea->fops.owner = owner; in snd_tea575x_init()
533 tea->vd.fops = &tea->fops; in snd_tea575x_init()
535 if (tea->cannot_read_data) in snd_tea575x_init()
536 v4l2_disable_ioctl(&tea->vd, VIDIOC_S_HW_FREQ_SEEK); in snd_tea575x_init()
538 if (!tea->cannot_mute) { in snd_tea575x_init()
539 tea->vd.ctrl_handler = &tea->ctrl_handler; in snd_tea575x_init()
540 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); in snd_tea575x_init()
541 v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, in snd_tea575x_init()
543 retval = tea->ctrl_handler.error; in snd_tea575x_init()
545 v4l2_err(tea->v4l2_dev, "can't initialize controls\n"); in snd_tea575x_init()
546 v4l2_ctrl_handler_free(&tea->ctrl_handler); in snd_tea575x_init()
550 if (tea->ext_init) { in snd_tea575x_init()
551 retval = tea->ext_init(tea); in snd_tea575x_init()
553 v4l2_ctrl_handler_free(&tea->ctrl_handler); in snd_tea575x_init()
558 v4l2_ctrl_handler_setup(&tea->ctrl_handler); in snd_tea575x_init()
561 retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->radio_nr); in snd_tea575x_init()
563 v4l2_err(tea->v4l2_dev, "can't register video device!\n"); in snd_tea575x_init()
564 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in snd_tea575x_init()
572 void snd_tea575x_exit(struct snd_tea575x *tea) in snd_tea575x_exit() argument
574 video_unregister_device(&tea->vd); in snd_tea575x_exit()
575 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in snd_tea575x_exit()