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