⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tda18271-maps.c

📁 trident tm5600的linux驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
	{ .rfmax = 749000, .val = 0x3b },	{ .rfmax = 754000, .val = 0x3c },	{ .rfmax = 759000, .val = 0x3d },	{ .rfmax = 764000, .val = 0x3e },	{ .rfmax = 769000, .val = 0x3f },	{ .rfmax = 774000, .val = 0x40 },	{ .rfmax = 779000, .val = 0x41 },	{ .rfmax = 784000, .val = 0x43 },	{ .rfmax = 789000, .val = 0x46 },	{ .rfmax = 794000, .val = 0x48 },	{ .rfmax = 799000, .val = 0x4b },	{ .rfmax = 804000, .val = 0x4f },	{ .rfmax = 809000, .val = 0x54 },	{ .rfmax = 814000, .val = 0x59 },	{ .rfmax = 819000, .val = 0x5d },	{ .rfmax = 824000, .val = 0x61 },	{ .rfmax = 829000, .val = 0x68 },	{ .rfmax = 834000, .val = 0x6e },	{ .rfmax = 839000, .val = 0x75 },	{ .rfmax = 844000, .val = 0x7e },	{ .rfmax = 849000, .val = 0x82 },	{ .rfmax = 854000, .val = 0x84 },	{ .rfmax = 859000, .val = 0x8f },	{ .rfmax = 865000, .val = 0x9a },	{ .rfmax =      0, .val = 0x00 }, /* end */};/*---------------------------------------------------------------------*/struct tda18271_thermo_map {	u8 d;	u8 r0;	u8 r1;};static struct tda18271_thermo_map tda18271_thermometer[] = {	{ .d = 0x00, .r0 = 60, .r1 =  92 },	{ .d = 0x01, .r0 = 62, .r1 =  94 },	{ .d = 0x02, .r0 = 66, .r1 =  98 },	{ .d = 0x03, .r0 = 64, .r1 =  96 },	{ .d = 0x04, .r0 = 74, .r1 = 106 },	{ .d = 0x05, .r0 = 72, .r1 = 104 },	{ .d = 0x06, .r0 = 68, .r1 = 100 },	{ .d = 0x07, .r0 = 70, .r1 = 102 },	{ .d = 0x08, .r0 = 90, .r1 = 122 },	{ .d = 0x09, .r0 = 88, .r1 = 120 },	{ .d = 0x0a, .r0 = 84, .r1 = 116 },	{ .d = 0x0b, .r0 = 86, .r1 = 118 },	{ .d = 0x0c, .r0 = 76, .r1 = 108 },	{ .d = 0x0d, .r0 = 78, .r1 = 110 },	{ .d = 0x0e, .r0 = 82, .r1 = 114 },	{ .d = 0x0f, .r0 = 80, .r1 = 112 },	{ .d = 0x00, .r0 =  0, .r1 =   0 }, /* end */};int tda18271_lookup_thermometer(struct dvb_frontend *fe){	struct tda18271_priv *priv = fe->tuner_priv;	unsigned char *regs = priv->tda18271_regs;	int val, i = 0;	while (tda18271_thermometer[i].d < (regs[R_TM] & 0x0f)) {		if (tda18271_thermometer[i + 1].d == 0)			break;		i++;	}	if ((regs[R_TM] & 0x20) == 0x20)		val = tda18271_thermometer[i].r1;	else		val = tda18271_thermometer[i].r0;	tda_map("(%d) tm = %d\n", i, val);	return val;}/*---------------------------------------------------------------------*/struct tda18271_cid_target_map {	u32 rfmax;	u8  target;	u16 limit;};static struct tda18271_cid_target_map tda18271_cid_target[] = {	{ .rfmax =  46000, .target = 0x04, .limit =  1800 },	{ .rfmax =  52200, .target = 0x0a, .limit =  1500 },	{ .rfmax =  79100, .target = 0x01, .limit =  4000 },	{ .rfmax = 136800, .target = 0x18, .limit =  4000 },	{ .rfmax = 156700, .target = 0x18, .limit =  4000 },	{ .rfmax = 156700, .target = 0x18, .limit =  4000 },	{ .rfmax = 186250, .target = 0x0a, .limit =  4000 },	{ .rfmax = 230000, .target = 0x0a, .limit =  4000 },	{ .rfmax = 345000, .target = 0x18, .limit =  4000 },	{ .rfmax = 426000, .target = 0x0e, .limit =  4000 },	{ .rfmax = 489500, .target = 0x1e, .limit =  4000 },	{ .rfmax = 697500, .target = 0x32, .limit =  4000 },	{ .rfmax = 842000, .target = 0x3a, .limit =  4000 },	{ .rfmax =      0, .target = 0x00, .limit =     0 }, /* end */};int tda18271_lookup_cid_target(struct dvb_frontend *fe,			       u32 *freq, u8 *cid_target, u16 *count_limit){	int i = 0;	while ((tda18271_cid_target[i].rfmax * 1000) < *freq) {		if (tda18271_cid_target[i + 1].rfmax == 0)			break;		i++;	}	*cid_target  = tda18271_cid_target[i].target;	*count_limit = tda18271_cid_target[i].limit;	tda_map("(%d) cid_target = %02x, count_limit = %d\n", i,		tda18271_cid_target[i].target, tda18271_cid_target[i].limit);	return 0;}/*---------------------------------------------------------------------*/static struct tda18271_rf_tracking_filter_cal tda18271_rf_band_template[] = {	{ .rfmax =  47900, .rfband = 0x00,	  .rf1_def =  46000, .rf2_def =      0, .rf3_def =      0 },	{ .rfmax =  61100, .rfband = 0x01,	  .rf1_def =  52200, .rf2_def =      0, .rf3_def =      0 },	{ .rfmax = 152600, .rfband = 0x02,	  .rf1_def =  70100, .rf2_def = 136800, .rf3_def =      0 },	{ .rfmax = 164700, .rfband = 0x03,	  .rf1_def = 156700, .rf2_def =      0, .rf3_def =      0 },	{ .rfmax = 203500, .rfband = 0x04,	  .rf1_def = 186250, .rf2_def =      0, .rf3_def =      0 },	{ .rfmax = 457800, .rfband = 0x05,	  .rf1_def = 230000, .rf2_def = 345000, .rf3_def = 426000 },	{ .rfmax = 865000, .rfband = 0x06,	  .rf1_def = 489500, .rf2_def = 697500, .rf3_def = 842000 },	{ .rfmax =      0, .rfband = 0x00,	  .rf1_def =      0, .rf2_def =      0, .rf3_def =      0 }, /* end */};int tda18271_lookup_rf_band(struct dvb_frontend *fe, u32 *freq, u8 *rf_band){	struct tda18271_priv *priv = fe->tuner_priv;	struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state;	int i = 0;	while ((map[i].rfmax * 1000) < *freq) {		if (tda18271_debug & DBG_ADV)			tda_map("(%d) rfmax = %d < freq = %d, "				"rf1_def = %d, rf2_def = %d, rf3_def = %d, "				"rf1 = %d, rf2 = %d, rf3 = %d, "				"rf_a1 = %d, rf_a2 = %d, "				"rf_b1 = %d, rf_b2 = %d\n",				i, map[i].rfmax * 1000, *freq,				map[i].rf1_def, map[i].rf2_def, map[i].rf3_def,				map[i].rf1, map[i].rf2, map[i].rf3,				map[i].rf_a1, map[i].rf_a2,				map[i].rf_b1, map[i].rf_b2);		if (map[i].rfmax == 0)			return -EINVAL;		i++;	}	if (rf_band)		*rf_band = map[i].rfband;	tda_map("(%d) rf_band = %02x\n", i, map[i].rfband);	return i;}/*---------------------------------------------------------------------*/struct tda18271_map_layout {	struct tda18271_pll_map *main_pll;	struct tda18271_pll_map *cal_pll;	struct tda18271_map *rf_cal;	struct tda18271_map *rf_cal_kmco;	struct tda18271_map *rf_cal_dc_over_dt;	struct tda18271_map *bp_filter;	struct tda18271_map *rf_band;	struct tda18271_map *gain_taper;	struct tda18271_map *ir_measure;};/*---------------------------------------------------------------------*/int tda18271_lookup_pll_map(struct dvb_frontend *fe,			    enum tda18271_map_type map_type,			    u32 *freq, u8 *post_div, u8 *div){	struct tda18271_priv *priv = fe->tuner_priv;	struct tda18271_pll_map *map = NULL;	unsigned int i = 0;	char *map_name;	int ret = 0;	BUG_ON(!priv->maps);	switch (map_type) {	case MAIN_PLL:		map = priv->maps->main_pll;		map_name = "main_pll";		break;	case CAL_PLL:		map = priv->maps->cal_pll;		map_name = "cal_pll";		break;	default:		/* we should never get here */		map_name = "undefined";		break;	}	if (!map) {		tda_warn("%s map is not set!\n", map_name);		ret = -EINVAL;		goto fail;	}	while ((map[i].lomax * 1000) < *freq) {		if (map[i + 1].lomax == 0) {			tda_map("%s: frequency (%d) out of range\n",				map_name, *freq);			ret = -ERANGE;			break;		}		i++;	}	*post_div = map[i].pd;	*div      = map[i].d;	tda_map("(%d) %s: post div = 0x%02x, div = 0x%02x\n",		i, map_name, *post_div, *div);fail:	return ret;}int tda18271_lookup_map(struct dvb_frontend *fe,			enum tda18271_map_type map_type,			u32 *freq, u8 *val){	struct tda18271_priv *priv = fe->tuner_priv;	struct tda18271_map *map = NULL;	unsigned int i = 0;	char *map_name;	int ret = 0;	BUG_ON(!priv->maps);	switch (map_type) {	case BP_FILTER:		map = priv->maps->bp_filter;		map_name = "bp_filter";		break;	case RF_CAL_KMCO:		map = priv->maps->rf_cal_kmco;		map_name = "km";		break;	case RF_BAND:		map = priv->maps->rf_band;		map_name = "rf_band";		break;	case GAIN_TAPER:		map = priv->maps->gain_taper;		map_name = "gain_taper";		break;	case RF_CAL:		map = priv->maps->rf_cal;		map_name = "rf_cal";		break;	case IR_MEASURE:		map = priv->maps->ir_measure;		map_name = "ir_measure";		break;	case RF_CAL_DC_OVER_DT:		map = priv->maps->rf_cal_dc_over_dt;		map_name = "rf_cal_dc_over_dt";		break;	default:		/* we should never get here */		map_name = "undefined";		break;	}	if (!map) {		tda_warn("%s map is not set!\n", map_name);		ret = -EINVAL;		goto fail;	}	while ((map[i].rfmax * 1000) < *freq) {		if (map[i + 1].rfmax == 0) {			tda_map("%s: frequency (%d) out of range\n",				map_name, *freq);			ret = -ERANGE;			break;		}		i++;	}	*val = map[i].val;	tda_map("(%d) %s: 0x%02x\n", i, map_name, *val);fail:	return ret;}/*---------------------------------------------------------------------*/static struct tda18271_std_map tda18271c1_std_map = {	.fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */	.atv_b    = { .if_freq = 6750, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_dk   = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */	.atv_gh   = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */	.atv_i    = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */	.atv_l    = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */	.atv_lc   = { .if_freq = 1250, .fm_rfn = 0, .agc_mode = 1, .std = 7,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */	.atv_mn   = { .if_freq = 5750, .fm_rfn = 0, .agc_mode = 1, .std = 5,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0d */	.atsc_6   = { .if_freq = 3250, .fm_rfn = 0, .agc_mode = 3, .std = 4,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */	.dvbt_6   = { .if_freq = 3300, .fm_rfn = 0, .agc_mode = 3, .std = 4,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */	.dvbt_7   = { .if_freq = 3800, .fm_rfn = 0, .agc_mode = 3, .std = 5,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */	.dvbt_8   = { .if_freq = 4300, .fm_rfn = 0, .agc_mode = 3, .std = 6,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1e */	.qam_6    = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */	.qam_8    = { .if_freq = 5000, .fm_rfn = 0, .agc_mode = 3, .std = 7,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */};static struct tda18271_std_map tda18271c2_std_map = {	.fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */	.atv_b    = { .if_freq = 6000, .fm_rfn = 0, .agc_mode = 1, .std = 5,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0d */	.atv_dk   = { .if_freq = 6900, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_gh   = { .if_freq = 7100, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_i    = { .if_freq = 7250, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_l    = { .if_freq = 6900, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_lc   = { .if_freq = 1250, .fm_rfn = 0, .agc_mode = 1, .std = 6,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */	.atv_mn   = { .if_freq = 5400, .fm_rfn = 0, .agc_mode = 1, .std = 4,		      .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0c */	.atsc_6   = { .if_freq = 3250, .fm_rfn = 0, .agc_mode = 3, .std = 4,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */	.dvbt_6   = { .if_freq = 3300, .fm_rfn = 0, .agc_mode = 3, .std = 4,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */	.dvbt_7   = { .if_freq = 3500, .fm_rfn = 0, .agc_mode = 3, .std = 4,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */	.dvbt_8   = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */	.qam_6    = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */	.qam_8    = { .if_freq = 5000, .fm_rfn = 0, .agc_mode = 3, .std = 7,		      .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */};/*---------------------------------------------------------------------*/static struct tda18271_map_layout tda18271c1_map_layout = {	.main_pll          = tda18271c1_main_pll,	.cal_pll           = tda18271c1_cal_pll,	.rf_cal            = tda18271c1_rf_cal,	.rf_cal_kmco       = tda18271c1_km,	.bp_filter         = tda18271_bp_filter,	.rf_band           = tda18271_rf_band,	.gain_taper        = tda18271_gain_taper,	.ir_measure        = tda18271_ir_measure,};static struct tda18271_map_layout tda18271c2_map_layout = {	.main_pll          = tda18271c2_main_pll,	.cal_pll           = tda18271c2_cal_pll,	.rf_cal            = tda18271c2_rf_cal,	.rf_cal_kmco       = tda18271c2_km,	.rf_cal_dc_over_dt = tda18271_rf_cal_dc_over_dt,	.bp_filter         = tda18271_bp_filter,	.rf_band           = tda18271_rf_band,	.gain_taper        = tda18271_gain_taper,	.ir_measure        = tda18271_ir_measure,};int tda18271_assign_map_layout(struct dvb_frontend *fe){	struct tda18271_priv *priv = fe->tuner_priv;	int ret = 0;	switch (priv->id) {	case TDA18271HDC1:		priv->maps = &tda18271c1_map_layout;		memcpy(&priv->std, &tda18271c1_std_map,		       sizeof(struct tda18271_std_map));		break;	case TDA18271HDC2:		priv->maps = &tda18271c2_map_layout;		memcpy(&priv->std, &tda18271c2_std_map,		       sizeof(struct tda18271_std_map));		break;	default:		ret = -EINVAL;		break;	}	memcpy(priv->rf_cal_state, &tda18271_rf_band_template,	       sizeof(tda18271_rf_band_template));	return ret;}/* * Overrides for Emacs so that we follow Linus's tabbing style. * --------------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -