Lines Matching refs:tea

162 static u32 tea5777_freq_to_v4l2_freq(struct radio_tea5777 *tea, u32 freq)  in tea5777_freq_to_v4l2_freq()  argument
164 switch (tea->band) { in tea5777_freq_to_v4l2_freq()
173 int radio_tea5777_set_freq(struct radio_tea5777 *tea) in radio_tea5777_set_freq() argument
178 freq = clamp(tea->freq, bands[tea->band].rangelow, in radio_tea5777_set_freq()
179 bands[tea->band].rangehigh); in radio_tea5777_set_freq()
182 switch (tea->band) { in radio_tea5777_set_freq()
184 tea->write_reg &= ~TEA5777_W_AM_FM_MASK; in radio_tea5777_set_freq()
186 tea->write_reg &= ~TEA5777_W_FM_PLL_MASK; in radio_tea5777_set_freq()
187 tea->write_reg |= (u64)freq << TEA5777_W_FM_PLL_SHIFT; in radio_tea5777_set_freq()
188 tea->write_reg &= ~TEA5777_W_FM_FREF_MASK; in radio_tea5777_set_freq()
189 tea->write_reg |= TEA5777_W_FM_FREF_VALUE << in radio_tea5777_set_freq()
191 tea->write_reg &= ~TEA5777_W_FM_FORCEMONO_MASK; in radio_tea5777_set_freq()
192 if (tea->audmode == V4L2_TUNER_MODE_MONO) in radio_tea5777_set_freq()
193 tea->write_reg |= 1LL << TEA5777_W_FM_FORCEMONO_SHIFT; in radio_tea5777_set_freq()
196 tea->write_reg &= ~TEA5777_W_AM_FM_MASK; in radio_tea5777_set_freq()
197 tea->write_reg |= (1LL << TEA5777_W_AM_FM_SHIFT); in radio_tea5777_set_freq()
199 tea->write_reg &= ~TEA5777_W_AM_PLL_MASK; in radio_tea5777_set_freq()
200 tea->write_reg |= (u64)freq << TEA5777_W_AM_PLL_SHIFT; in radio_tea5777_set_freq()
201 tea->write_reg &= ~TEA5777_W_AM_AGCRF_MASK; in radio_tea5777_set_freq()
202 tea->write_reg &= ~TEA5777_W_AM_AGCRF_MASK; in radio_tea5777_set_freq()
203 tea->write_reg &= ~TEA5777_W_AM_MWLW_MASK; in radio_tea5777_set_freq()
204 tea->write_reg |= TEA5777_W_AM_MW << TEA5777_W_AM_MWLW_SHIFT; in radio_tea5777_set_freq()
205 tea->write_reg &= ~TEA5777_W_AM_LNA_MASK; in radio_tea5777_set_freq()
206 tea->write_reg |= 1LL << TEA5777_W_AM_LNA_SHIFT; in radio_tea5777_set_freq()
207 tea->write_reg &= ~TEA5777_W_AM_PEAK_MASK; in radio_tea5777_set_freq()
208 tea->write_reg |= 1LL << TEA5777_W_AM_PEAK_SHIFT; in radio_tea5777_set_freq()
209 tea->write_reg &= ~TEA5777_W_AM_CALLIGN_MASK; in radio_tea5777_set_freq()
213 res = tea->ops->write_reg(tea, tea->write_reg); in radio_tea5777_set_freq()
217 tea->needs_write = false; in radio_tea5777_set_freq()
218 tea->read_reg = -1; in radio_tea5777_set_freq()
219 tea->freq = tea5777_freq_to_v4l2_freq(tea, freq); in radio_tea5777_set_freq()
224 static int radio_tea5777_update_read_reg(struct radio_tea5777 *tea, int wait) in radio_tea5777_update_read_reg() argument
228 if (tea->read_reg != -1) in radio_tea5777_update_read_reg()
231 if (tea->write_before_read && tea->needs_write) { in radio_tea5777_update_read_reg()
232 res = radio_tea5777_set_freq(tea); in radio_tea5777_update_read_reg()
242 res = tea->ops->read_reg(tea, &tea->read_reg); in radio_tea5777_update_read_reg()
246 tea->needs_write = true; in radio_tea5777_update_read_reg()
257 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_querycap() local
259 strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); in vidioc_querycap()
260 strscpy(v->card, tea->card, sizeof(v->card)); in vidioc_querycap()
262 strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); in vidioc_querycap()
269 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_enum_freq_bands() local
272 (!tea->has_am && band->index == BAND_AM)) in vidioc_enum_freq_bands()
282 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_g_tuner() local
288 res = radio_tea5777_update_read_reg(tea, 0); in vidioc_g_tuner()
293 if (tea->has_am) in vidioc_g_tuner()
302 v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : in vidioc_g_tuner()
305 if (tea->band == BAND_FM && in vidioc_g_tuner()
306 (tea->read_reg & TEA5777_R_FM_STEREO_MASK)) in vidioc_g_tuner()
310 v->audmode = tea->audmode; in vidioc_g_tuner()
312 v->signal = (tea->read_reg & TEA5777_R_LEVEL_MASK) >> in vidioc_g_tuner()
316 tea->read_reg = -1; in vidioc_g_tuner()
324 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_tuner() local
325 u32 orig_audmode = tea->audmode; in vidioc_s_tuner()
330 tea->audmode = v->audmode; in vidioc_s_tuner()
331 if (tea->audmode > V4L2_TUNER_MODE_STEREO) in vidioc_s_tuner()
332 tea->audmode = V4L2_TUNER_MODE_STEREO; in vidioc_s_tuner()
334 if (tea->audmode != orig_audmode && tea->band == BAND_FM) in vidioc_s_tuner()
335 return radio_tea5777_set_freq(tea); in vidioc_s_tuner()
343 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_g_frequency() local
348 f->frequency = tea->freq; in vidioc_g_frequency()
355 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_frequency() local
360 if (tea->has_am && f->frequency < (20000 * 16)) in vidioc_s_frequency()
361 tea->band = BAND_AM; in vidioc_s_frequency()
363 tea->band = BAND_FM; in vidioc_s_frequency()
365 tea->freq = f->frequency; in vidioc_s_frequency()
366 return radio_tea5777_set_freq(tea); in vidioc_s_frequency()
372 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_hw_freq_seek() local
387 if (i == BAND_AM && !tea->has_am) in vidioc_s_hw_freq_seek()
396 tea->band = i; in vidioc_s_hw_freq_seek()
397 if (tea->freq < rangelow || tea->freq > rangehigh) { in vidioc_s_hw_freq_seek()
398 tea->freq = clamp(tea->freq, rangelow, in vidioc_s_hw_freq_seek()
400 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
405 rangelow = bands[tea->band].rangelow; in vidioc_s_hw_freq_seek()
406 rangehigh = bands[tea->band].rangehigh; in vidioc_s_hw_freq_seek()
409 spacing = (tea->band == BAND_AM) ? (5 * 16) : (200 * 16); /* kHz */ in vidioc_s_hw_freq_seek()
410 orig_freq = tea->freq; in vidioc_s_hw_freq_seek()
412 tea->write_reg |= TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
413 if (tea->seek_rangelow != rangelow) { in vidioc_s_hw_freq_seek()
414 tea->write_reg &= ~TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
415 tea->freq = rangelow; in vidioc_s_hw_freq_seek()
416 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
419 tea->seek_rangelow = rangelow; in vidioc_s_hw_freq_seek()
421 if (tea->seek_rangehigh != rangehigh) { in vidioc_s_hw_freq_seek()
422 tea->write_reg |= TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
423 tea->freq = rangehigh; in vidioc_s_hw_freq_seek()
424 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
427 tea->seek_rangehigh = rangehigh; in vidioc_s_hw_freq_seek()
429 tea->write_reg &= ~TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
431 tea->write_reg |= TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
433 tea->write_reg |= TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
434 tea->freq = orig_freq + spacing; in vidioc_s_hw_freq_seek()
436 tea->write_reg &= ~TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
437 tea->freq = orig_freq - spacing; in vidioc_s_hw_freq_seek()
439 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
450 res = radio_tea5777_update_read_reg(tea, 100); in vidioc_s_hw_freq_seek()
459 tea->freq = (tea->read_reg & TEA5777_R_FM_PLL_MASK); in vidioc_s_hw_freq_seek()
460 tea->freq = tea5777_freq_to_v4l2_freq(tea, tea->freq); in vidioc_s_hw_freq_seek()
462 if ((tea->read_reg & TEA5777_R_SFOUND_MASK)) { in vidioc_s_hw_freq_seek()
463 tea->write_reg &= ~TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
467 if (tea->read_reg & TEA5777_R_BLIM_MASK) { in vidioc_s_hw_freq_seek()
473 tea->read_reg = -1; in vidioc_s_hw_freq_seek()
476 tea->write_reg &= ~TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
477 tea->write_reg &= ~TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
478 tea->freq = orig_freq; in vidioc_s_hw_freq_seek()
479 radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
485 struct radio_tea5777 *tea = in tea575x_s_ctrl() local
491 tea->write_reg |= TEA5777_W_MUTE_MASK; in tea575x_s_ctrl()
493 tea->write_reg &= ~TEA5777_W_MUTE_MASK; in tea575x_s_ctrl()
495 return radio_tea5777_set_freq(tea); in tea575x_s_ctrl()
530 int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner) in radio_tea5777_init() argument
534 tea->write_reg = (1LL << TEA5777_W_IFCE_SHIFT) | in radio_tea5777_init()
539 tea->freq = 90500 * 16; /* 90.5Mhz default */ in radio_tea5777_init()
540 tea->audmode = V4L2_TUNER_MODE_STEREO; in radio_tea5777_init()
541 res = radio_tea5777_set_freq(tea); in radio_tea5777_init()
543 v4l2_err(tea->v4l2_dev, "can't set initial freq (%d)\n", res); in radio_tea5777_init()
547 tea->vd = tea575x_radio; in radio_tea5777_init()
548 video_set_drvdata(&tea->vd, tea); in radio_tea5777_init()
549 mutex_init(&tea->mutex); in radio_tea5777_init()
550 strscpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); in radio_tea5777_init()
551 tea->vd.lock = &tea->mutex; in radio_tea5777_init()
552 tea->vd.v4l2_dev = tea->v4l2_dev; in radio_tea5777_init()
553 tea->vd.device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO | in radio_tea5777_init()
555 tea->fops = tea575x_fops; in radio_tea5777_init()
556 tea->fops.owner = owner; in radio_tea5777_init()
557 tea->vd.fops = &tea->fops; in radio_tea5777_init()
559 tea->vd.ctrl_handler = &tea->ctrl_handler; in radio_tea5777_init()
560 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); in radio_tea5777_init()
561 v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, in radio_tea5777_init()
563 res = tea->ctrl_handler.error; in radio_tea5777_init()
565 v4l2_err(tea->v4l2_dev, "can't initialize controls\n"); in radio_tea5777_init()
566 v4l2_ctrl_handler_free(&tea->ctrl_handler); in radio_tea5777_init()
569 v4l2_ctrl_handler_setup(&tea->ctrl_handler); in radio_tea5777_init()
571 res = video_register_device(&tea->vd, VFL_TYPE_RADIO, -1); in radio_tea5777_init()
573 v4l2_err(tea->v4l2_dev, "can't register video device!\n"); in radio_tea5777_init()
574 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in radio_tea5777_init()
582 void radio_tea5777_exit(struct radio_tea5777 *tea) in radio_tea5777_exit() argument
584 video_unregister_device(&tea->vd); in radio_tea5777_exit()
585 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in radio_tea5777_exit()