static int s610_radio_fops_open(struct file *file)
{
+#ifdef CONFIG_SCSC_FM
+ int i;
+ int ret_mx250;
+ int xtal_clkdet;
+#endif /* CONFIG_SCSC_FM */
int ret;
struct s610_radio *radio = video_drvdata(file);
- static bool run_once = true;
FUNC_ENTRY(radio);
-#ifdef CONFIG_SCSC_FM
- /* Start FM/WLBT LDO */
- ret = mx250_fm_request();
- if (ret < 0) {
- dev_err(radio->v4l2dev.dev,
- "mx250_fm_request() failed with err %d\n", ret);
- return ret;
- }
-#endif /* CONFIG_SCSC_FM */
-
shared_fm_open_cnt++;
-#ifdef USE_FM_LNA_ENABLE
- if (radio->elna_gpio != -EINVAL) {
- ret = set_eLNA_gpio(radio, GPIO_HIGH);
- if (ret)
- dev_info(radio->v4l2dev.dev,
- "Failed to set gpio for eLNA\n");
- }
-#endif /* USE_FM_LNA_ENABLE */
-
ret = v4l2_fh_open(file);
if (ret)
return ret;
if (v4l2_fh_is_singular_file(file)) {
+#ifdef CONFIG_SCSC_FM
+ /* Start FM/WLBT LDO */
+ ret_mx250 = mx250_fm_request();
+#endif /* CONFIG_SCSC_FM */
+
+#ifdef USE_FM_LNA_ENABLE
+ if (radio->elna_gpio != -EINVAL) {
+ ret = set_eLNA_gpio(radio, GPIO_HIGH);
+ if (ret)
+ dev_info(radio->v4l2dev.dev,
+ "Failed to set gpio for eLNA\n");
+ }
+#endif /* USE_FM_LNA_ENABLE */
+
s610_core_lock(radio->core);
atomic_set(&radio->is_doing, 0);
atomic_set(&radio->is_rds_doing, 0);
fmspeedy_wakeup();
- if (run_once) {
- fm_ds_set(0);
- fm_aux_pll_off();
+#ifdef CONFIG_SCSC_FM
+ i = 0;
+ do {
+ if (i > 10) {
+ dev_err(radio->v4l2dev.dev, "mx250_fm_request() failed\n");
+ ret = -1;
+ goto err_open;
+ }
- run_once = false;
- }
+ if (i > 0)
+ ret_mx250 = mx250_fm_request();
+
+ msleep(200);
+ xtal_clkdet = fmspeedy_get_reg_field(0xFFF25B, 7, (0x0001 << 7));
+
+ dev_err(radio->v4l2dev.dev,
+ "#%d, mx250_fm_request ret : %d, xtal_clkdet : %d\n",
+ i, ret_mx250, xtal_clkdet);
+
+ i++;
+ } while ((xtal_clkdet != 1) || (ret_mx250 < 0));
+#endif /* CONFIG_SCSC_FM */
fm_get_version_number();
}
#endif /* USE_AUDIO_PM */
s610_core_unlock(radio->core);
- }
-
- if (wake_lock_active(&radio->wakelock))
- wake_unlock(&radio->wakelock);
-
- if (wake_lock_active(&radio->rdswakelock))
- wake_unlock(&radio->rdswakelock);
-
- ret = v4l2_fh_release(file);
#ifdef USE_FM_LNA_ENABLE
- if (radio->elna_gpio != -EINVAL) {
- ret = set_eLNA_gpio(radio, GPIO_LOW);
- if (ret)
- dev_info(radio->v4l2dev.dev,
- "Failed to set gpio for eLNA\n");
- }
+ if (radio->elna_gpio != -EINVAL) {
+ ret = set_eLNA_gpio(radio, GPIO_LOW);
+ if (ret)
+ dev_info(radio->v4l2dev.dev,
+ "Failed to set gpio for eLNA\n");
+ }
#endif /* USE_FM_LNA_ENABLE */
#ifdef CONFIG_SCSC_FM
dev_err(radio->v4l2dev.dev,
"mx250_fm_release() failed with err %d\n", ret);
#endif
+ }
+
+ if (wake_lock_active(&radio->wakelock))
+ wake_unlock(&radio->wakelock);
+
+ if (wake_lock_active(&radio->rdswakelock))
+ wake_unlock(&radio->rdswakelock);
+
+ ret = v4l2_fh_release(file);
shared_fm_open_cnt--;