/* Sets band (0-US; 1-Europe; 2-Japan) */ int fm_rx_set_region(struct fmdrv_ops *fmdev, unsigned char region_to_set) { unsigned char payload = FM_STEREO_AUTO|FM_BAND_REG_WEST; unsigned short boundary[2]; int ret = -EPERM; V4L2_FM_DRV_DBG(V4L2_DBG_TX,"fm_rx_set_region In region_to_set %d",\ region_to_set); if (fmdev->curr_fmmode != FM_MODE_RX) return ret; if (region_to_set != FM_REGION_NA && region_to_set != FM_REGION_EUR && region_to_set != FM_REGION_JP && region_to_set != FM_REGION_RUS && region_to_set != FM_REGION_CHN) { V4L2_FM_DRV_ERR("(fmdrv): Invalid band"); ret = -EINVAL; return ret; } if (region_to_set == FM_REGION_JP || region_to_set == FM_REGION_RUS || region_to_set == FM_REGION_CHN) { memcpy(&fmdev->rx.region, ®ion_configs[region_to_set], sizeof(struct region_info)); boundary[0] = fmdev->rx.region.high_bound; boundary[1] = fmdev->rx.region.low_bound; fmc_send_cmd(fmdev, FM_SEARCH_BOUNDARY, boundary, sizeof(boundary), REG_WR, &fmdev->maintask_completion, NULL, NULL); } else { boundary[0] = 0; boundary[1] = 0; fmc_send_cmd(fmdev, FM_SEARCH_BOUNDARY, boundary, sizeof(boundary), REG_WR, &fmdev->maintask_completion, NULL, NULL); } if (region_to_set == FM_REGION_JP)/* set japan region */ { payload |= FM_BAND_REG_EAST; } /* Send cmd to set the band */ ret = fmc_send_cmd(fmdev, FM_REG_FM_CTRL, &payload, sizeof(payload), REG_WR, &fmdev->maintask_completion, NULL, NULL); FM_CHECK_SEND_CMD_STATUS(ret); fmc_update_region_info(fmdev, region_to_set); return ret; }
/* Sets band (0-Europe/US; 1-Japan) */ int fm_rx_set_region(struct fmdev *fmdev, u8 region_to_set) { u16 payload; u32 new_frq = 0; int ret; if (region_to_set != FM_BAND_EUROPE_US && region_to_set != FM_BAND_JAPAN) { fmerr("Invalid band\n"); return -EINVAL; } if (fmdev->rx.region.fm_band == region_to_set) { fmerr("Requested band is already configured\n"); return 0; } /* Send cmd to set the band */ payload = (u16)region_to_set; ret = fmc_send_cmd(fmdev, BAND_SET, REG_WR, &payload, sizeof(payload), NULL, NULL); if (ret < 0) return ret; fmc_update_region_info(fmdev, region_to_set); /* Check whether current RX frequency is within band boundary */ if (fmdev->rx.freq < fmdev->rx.region.bot_freq) new_frq = fmdev->rx.region.bot_freq; else if (fmdev->rx.freq > fmdev->rx.region.top_freq) new_frq = fmdev->rx.region.top_freq; if (new_frq) { fmdbg("Current freq is not within band limit boundary," "switching to %d KHz\n", new_frq); /* Current RX frequency is not in range. So, update it */ ret = fm_rx_set_freq(fmdev, new_frq); } return ret; }