diff options
author | Antti Palosaari <crope@iki.fi> | 2014-12-08 22:24:13 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-02-02 14:52:25 -0500 |
commit | b8cb50d237ff1590e2b39031e5d7d3e1bcd49c5b (patch) | |
tree | 6936e41d4929385114bd0861eb8644688d788281 | |
parent | 7cc39328898151e92eb4ff052150737558bf7887 (diff) |
[media] rtl2830: get rid of internal config data
Remove internal config and use configuration values directly from
the platform data.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/dvb-frontends/rtl2830.c | 43 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/rtl2830_priv.h | 15 |
2 files changed, 18 insertions, 40 deletions
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c index fa73575a6692..ea68c7ef2a71 100644 --- a/drivers/media/dvb-frontends/rtl2830.c +++ b/drivers/media/dvb-frontends/rtl2830.c | |||
@@ -33,12 +33,11 @@ | |||
33 | /* write multiple hardware registers */ | 33 | /* write multiple hardware registers */ |
34 | static int rtl2830_wr(struct i2c_client *client, u8 reg, const u8 *val, int len) | 34 | static int rtl2830_wr(struct i2c_client *client, u8 reg, const u8 *val, int len) |
35 | { | 35 | { |
36 | struct rtl2830_dev *dev = i2c_get_clientdata(client); | ||
37 | int ret; | 36 | int ret; |
38 | u8 buf[MAX_XFER_SIZE]; | 37 | u8 buf[MAX_XFER_SIZE]; |
39 | struct i2c_msg msg[1] = { | 38 | struct i2c_msg msg[1] = { |
40 | { | 39 | { |
41 | .addr = dev->cfg.i2c_addr, | 40 | .addr = client->addr, |
42 | .flags = 0, | 41 | .flags = 0, |
43 | .len = 1 + len, | 42 | .len = 1 + len, |
44 | .buf = buf, | 43 | .buf = buf, |
@@ -54,7 +53,7 @@ static int rtl2830_wr(struct i2c_client *client, u8 reg, const u8 *val, int len) | |||
54 | buf[0] = reg; | 53 | buf[0] = reg; |
55 | memcpy(&buf[1], val, len); | 54 | memcpy(&buf[1], val, len); |
56 | 55 | ||
57 | ret = i2c_transfer(dev->i2c, msg, 1); | 56 | ret = i2c_transfer(client->adapter, msg, 1); |
58 | if (ret == 1) { | 57 | if (ret == 1) { |
59 | ret = 0; | 58 | ret = 0; |
60 | } else { | 59 | } else { |
@@ -68,23 +67,22 @@ static int rtl2830_wr(struct i2c_client *client, u8 reg, const u8 *val, int len) | |||
68 | /* read multiple hardware registers */ | 67 | /* read multiple hardware registers */ |
69 | static int rtl2830_rd(struct i2c_client *client, u8 reg, u8 *val, int len) | 68 | static int rtl2830_rd(struct i2c_client *client, u8 reg, u8 *val, int len) |
70 | { | 69 | { |
71 | struct rtl2830_dev *dev = i2c_get_clientdata(client); | ||
72 | int ret; | 70 | int ret; |
73 | struct i2c_msg msg[2] = { | 71 | struct i2c_msg msg[2] = { |
74 | { | 72 | { |
75 | .addr = dev->cfg.i2c_addr, | 73 | .addr = client->addr, |
76 | .flags = 0, | 74 | .flags = 0, |
77 | .len = 1, | 75 | .len = 1, |
78 | .buf = ®, | 76 | .buf = ®, |
79 | }, { | 77 | }, { |
80 | .addr = dev->cfg.i2c_addr, | 78 | .addr = client->addr, |
81 | .flags = I2C_M_RD, | 79 | .flags = I2C_M_RD, |
82 | .len = len, | 80 | .len = len, |
83 | .buf = val, | 81 | .buf = val, |
84 | } | 82 | } |
85 | }; | 83 | }; |
86 | 84 | ||
87 | ret = i2c_transfer(dev->i2c, msg, 2); | 85 | ret = i2c_transfer(client->adapter, msg, 2); |
88 | if (ret == 2) { | 86 | if (ret == 2) { |
89 | ret = 0; | 87 | ret = 0; |
90 | } else { | 88 | } else { |
@@ -207,10 +205,10 @@ static int rtl2830_init(struct dvb_frontend *fe) | |||
207 | { 0x2f1, 0x20, 0xf8 }, | 205 | { 0x2f1, 0x20, 0xf8 }, |
208 | { 0x16d, 0x00, 0x01 }, | 206 | { 0x16d, 0x00, 0x01 }, |
209 | { 0x1a6, 0x00, 0x80 }, | 207 | { 0x1a6, 0x00, 0x80 }, |
210 | { 0x106, dev->cfg.vtop, 0x3f }, | 208 | { 0x106, dev->pdata->vtop, 0x3f }, |
211 | { 0x107, dev->cfg.krf, 0x3f }, | 209 | { 0x107, dev->pdata->krf, 0x3f }, |
212 | { 0x112, 0x28, 0xff }, | 210 | { 0x112, 0x28, 0xff }, |
213 | { 0x103, dev->cfg.agc_targ_val, 0xff }, | 211 | { 0x103, dev->pdata->agc_targ_val, 0xff }, |
214 | { 0x00a, 0x02, 0x07 }, | 212 | { 0x00a, 0x02, 0x07 }, |
215 | { 0x140, 0x0c, 0x3c }, | 213 | { 0x140, 0x0c, 0x3c }, |
216 | { 0x140, 0x40, 0xc0 }, | 214 | { 0x140, 0x40, 0xc0 }, |
@@ -218,7 +216,7 @@ static int rtl2830_init(struct dvb_frontend *fe) | |||
218 | { 0x15b, 0x28, 0x38 }, | 216 | { 0x15b, 0x28, 0x38 }, |
219 | { 0x15c, 0x05, 0x07 }, | 217 | { 0x15c, 0x05, 0x07 }, |
220 | { 0x15c, 0x28, 0x38 }, | 218 | { 0x15c, 0x28, 0x38 }, |
221 | { 0x115, dev->cfg.spec_inv, 0x01 }, | 219 | { 0x115, dev->pdata->spec_inv, 0x01 }, |
222 | { 0x16f, 0x01, 0x07 }, | 220 | { 0x16f, 0x01, 0x07 }, |
223 | { 0x170, 0x18, 0x38 }, | 221 | { 0x170, 0x18, 0x38 }, |
224 | { 0x172, 0x0f, 0x0f }, | 222 | { 0x172, 0x0f, 0x0f }, |
@@ -349,9 +347,9 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) | |||
349 | if (ret < 0) | 347 | if (ret < 0) |
350 | goto err; | 348 | goto err; |
351 | 349 | ||
352 | num = if_frequency % dev->cfg.xtal; | 350 | num = if_frequency % dev->pdata->clk; |
353 | num *= 0x400000; | 351 | num *= 0x400000; |
354 | num = div_u64(num, dev->cfg.xtal); | 352 | num = div_u64(num, dev->pdata->clk); |
355 | num = -num; | 353 | num = -num; |
356 | if_ctl = num & 0x3fffff; | 354 | if_ctl = num & 0x3fffff; |
357 | dev_dbg(&client->dev, "if_frequency=%d if_ctl=%08x\n", | 355 | dev_dbg(&client->dev, "if_frequency=%d if_ctl=%08x\n", |
@@ -506,7 +504,7 @@ err: | |||
506 | static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status) | 504 | static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status) |
507 | { | 505 | { |
508 | struct i2c_client *client = fe->demodulator_priv; | 506 | struct i2c_client *client = fe->demodulator_priv; |
509 | struct rtl2830_dev *dev = fe->demodulator_priv; | 507 | struct rtl2830_dev *dev = i2c_get_clientdata(client); |
510 | int ret; | 508 | int ret; |
511 | u8 tmp; | 509 | u8 tmp; |
512 | *status = 0; | 510 | *status = 0; |
@@ -688,7 +686,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) | |||
688 | struct rtl2830_dev *dev = i2c_get_clientdata(client); | 686 | struct rtl2830_dev *dev = i2c_get_clientdata(client); |
689 | struct i2c_msg select_reg_page_msg[1] = { | 687 | struct i2c_msg select_reg_page_msg[1] = { |
690 | { | 688 | { |
691 | .addr = dev->cfg.i2c_addr, | 689 | .addr = client->addr, |
692 | .flags = 0, | 690 | .flags = 0, |
693 | .len = 2, | 691 | .len = 2, |
694 | .buf = "\x00\x01", | 692 | .buf = "\x00\x01", |
@@ -696,7 +694,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) | |||
696 | }; | 694 | }; |
697 | struct i2c_msg gate_open_msg[1] = { | 695 | struct i2c_msg gate_open_msg[1] = { |
698 | { | 696 | { |
699 | .addr = dev->cfg.i2c_addr, | 697 | .addr = client->addr, |
700 | .flags = 0, | 698 | .flags = 0, |
701 | .len = 2, | 699 | .len = 2, |
702 | .buf = "\x01\x08", | 700 | .buf = "\x01\x08", |
@@ -705,7 +703,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) | |||
705 | int ret; | 703 | int ret; |
706 | 704 | ||
707 | /* select register page */ | 705 | /* select register page */ |
708 | ret = __i2c_transfer(adap, select_reg_page_msg, 1); | 706 | ret = __i2c_transfer(client->adapter, select_reg_page_msg, 1); |
709 | if (ret != 1) { | 707 | if (ret != 1) { |
710 | dev_warn(&client->dev, "i2c write failed %d\n", ret); | 708 | dev_warn(&client->dev, "i2c write failed %d\n", ret); |
711 | if (ret >= 0) | 709 | if (ret >= 0) |
@@ -716,7 +714,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) | |||
716 | dev->page = 1; | 714 | dev->page = 1; |
717 | 715 | ||
718 | /* open tuner I2C repeater for 1 xfer, closes automatically */ | 716 | /* open tuner I2C repeater for 1 xfer, closes automatically */ |
719 | ret = __i2c_transfer(adap, gate_open_msg, 1); | 717 | ret = __i2c_transfer(client->adapter, gate_open_msg, 1); |
720 | if (ret != 1) { | 718 | if (ret != 1) { |
721 | dev_warn(&client->dev, "i2c write failed %d\n", ret); | 719 | dev_warn(&client->dev, "i2c write failed %d\n", ret); |
722 | if (ret >= 0) | 720 | if (ret >= 0) |
@@ -753,7 +751,6 @@ static int rtl2830_probe(struct i2c_client *client, | |||
753 | const struct i2c_device_id *id) | 751 | const struct i2c_device_id *id) |
754 | { | 752 | { |
755 | struct rtl2830_platform_data *pdata = client->dev.platform_data; | 753 | struct rtl2830_platform_data *pdata = client->dev.platform_data; |
756 | struct i2c_adapter *i2c = client->adapter; | ||
757 | struct rtl2830_dev *dev; | 754 | struct rtl2830_dev *dev; |
758 | int ret; | 755 | int ret; |
759 | u8 u8tmp; | 756 | u8 u8tmp; |
@@ -774,14 +771,8 @@ static int rtl2830_probe(struct i2c_client *client, | |||
774 | 771 | ||
775 | /* setup the state */ | 772 | /* setup the state */ |
776 | i2c_set_clientdata(client, dev); | 773 | i2c_set_clientdata(client, dev); |
777 | dev->i2c = i2c; | 774 | dev->pdata = client->dev.platform_data; |
778 | dev->sleeping = true; | 775 | dev->sleeping = true; |
779 | dev->cfg.i2c_addr = client->addr; | ||
780 | dev->cfg.xtal = pdata->clk; | ||
781 | dev->cfg.spec_inv = pdata->spec_inv; | ||
782 | dev->cfg.vtop = pdata->vtop; | ||
783 | dev->cfg.krf = pdata->krf; | ||
784 | dev->cfg.agc_targ_val = pdata->agc_targ_val; | ||
785 | 776 | ||
786 | /* check if the demod is there */ | 777 | /* check if the demod is there */ |
787 | ret = rtl2830_rd_reg(client, 0x000, &u8tmp); | 778 | ret = rtl2830_rd_reg(client, 0x000, &u8tmp); |
diff --git a/drivers/media/dvb-frontends/rtl2830_priv.h b/drivers/media/dvb-frontends/rtl2830_priv.h index 9e7bd4264ac1..5276fb210990 100644 --- a/drivers/media/dvb-frontends/rtl2830_priv.h +++ b/drivers/media/dvb-frontends/rtl2830_priv.h | |||
@@ -26,24 +26,11 @@ | |||
26 | #include "rtl2830.h" | 26 | #include "rtl2830.h" |
27 | #include <linux/i2c-mux.h> | 27 | #include <linux/i2c-mux.h> |
28 | 28 | ||
29 | struct rtl2830_config { | ||
30 | u8 i2c_addr; | ||
31 | u32 xtal; | ||
32 | bool spec_inv; | ||
33 | u8 vtop; | ||
34 | u8 krf; | ||
35 | u8 agc_targ_val; | ||
36 | }; | ||
37 | |||
38 | struct rtl2830_dev { | 29 | struct rtl2830_dev { |
30 | struct rtl2830_platform_data *pdata; | ||
39 | struct i2c_adapter *adapter; | 31 | struct i2c_adapter *adapter; |
40 | struct i2c_adapter *i2c; | ||
41 | struct dvb_frontend fe; | 32 | struct dvb_frontend fe; |
42 | struct rtl2830_config cfg; | ||
43 | struct i2c_adapter tuner_i2c_adapter; | ||
44 | |||
45 | bool sleeping; | 33 | bool sleeping; |
46 | |||
47 | u8 page; /* active register page */ | 34 | u8 page; /* active register page */ |
48 | }; | 35 | }; |
49 | 36 | ||