Re: [cx231xx 1/2] Added support for s5h1432 demod
Em 10-06-2010 01:25, Palash Bandyopadhyay escreveu: > From 53df9742b92902b5fa9d28b2dcc949cb495725a5 Mon Sep 17 00:00:00 2001 > Message-Id: > <53df9742b92902b5fa9d28b2dcc949cb495725a5.1276143429.git.palash.bandyopadh...@conexant.com> > From: palash > Date: Wed, 9 Jun 2010 21:13:17 -0700 > Subject: [cx231xx 1/2] Added support for s5h1432 demod > To: linux-media@vger.kernel.org > > Signed-off-by: palash There are lots of CodingStyle issues that need fixes. Even fixing the bad whitespacing with a script, there are still lots of other issues, as pointed by scripts/checkpatch.pl: WARNING: please write a paragraph that describes the config symbol fully #60: FILE: drivers/media/dvb/frontends/Kconfig:264: + help WARNING: suspect code indent for conditional statements (7, 15) #130: FILE: drivers/media/dvb/frontends/s5h1432.c:52: + if (debug) \ + printk(arg);\ WARNING: suspect code indent for conditional statements (7, 15) #145: FILE: drivers/media/dvb/frontends/s5h1432.c:67: + if (ret != 1) + printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, " WARNING: suspect code indent for conditional statements (7, 15) #164: FILE: drivers/media/dvb/frontends/s5h1432.c:86: + if (ret != 2) + printk(KERN_ERR "%s: readreg error (ret == %i)\n", WARNING: unnecessary whitespace before a quoted newline #256: FILE: drivers/media/dvb/frontends/s5h1432.c:178: + printk(KERN_INFO "Default IFFreq %d :reg value = 0x%x \n", WARNING: suspect code indent for conditional statements (7, 15) #279: FILE: drivers/media/dvb/frontends/s5h1432.c:201: + if (p->frequency == state->current_frequency) { + /*current_frequency = p->frequency;*/ WARNING: suspect code indent for conditional statements (7, 15) #396: FILE: drivers/media/dvb/frontends/s5h1432.c:318: + for (i = 0; i < 0xFF; i++) { + reg = s5h1432_readreg(state, S5H1432_I2C_TOP_ADDR, i); WARNING: suspect code indent for conditional statements (7, 15) #463: FILE: drivers/media/dvb/frontends/s5h1432.c:385: + if (state == NULL) + goto error; total: 0 errors, 8 warnings, 562 lines checked patches/lmml_108408_cx231xx_1_2_added_support_for_s5h1432_demod.patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. Please fix. Cheers, Mauro -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
FW: [cx231xx 1/2] Added support for s5h1432 demod
>From 53df9742b92902b5fa9d28b2dcc949cb495725a5 Mon Sep 17 00:00:00 2001 Message-Id: <53df9742b92902b5fa9d28b2dcc949cb495725a5.1276143429.git.palash.bandyopadh...@conexant.com> From: palash Date: Wed, 9 Jun 2010 21:13:17 -0700 Subject: [cx231xx 1/2] Added support for s5h1432 demod To: linux-media@vger.kernel.org Signed-off-by: palash create mode 100644 drivers/media/dvb/frontends/s5h1432.c create mode 100644 drivers/media/dvb/frontends/s5h1432.h diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index cd7f9b7..257c2fa 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -257,6 +257,13 @@ config DVB_CX22702 help A DVB-T tuner module. Say Y when you want to support this frontend. +config DVB_S5H1432 + tristate "Samsung s5h1432 demodulator (OFDM)" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A DVB-T tuner module. Say Y when you want to support this frontend. + config DVB_DRX397XD tristate "Micronas DRX3975D/DRX3977D based" depends on DVB_CORE && I2C diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 874e8ad..faaa9aa 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_DVB_STB0899) += stb0899.o obj-$(CONFIG_DVB_STB6100) += stb6100.o obj-$(CONFIG_DVB_SP8870) += sp8870.o obj-$(CONFIG_DVB_CX22700) += cx22700.o +obj-$(CONFIG_DVB_S5H1432) += s5h1432.o obj-$(CONFIG_DVB_CX24110) += cx24110.o obj-$(CONFIG_DVB_TDA8083) += tda8083.o obj-$(CONFIG_DVB_L64781) += l64781.o diff --git a/drivers/media/dvb/frontends/s5h1432.c b/drivers/media/dvb/frontends/s5h1432.c new file mode 100644 index 000..92d134e --- /dev/null +++ b/drivers/media/dvb/frontends/s5h1432.c @@ -0,0 +1,446 @@ +/* +Samsung s5h1432 DVB-T demodulator driver + +Copyright (C) 2009 Bill Liu + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include +#include +#include +#include +#include "dvb_frontend.h" +#include "s5h1432.h" + +struct s5h1432_state { + + struct i2c_adapter *i2c; + + /* configuration settings */ + const struct s5h1432_config *config; + + struct dvb_frontend frontend; + + fe_modulation_t current_modulation; + unsigned int first_tune:1; + + u32 current_frequency; + int if_freq; + + u8 inversion; +}; + +static int debug; + +#define dprintk(arg...) do { \ + if (debug) \ + printk(arg);\ + } while (0) + + +static int s5h1432_writereg(struct s5h1432_state *state, + u8 addr, u8 reg, u8 data) +{ + int ret; + u8 buf[] = { reg, data }; + + struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 }; + + ret = i2c_transfer(state->i2c, &msg, 1); + + if (ret != 1) + printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, " + "ret == %i)\n", __func__, addr, reg, data, ret); + + return (ret != 1) ? -1 : 0; +} + +static u8 s5h1432_readreg(struct s5h1432_state *state, u8 addr, u8 reg) +{ + int ret; + u8 b0[] = { reg }; + u8 b1[] = { 0 }; + + struct i2c_msg msg[] = { + { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, + { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; + + ret = i2c_transfer(state->i2c, msg, 2); + + if (ret != 2) + printk(KERN_ERR "%s: readreg error (ret == %i)\n", + __func__, ret); + return b1[0]; +} + +static int s5h1432_sleep(struct dvb_frontend *fe) +{ + return 0; +} + +static int s5h1432_set_channel_bandwidth(struct dvb_frontend *fe, u32 bandwidth) +{ + + struct s5h1432_state *state = fe->demodulator_priv; + + u8 reg = 0; + + +/* Register[0x2E] bit 3:2 : 8MHz = 0; 7MHz = 1; 6MHz = 2*/ + reg = s5h1432_readreg(state, S5H1432_I2C_TOP_ADDR, 0x2E); + reg &= ~(0x0C); + switch (bandwidth) { + case 6: + reg |= 0x08; + break; + case 7: +
[cx231xx 1/2] Added support for s5h1432 demod
>From 53df9742b92902b5fa9d28b2dcc949cb495725a5 Mon Sep 17 00:00:00 2001 Message-Id: <53df9742b92902b5fa9d28b2dcc949cb495725a5.1276143429.git.palash.bandyopadh...@conexant.com> From: palash Date: Wed, 9 Jun 2010 21:13:17 -0700 Subject: [cx231xx 1/2] Added support for s5h1432 demod To: linux-media@vger.kernel.org Signed-off-by: palash create mode 100644 drivers/media/dvb/frontends/s5h1432.c create mode 100644 drivers/media/dvb/frontends/s5h1432.h diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index cd7f9b7..257c2fa 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -257,6 +257,13 @@ config DVB_CX22702 help A DVB-T tuner module. Say Y when you want to support this frontend. +config DVB_S5H1432 + tristate "Samsung s5h1432 demodulator (OFDM)" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A DVB-T tuner module. Say Y when you want to support this frontend. + config DVB_DRX397XD tristate "Micronas DRX3975D/DRX3977D based" depends on DVB_CORE && I2C diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 874e8ad..faaa9aa 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_DVB_STB0899) += stb0899.o obj-$(CONFIG_DVB_STB6100) += stb6100.o obj-$(CONFIG_DVB_SP8870) += sp8870.o obj-$(CONFIG_DVB_CX22700) += cx22700.o +obj-$(CONFIG_DVB_S5H1432) += s5h1432.o obj-$(CONFIG_DVB_CX24110) += cx24110.o obj-$(CONFIG_DVB_TDA8083) += tda8083.o obj-$(CONFIG_DVB_L64781) += l64781.o diff --git a/drivers/media/dvb/frontends/s5h1432.c b/drivers/media/dvb/frontends/s5h1432.c new file mode 100644 index 000..92d134e --- /dev/null +++ b/drivers/media/dvb/frontends/s5h1432.c @@ -0,0 +1,446 @@ +/* +Samsung s5h1432 DVB-T demodulator driver + +Copyright (C) 2009 Bill Liu + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include +#include +#include +#include +#include "dvb_frontend.h" +#include "s5h1432.h" + +struct s5h1432_state { + + struct i2c_adapter *i2c; + + /* configuration settings */ + const struct s5h1432_config *config; + + struct dvb_frontend frontend; + + fe_modulation_t current_modulation; + unsigned int first_tune:1; + + u32 current_frequency; + int if_freq; + + u8 inversion; +}; + +static int debug; + +#define dprintk(arg...) do { \ + if (debug) \ + printk(arg);\ + } while (0) + + +static int s5h1432_writereg(struct s5h1432_state *state, + u8 addr, u8 reg, u8 data) +{ + int ret; + u8 buf[] = { reg, data }; + + struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 }; + + ret = i2c_transfer(state->i2c, &msg, 1); + + if (ret != 1) + printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, " + "ret == %i)\n", __func__, addr, reg, data, ret); + + return (ret != 1) ? -1 : 0; +} + +static u8 s5h1432_readreg(struct s5h1432_state *state, u8 addr, u8 reg) +{ + int ret; + u8 b0[] = { reg }; + u8 b1[] = { 0 }; + + struct i2c_msg msg[] = { + { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, + { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; + + ret = i2c_transfer(state->i2c, msg, 2); + + if (ret != 2) + printk(KERN_ERR "%s: readreg error (ret == %i)\n", + __func__, ret); + return b1[0]; +} + +static int s5h1432_sleep(struct dvb_frontend *fe) +{ + return 0; +} + +static int s5h1432_set_channel_bandwidth(struct dvb_frontend *fe, u32 bandwidth) +{ + + struct s5h1432_state *state = fe->demodulator_priv; + + u8 reg = 0; + + +/* Register[0x2E] bit 3:2 : 8MHz = 0; 7MHz = 1; 6MHz = 2*/ + reg = s5h1432_readreg(state, S5H1432_I2C_TOP_ADDR, 0x2E); + reg &= ~(0x0C); + switch (bandwidth) { + case 6: + reg |= 0x08; + break; + case 7: +