Re: [PATCH] media: dvb-frontends: add Socionext SC1501A ISDB-S/T demodulator driver
Hi Katsuhiro, I love your patch! Yet something to improve: [auto build test ERROR on linuxtv-media/master] [also build test ERROR on v4.17-rc5 next-20180514] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Katsuhiro-Suzuki/media-dvb-frontends-add-Socionext-SC1501A-ISDB-S-T-demodulator-driver/20180515-091453 base: git://linuxtv.org/media_tree.git master config: i386-allyesconfig (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/media/dvb-frontends/sc1501a.o: In function `sc1501a_set_frontend': >> sc1501a.c:(.text+0xbe0): undefined reference to `__divdi3' sc1501a.c:(.text+0xc01): undefined reference to `__divdi3' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH] media: dvb-frontends: add Socionext SC1501A ISDB-S/T demodulator driver
Hi Katsuhiro, I love your patch! Perhaps something to improve: [auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.17-rc5 next-20180514] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Katsuhiro-Suzuki/media-dvb-frontends-add-Socionext-SC1501A-ISDB-S-T-demodulator-driver/20180515-091453 base: git://linuxtv.org/media_tree.git master reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) >> drivers/media/dvb-frontends/sc1501a.c:313:47: sparse: constant 211243671486 >> is so big it is long vim +313 drivers/media/dvb-frontends/sc1501a.c 258 259 static int sc1501a_s_read_status(struct sc1501a_priv *chip, 260 struct dtv_frontend_properties *c, 261 enum fe_status *status) 262 { 263 struct regmap *r_s = chip->regmap_s; 264 u32 cpmon, tmpu, tmpl, flg; 265 u64 tmp; 266 267 /* Sync detection */ 268 regmap_read(r_s, CPMON1_S, &cpmon); 269 270 *status = 0; 271 if (cpmon & CPMON1_S_FSYNC) 272 *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; 273 if (cpmon & CPMON1_S_W2LOCK) 274 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER; 275 276 /* Signal strength */ 277 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 278 279 if (*status & FE_HAS_SIGNAL) { 280 u32 agc; 281 282 regmap_read(r_s, AGCREAD_S, &tmpu); 283 agc = tmpu << 8; 284 285 c->strength.len = 1; 286 c->strength.stat[0].scale = FE_SCALE_RELATIVE; 287 c->strength.stat[0].uvalue = agc; 288 } 289 290 /* C/N rate */ 291 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 292 293 if (*status & FE_HAS_VITERBI) { 294 u32 cnr = 0, x, y, d; 295 u64 d_3 = 0; 296 297 regmap_read(r_s, CNRDXU_S, &tmpu); 298 regmap_read(r_s, CNRDXL_S, &tmpl); 299 x = (tmpu << 8) | tmpl; 300 regmap_read(r_s, CNRDYU_S, &tmpu); 301 regmap_read(r_s, CNRDYL_S, &tmpl); 302 y = (tmpu << 8) | tmpl; 303 304 /* CNR[dB]: 10 * log10(D) - 30.74 / D^3 - 3 */ 305 /* D = x^2 / (2^15 * y - x^2) */ 306 d = (y << 15) - x * x; 307 if (d > 0) { 308 /* (2^4 * D)^3 = 2^12 * D^3 */ 309 /* 3.074 * 2^(12 + 24) = 211243671486 */ 310 d_3 = div_u64(16 * x * x, d); 311 d_3 = d_3 * d_3 * d_3; 312 if (d_3) > 313 d_3 = div_u64(211243671486, d_3); 314 } 315 316 if (d_3) { 317 /* 0.3 * 2^24 = 5033164 */ 318 tmp = (s64)2 * intlog10(x) - intlog10(abs(d)) - d_3 319 - 5033164; 320 cnr = div_u64(tmp * 1, 1 << 24); 321 } 322 323 if (cnr) { 324 c->cnr.len = 1; 325 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; 326 c->cnr.stat[0].uvalue = cnr; 327 } 328 } 329 330 /* BER */ 331 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 332 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 333 334 regmap_read(r_s, BERCNFLG_S, &flg); 335 336 if ((*status & FE_HAS_VITERBI) && (flg & BERCNFLG_S_BERVRDY)) { 337 u32 bit_err, bit_cnt; 338 339 regmap_read(r_s, BERVRDU_S, &tmpu); 340 regmap_read(r_s, BERVRDL_S, &tmpl); 341 bit_err = (tmpu << 8) | tmpl; 342 bit_cnt = (1 << 13) * 204; 343 344 if (bit_cnt) { 345 c->post_bit_error.len = 1; 346 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; 347 c->post_bit_error.stat[0].uvalue = bit_err; 348 c->post_bit_count.len = 1; 349 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; 350 c->post_bit_count.stat[0].uvalue = bit_cnt; 351 } 352 } 353 354
[PATCH] media: dvb-frontends: add Socionext SC1501A ISDB-S/T demodulator driver
This patch adds a frontend driver for the Socionext SC1501A series and Socionext MN88443x ISDB-S/T demodulators. Signed-off-by: Katsuhiro Suzuki --- drivers/media/dvb-frontends/Kconfig | 10 + drivers/media/dvb-frontends/Makefile | 1 + drivers/media/dvb-frontends/sc1501a.c | 802 ++ drivers/media/dvb-frontends/sc1501a.h | 27 + 4 files changed, 840 insertions(+) create mode 100644 drivers/media/dvb-frontends/sc1501a.c create mode 100644 drivers/media/dvb-frontends/sc1501a.h diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig index 55e36a4f5215..e9d2c94b290e 100644 --- a/drivers/media/dvb-frontends/Kconfig +++ b/drivers/media/dvb-frontends/Kconfig @@ -739,6 +739,16 @@ config DVB_TC90522 Toshiba TC90522 2xISDB-S 8PSK + 2xISDB-T OFDM demodulator. Say Y when you want to support this frontend. +config DVB_SC1501A + tristate "Socionext SC1501A" + depends on DVB_CORE && I2C + select REGMAP_I2C + default m if !MEDIA_SUBDRV_AUTOSELECT + help + A driver for Socionext SC1501A, MN884433 and MN884434 + ISDB-S + ISDB-T demodulator. + Say Y when you want to support this frontend. + comment "Digital terrestrial only tuners/PLL" depends on DVB_CORE diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile index 67a783fd5ed0..e204502347ed 100644 --- a/drivers/media/dvb-frontends/Makefile +++ b/drivers/media/dvb-frontends/Makefile @@ -125,6 +125,7 @@ obj-$(CONFIG_DVB_AF9033) += af9033.o obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o obj-$(CONFIG_DVB_GP8PSK_FE) += gp8psk-fe.o obj-$(CONFIG_DVB_TC90522) += tc90522.o +obj-$(CONFIG_DVB_SC1501A) += sc1501a.o obj-$(CONFIG_DVB_HORUS3A) += horus3a.o obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o obj-$(CONFIG_DVB_HELENE) += helene.o diff --git a/drivers/media/dvb-frontends/sc1501a.c b/drivers/media/dvb-frontends/sc1501a.c new file mode 100644 index ..6460d7f95b35 --- /dev/null +++ b/drivers/media/dvb-frontends/sc1501a.c @@ -0,0 +1,802 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext SC1501A series demodulator driver for ISDB-S/ISDB-T. +// +// Copyright (c) 2018 Socionext Inc. + +#include +#include +#include +#include +#include +#include +#include + +#include "sc1501a.h" + +/* ISDB-S registers */ +#define ATSIDU_S0x2f +#define ATSIDL_S0x30 +#define TSSET_S 0x31 +#define AGCREAD_S 0x5a +#define CPMON1_S0x5e +#define CPMON1_S_FSYNC BIT(5) +#define CPMON1_S_ERRMON BIT(4) +#define CPMON1_S_SIGOFF BIT(3) +#define CPMON1_S_W2LOCK BIT(2) +#define CPMON1_S_W1LOCK BIT(1) +#define CPMON1_S_DW1LOCKBIT(0) +#define TRMON_S 0x60 +#define BERCNFLG_S 0x68 +#define BERCNFLG_S_BERVRDY BIT(5) +#define BERCNFLG_S_BERVCHK BIT(4) +#define BERCNFLG_S_BERDRDY BIT(3) +#define BERCNFLG_S_BERDCHK BIT(2) +#define CNRDXU_S0x69 +#define CNRDXL_S0x6a +#define CNRDYU_S0x6b +#define CNRDYL_S0x6c +#define BERVRDU_S 0x71 +#define BERVRDL_S 0x72 +#define DOSET1_S0x73 + +/* Primary ISDB-T */ +#define PLLASET10x00 +#define PLLASET20x01 +#define PLLBSET10x02 +#define PLLBSET20x03 +#define PLLSET 0x04 +#define OUTCSET 0x08 +#define OUTCSET_CHDRV_8MA 0xff +#define OUTCSET_CHDRV_4MA 0x00 +#define PLDWSET 0x09 +#define PLDWSET_NORMAL 0x00 +#define PLDWSET_PULLDOWN 0xff +#define HIZSET1 0x0a +#define HIZSET2 0x0b + +/* Secondary ISDB-T (for MN884434 only) */ +#define RCVSET 0x00 +#define TSSET1_M0x01 +#define TSSET2_M0x02 +#define TSSET3_M0x03 +#define INTACSET0x08 +#define HIZSET3 0x0b + +/* ISDB-T registe