···234234 Montage M88RS6000 internal tuner.235235236236config MEDIA_TUNER_TUA9001237237- tristate "Infineon TUA 9001 silicon tuner"237237+ tristate "Infineon TUA9001 silicon tuner"238238 depends on MEDIA_SUPPORT && I2C239239 default m if !MEDIA_SUBDRV_AUTOSELECT240240 help
+75-78
drivers/media/tuners/tua9001.c
···11/*22- * Infineon TUA 9001 silicon tuner driver22+ * Infineon TUA9001 silicon tuner driver33 *44 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>55 *···1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414 * GNU General Public License for more details.1515- *1616- * You should have received a copy of the GNU General Public License along1717- * with this program; if not, write to the Free Software Foundation, Inc.,1818- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.1915 */20162121-#include "tua9001.h"2217#include "tua9001_priv.h"23182419/* write register */2525-static int tua9001_wr_reg(struct tua9001_priv *priv, u8 reg, u16 val)2020+static int tua9001_wr_reg(struct tua9001_dev *dev, u8 reg, u16 val)2621{2222+ struct i2c_client *client = dev->client;2723 int ret;2824 u8 buf[3] = { reg, (val >> 8) & 0xff, (val >> 0) & 0xff };2925 struct i2c_msg msg[1] = {3026 {3131- .addr = priv->i2c_addr,2727+ .addr = client->addr,3228 .flags = 0,3329 .len = sizeof(buf),3430 .buf = buf,3531 }3632 };37333838- ret = i2c_transfer(priv->i2c, msg, 1);3434+ ret = i2c_transfer(client->adapter, msg, 1);3935 if (ret == 1) {4036 ret = 0;4137 } else {4242- dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x\n",4343- KBUILD_MODNAME, ret, reg);3838+ dev_warn(&client->dev, "i2c wr failed=%d reg=%02x\n", ret, reg);4439 ret = -EREMOTEIO;4540 }4641···44494550static int tua9001_init(struct dvb_frontend *fe)4651{4747- struct tua9001_priv *priv = fe->tuner_priv;4848- int ret = 0;4949- u8 i;5050- struct reg_val data[] = {5151- { 0x1e, 0x6512 },5252- { 0x25, 0xb888 },5353- { 0x39, 0x5460 },5454- { 0x3b, 0x00c0 },5555- { 0x3a, 0xf000 },5656- { 0x08, 0x0000 },5757- { 0x32, 0x0030 },5858- { 0x41, 0x703a },5959- { 0x40, 0x1c78 },6060- { 0x2c, 0x1c00 },6161- { 0x36, 0xc013 },6262- { 0x37, 0x6f18 },6363- { 0x27, 0x0008 },6464- { 0x2a, 0x0001 },6565- { 0x34, 0x0a40 },5252+ struct tua9001_dev *dev = fe->tuner_priv;5353+ struct i2c_client *client = dev->client;5454+ int ret, i;5555+ static const struct tua9001_reg_val data[] = {5656+ {0x1e, 0x6512},5757+ {0x25, 0xb888},5858+ {0x39, 0x5460},5959+ {0x3b, 0x00c0},6060+ {0x3a, 0xf000},6161+ {0x08, 0x0000},6262+ {0x32, 0x0030},6363+ {0x41, 0x703a},6464+ {0x40, 0x1c78},6565+ {0x2c, 0x1c00},6666+ {0x36, 0xc013},6767+ {0x37, 0x6f18},6868+ {0x27, 0x0008},6969+ {0x2a, 0x0001},7070+ {0x34, 0x0a40},6671 };67726868- dev_dbg(&priv->i2c->dev, "%s:\n", __func__);7373+ dev_dbg(&client->dev, "\n");69747075 if (fe->callback) {7171- ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,7272- TUA9001_CMD_RESETN, 0);7373- if (ret < 0)7676+ ret = fe->callback(client->adapter,7777+ DVB_FRONTEND_COMPONENT_TUNER,7878+ TUA9001_CMD_RESETN, 0);7979+ if (ret)7480 goto err;7581 }76827783 for (i = 0; i < ARRAY_SIZE(data); i++) {7878- ret = tua9001_wr_reg(priv, data[i].reg, data[i].val);7979- if (ret < 0)8484+ ret = tua9001_wr_reg(dev, data[i].reg, data[i].val);8585+ if (ret)8086 goto err;8187 }8888+ return 0;8289err:8383- if (ret < 0)8484- dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);8585-9090+ dev_dbg(&client->dev, "failed=%d\n", ret);8691 return ret;8792}88938994static int tua9001_sleep(struct dvb_frontend *fe)9095{9191- struct tua9001_priv *priv = fe->tuner_priv;9292- int ret = 0;9696+ struct tua9001_dev *dev = fe->tuner_priv;9797+ struct i2c_client *client = dev->client;9898+ int ret;93999494- dev_dbg(&priv->i2c->dev, "%s:\n", __func__);100100+ dev_dbg(&client->dev, "\n");951019696- if (fe->callback)9797- ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,9898- TUA9001_CMD_RESETN, 1);9999-100100- if (ret < 0)101101- dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);102102-102102+ if (fe->callback) {103103+ ret = fe->callback(client->adapter,104104+ DVB_FRONTEND_COMPONENT_TUNER,105105+ TUA9001_CMD_RESETN, 1);106106+ if (ret)107107+ goto err;108108+ }109109+ return 0;110110+err:111111+ dev_dbg(&client->dev, "failed=%d\n", ret);103112 return ret;104113}105114106115static int tua9001_set_params(struct dvb_frontend *fe)107116{108108- struct tua9001_priv *priv = fe->tuner_priv;117117+ struct tua9001_dev *dev = fe->tuner_priv;118118+ struct i2c_client *client = dev->client;109119 struct dtv_frontend_properties *c = &fe->dtv_property_cache;110110- int ret = 0, i;120120+ int ret, i;111121 u16 val;112122 u32 frequency;113113- struct reg_val data[2];123123+ struct tua9001_reg_val data[2];114124115115- dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d frequency=%d " \116116- "bandwidth_hz=%d\n", __func__,117117- c->delivery_system, c->frequency, c->bandwidth_hz);125125+ dev_dbg(&client->dev,126126+ "delivery_system=%u frequency=%u bandwidth_hz=%u\n",127127+ c->delivery_system, c->frequency, c->bandwidth_hz);118128119129 switch (c->delivery_system) {120130 case SYS_DVBT:···158158 data[1].val = frequency;159159160160 if (fe->callback) {161161- ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,162162- TUA9001_CMD_RXEN, 0);163163- if (ret < 0)161161+ ret = fe->callback(client->adapter,162162+ DVB_FRONTEND_COMPONENT_TUNER,163163+ TUA9001_CMD_RXEN, 0);164164+ if (ret)164165 goto err;165166 }166167167168 for (i = 0; i < ARRAY_SIZE(data); i++) {168168- ret = tua9001_wr_reg(priv, data[i].reg, data[i].val);169169- if (ret < 0)169169+ ret = tua9001_wr_reg(dev, data[i].reg, data[i].val);170170+ if (ret)170171 goto err;171172 }172173173174 if (fe->callback) {174174- ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,175175- TUA9001_CMD_RXEN, 1);176176- if (ret < 0)175175+ ret = fe->callback(client->adapter,176176+ DVB_FRONTEND_COMPONENT_TUNER,177177+ TUA9001_CMD_RXEN, 1);178178+ if (ret)177179 goto err;178180 }181181+ return 0;179182err:180180- if (ret < 0)181181- dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);182182-183183+ dev_dbg(&client->dev, "failed=%d\n", ret);183184 return ret;184185}185186186187static int tua9001_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)187188{188188- struct tua9001_priv *priv = fe->tuner_priv;189189+ struct tua9001_dev *dev = fe->tuner_priv;190190+ struct i2c_client *client = dev->client;189191190190- dev_dbg(&priv->i2c->dev, "%s:\n", __func__);192192+ dev_dbg(&client->dev, "\n");191193192194 *frequency = 0; /* Zero-IF */193193-194195 return 0;195196}196197197198static const struct dvb_tuner_ops tua9001_tuner_ops = {198199 .info = {199199- .name = "Infineon TUA 9001",200200-200200+ .name = "Infineon TUA9001",201201 .frequency_min = 170000000,202202 .frequency_max = 862000000,203203- .frequency_step = 0,204203 },205204206205 .init = tua9001_init,···212213static int tua9001_probe(struct i2c_client *client,213214 const struct i2c_device_id *id)214215{215215- struct tua9001_priv *dev;216216+ struct tua9001_dev *dev;216217 struct tua9001_platform_data *pdata = client->dev.platform_data;217218 struct dvb_frontend *fe = pdata->dvb_frontend;218219 int ret;···224225 }225226226227 dev->client = client;227227- dev->i2c_addr = client->addr;228228- dev->i2c = client->adapter;229228 dev->fe = pdata->dvb_frontend;230229231230 if (fe->callback) {···251254 sizeof(struct dvb_tuner_ops));252255 i2c_set_clientdata(client, dev);253256254254- dev_info(&client->dev, "Infineon TUA 9001 successfully attached\n");257257+ dev_info(&client->dev, "Infineon TUA9001 successfully attached\n");255258 return 0;256259err_kfree:257260 kfree(dev);···262265263266static int tua9001_remove(struct i2c_client *client)264267{265265- struct tua9001_priv *dev = i2c_get_clientdata(client);268268+ struct tua9001_dev *dev = i2c_get_clientdata(client);266269 struct dvb_frontend *fe = dev->fe;267270 int ret;268271···302305303306module_i2c_driver(tua9001_driver);304307305305-MODULE_DESCRIPTION("Infineon TUA 9001 silicon tuner driver");308308+MODULE_DESCRIPTION("Infineon TUA9001 silicon tuner driver");306309MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");307310MODULE_LICENSE("GPL");
+1-5
drivers/media/tuners/tua9001.h
···11/*22- * Infineon TUA 9001 silicon tuner driver22+ * Infineon TUA9001 silicon tuner driver33 *44 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>55 *···1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414 * GNU General Public License for more details.1515- *1616- * You should have received a copy of the GNU General Public License along1717- * with this program; if not, write to the Free Software Foundation, Inc.,1818- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.1915 */20162117#ifndef TUA9001_H
+6-10
drivers/media/tuners/tua9001_priv.h
···11/*22- * Infineon TUA 9001 silicon tuner driver22+ * Infineon TUA9001 silicon tuner driver33 *44 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>55 *···1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414 * GNU General Public License for more details.1515- *1616- * You should have received a copy of the GNU General Public License along1717- * with this program; if not, write to the Free Software Foundation, Inc.,1818- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.1915 */20162117#ifndef TUA9001_PRIV_H2218#define TUA9001_PRIV_H23192424-struct reg_val {2020+#include "tua9001.h"2121+2222+struct tua9001_reg_val {2523 u8 reg;2624 u16 val;2725};28262929-struct tua9001_priv {3030- struct i2c_client *client;3131- struct i2c_adapter *i2c;3232- u8 i2c_addr;2727+struct tua9001_dev {3328 struct dvb_frontend *fe;2929+ struct i2c_client *client;3430};35313632#endif