Lines Matching refs:tea

172 static u32 tea5777_freq_to_v4l2_freq(struct radio_tea5777 *tea, u32 freq)  in tea5777_freq_to_v4l2_freq()  argument
174 switch (tea->band) { in tea5777_freq_to_v4l2_freq()
183 int radio_tea5777_set_freq(struct radio_tea5777 *tea) in radio_tea5777_set_freq() argument
188 freq = clamp(tea->freq, bands[tea->band].rangelow, in radio_tea5777_set_freq()
189 bands[tea->band].rangehigh); in radio_tea5777_set_freq()
192 switch (tea->band) { in radio_tea5777_set_freq()
194 tea->write_reg &= ~TEA5777_W_AM_FM_MASK; in radio_tea5777_set_freq()
196 tea->write_reg &= ~TEA5777_W_FM_PLL_MASK; in radio_tea5777_set_freq()
197 tea->write_reg |= (u64)freq << TEA5777_W_FM_PLL_SHIFT; in radio_tea5777_set_freq()
198 tea->write_reg &= ~TEA5777_W_FM_FREF_MASK; in radio_tea5777_set_freq()
199 tea->write_reg |= TEA5777_W_FM_FREF_VALUE << in radio_tea5777_set_freq()
201 tea->write_reg &= ~TEA5777_W_FM_FORCEMONO_MASK; in radio_tea5777_set_freq()
202 if (tea->audmode == V4L2_TUNER_MODE_MONO) in radio_tea5777_set_freq()
203 tea->write_reg |= 1LL << TEA5777_W_FM_FORCEMONO_SHIFT; in radio_tea5777_set_freq()
206 tea->write_reg &= ~TEA5777_W_AM_FM_MASK; in radio_tea5777_set_freq()
207 tea->write_reg |= (1LL << TEA5777_W_AM_FM_SHIFT); in radio_tea5777_set_freq()
209 tea->write_reg &= ~TEA5777_W_AM_PLL_MASK; in radio_tea5777_set_freq()
210 tea->write_reg |= (u64)freq << TEA5777_W_AM_PLL_SHIFT; in radio_tea5777_set_freq()
211 tea->write_reg &= ~TEA5777_W_AM_AGCRF_MASK; in radio_tea5777_set_freq()
212 tea->write_reg &= ~TEA5777_W_AM_AGCRF_MASK; in radio_tea5777_set_freq()
213 tea->write_reg &= ~TEA5777_W_AM_MWLW_MASK; in radio_tea5777_set_freq()
214 tea->write_reg |= TEA5777_W_AM_MW << TEA5777_W_AM_MWLW_SHIFT; in radio_tea5777_set_freq()
215 tea->write_reg &= ~TEA5777_W_AM_LNA_MASK; in radio_tea5777_set_freq()
216 tea->write_reg |= 1LL << TEA5777_W_AM_LNA_SHIFT; in radio_tea5777_set_freq()
217 tea->write_reg &= ~TEA5777_W_AM_PEAK_MASK; in radio_tea5777_set_freq()
218 tea->write_reg |= 1LL << TEA5777_W_AM_PEAK_SHIFT; in radio_tea5777_set_freq()
219 tea->write_reg &= ~TEA5777_W_AM_CALLIGN_MASK; in radio_tea5777_set_freq()
223 res = tea->ops->write_reg(tea, tea->write_reg); in radio_tea5777_set_freq()
227 tea->needs_write = false; in radio_tea5777_set_freq()
228 tea->read_reg = -1; in radio_tea5777_set_freq()
229 tea->freq = tea5777_freq_to_v4l2_freq(tea, freq); in radio_tea5777_set_freq()
234 static int radio_tea5777_update_read_reg(struct radio_tea5777 *tea, int wait) in radio_tea5777_update_read_reg() argument
238 if (tea->read_reg != -1) in radio_tea5777_update_read_reg()
241 if (tea->write_before_read && tea->needs_write) { in radio_tea5777_update_read_reg()
242 res = radio_tea5777_set_freq(tea); in radio_tea5777_update_read_reg()
252 res = tea->ops->read_reg(tea, &tea->read_reg); in radio_tea5777_update_read_reg()
256 tea->needs_write = true; in radio_tea5777_update_read_reg()
267 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_querycap() local
269 strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); in vidioc_querycap()
270 strlcpy(v->card, tea->card, sizeof(v->card)); in vidioc_querycap()
272 strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); in vidioc_querycap()
282 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_enum_freq_bands() local
285 (!tea->has_am && band->index == BAND_AM)) in vidioc_enum_freq_bands()
295 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_g_tuner() local
301 res = radio_tea5777_update_read_reg(tea, 0); in vidioc_g_tuner()
306 if (tea->has_am) in vidioc_g_tuner()
315 v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : in vidioc_g_tuner()
318 if (tea->band == BAND_FM && in vidioc_g_tuner()
319 (tea->read_reg & TEA5777_R_FM_STEREO_MASK)) in vidioc_g_tuner()
323 v->audmode = tea->audmode; in vidioc_g_tuner()
325 v->signal = (tea->read_reg & TEA5777_R_LEVEL_MASK) >> in vidioc_g_tuner()
329 tea->read_reg = -1; in vidioc_g_tuner()
337 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_tuner() local
338 u32 orig_audmode = tea->audmode; in vidioc_s_tuner()
343 tea->audmode = v->audmode; in vidioc_s_tuner()
344 if (tea->audmode > V4L2_TUNER_MODE_STEREO) in vidioc_s_tuner()
345 tea->audmode = V4L2_TUNER_MODE_STEREO; in vidioc_s_tuner()
347 if (tea->audmode != orig_audmode && tea->band == BAND_FM) in vidioc_s_tuner()
348 return radio_tea5777_set_freq(tea); in vidioc_s_tuner()
356 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_g_frequency() local
361 f->frequency = tea->freq; in vidioc_g_frequency()
368 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_frequency() local
373 if (tea->has_am && f->frequency < (20000 * 16)) in vidioc_s_frequency()
374 tea->band = BAND_AM; in vidioc_s_frequency()
376 tea->band = BAND_FM; in vidioc_s_frequency()
378 tea->freq = f->frequency; in vidioc_s_frequency()
379 return radio_tea5777_set_freq(tea); in vidioc_s_frequency()
385 struct radio_tea5777 *tea = video_drvdata(file); in vidioc_s_hw_freq_seek() local
400 if (i == BAND_AM && !tea->has_am) in vidioc_s_hw_freq_seek()
409 tea->band = i; in vidioc_s_hw_freq_seek()
410 if (tea->freq < rangelow || tea->freq > rangehigh) { in vidioc_s_hw_freq_seek()
411 tea->freq = clamp(tea->freq, rangelow, in vidioc_s_hw_freq_seek()
413 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
418 rangelow = bands[tea->band].rangelow; in vidioc_s_hw_freq_seek()
419 rangehigh = bands[tea->band].rangehigh; in vidioc_s_hw_freq_seek()
422 spacing = (tea->band == BAND_AM) ? (5 * 16) : (200 * 16); /* kHz */ in vidioc_s_hw_freq_seek()
423 orig_freq = tea->freq; in vidioc_s_hw_freq_seek()
425 tea->write_reg |= TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
426 if (tea->seek_rangelow != rangelow) { in vidioc_s_hw_freq_seek()
427 tea->write_reg &= ~TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
428 tea->freq = rangelow; in vidioc_s_hw_freq_seek()
429 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
432 tea->seek_rangelow = rangelow; in vidioc_s_hw_freq_seek()
434 if (tea->seek_rangehigh != rangehigh) { in vidioc_s_hw_freq_seek()
435 tea->write_reg |= TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
436 tea->freq = rangehigh; in vidioc_s_hw_freq_seek()
437 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
440 tea->seek_rangehigh = rangehigh; in vidioc_s_hw_freq_seek()
442 tea->write_reg &= ~TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
444 tea->write_reg |= TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
446 tea->write_reg |= TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
447 tea->freq = orig_freq + spacing; in vidioc_s_hw_freq_seek()
449 tea->write_reg &= ~TEA5777_W_UPDWN_MASK; in vidioc_s_hw_freq_seek()
450 tea->freq = orig_freq - spacing; in vidioc_s_hw_freq_seek()
452 res = radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
463 res = radio_tea5777_update_read_reg(tea, 100); in vidioc_s_hw_freq_seek()
472 tea->freq = (tea->read_reg & TEA5777_R_FM_PLL_MASK); in vidioc_s_hw_freq_seek()
473 tea->freq = tea5777_freq_to_v4l2_freq(tea, tea->freq); in vidioc_s_hw_freq_seek()
475 if ((tea->read_reg & TEA5777_R_SFOUND_MASK)) { in vidioc_s_hw_freq_seek()
476 tea->write_reg &= ~TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
480 if (tea->read_reg & TEA5777_R_BLIM_MASK) { in vidioc_s_hw_freq_seek()
486 tea->read_reg = -1; in vidioc_s_hw_freq_seek()
489 tea->write_reg &= ~TEA5777_W_PROGBLIM_MASK; in vidioc_s_hw_freq_seek()
490 tea->write_reg &= ~TEA5777_W_SEARCH_MASK; in vidioc_s_hw_freq_seek()
491 tea->freq = orig_freq; in vidioc_s_hw_freq_seek()
492 radio_tea5777_set_freq(tea); in vidioc_s_hw_freq_seek()
498 struct radio_tea5777 *tea = in tea575x_s_ctrl() local
504 tea->write_reg |= TEA5777_W_MUTE_MASK; in tea575x_s_ctrl()
506 tea->write_reg &= ~TEA5777_W_MUTE_MASK; in tea575x_s_ctrl()
508 return radio_tea5777_set_freq(tea); in tea575x_s_ctrl()
543 int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner) in radio_tea5777_init() argument
547 tea->write_reg = (1LL << TEA5777_W_IFCE_SHIFT) | in radio_tea5777_init()
552 tea->freq = 90500 * 16; /* 90.5Mhz default */ in radio_tea5777_init()
553 tea->audmode = V4L2_TUNER_MODE_STEREO; in radio_tea5777_init()
554 res = radio_tea5777_set_freq(tea); in radio_tea5777_init()
556 v4l2_err(tea->v4l2_dev, "can't set initial freq (%d)\n", res); in radio_tea5777_init()
560 tea->vd = tea575x_radio; in radio_tea5777_init()
561 video_set_drvdata(&tea->vd, tea); in radio_tea5777_init()
562 mutex_init(&tea->mutex); in radio_tea5777_init()
563 strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); in radio_tea5777_init()
564 tea->vd.lock = &tea->mutex; in radio_tea5777_init()
565 tea->vd.v4l2_dev = tea->v4l2_dev; in radio_tea5777_init()
566 tea->fops = tea575x_fops; in radio_tea5777_init()
567 tea->fops.owner = owner; in radio_tea5777_init()
568 tea->vd.fops = &tea->fops; in radio_tea5777_init()
570 tea->vd.ctrl_handler = &tea->ctrl_handler; in radio_tea5777_init()
571 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); in radio_tea5777_init()
572 v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, in radio_tea5777_init()
574 res = tea->ctrl_handler.error; in radio_tea5777_init()
576 v4l2_err(tea->v4l2_dev, "can't initialize controls\n"); in radio_tea5777_init()
577 v4l2_ctrl_handler_free(&tea->ctrl_handler); in radio_tea5777_init()
580 v4l2_ctrl_handler_setup(&tea->ctrl_handler); in radio_tea5777_init()
582 res = video_register_device(&tea->vd, VFL_TYPE_RADIO, -1); in radio_tea5777_init()
584 v4l2_err(tea->v4l2_dev, "can't register video device!\n"); in radio_tea5777_init()
585 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in radio_tea5777_init()
593 void radio_tea5777_exit(struct radio_tea5777 *tea) in radio_tea5777_exit() argument
595 video_unregister_device(&tea->vd); in radio_tea5777_exit()
596 v4l2_ctrl_handler_free(tea->vd.ctrl_handler); in radio_tea5777_exit()