hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/dvb-frontends/lgdt3306a.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Support for LGDT3306A - 8VSB/QAM-B
34 *
45 * Copyright (C) 2013 Fred Richter <frichter@hauppauge.com>
56 * - driver structure based on lgdt3305.[ch] by Michael Krufky
67 * - code based on LG3306_V0.35 API by LG Electronics Inc.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
178 */
189
1910 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -777,7 +768,7 @@
777768 default:
778769 pr_warn("IF=%d KHz is not supported, 3250 assumed\n",
779770 if_freq_khz);
780
- /* fallthrough */
771
+ fallthrough;
781772 case 3250: /* 3.25Mhz */
782773 nco1 = 0x34;
783774 nco2 = 0x00;
....@@ -855,6 +846,7 @@
855846 static int lgdt3306a_init(struct dvb_frontend *fe)
856847 {
857848 struct lgdt3306a_state *state = fe->demodulator_priv;
849
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
858850 u8 val;
859851 int ret;
860852
....@@ -1005,6 +997,9 @@
1005997 /* 15. Sleep (in reset) */
1006998 ret = lgdt3306a_sleep(state);
1007999 lg_chkerr(ret);
1000
+
1001
+ c->cnr.len = 1;
1002
+ c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10081003
10091004 fail:
10101005 return ret;
....@@ -1606,6 +1601,7 @@
16061601 enum fe_status *status)
16071602 {
16081603 struct lgdt3306a_state *state = fe->demodulator_priv;
1604
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
16091605 u16 strength = 0;
16101606 int ret = 0;
16111607
....@@ -1646,6 +1642,15 @@
16461642 default:
16471643 ret = -EINVAL;
16481644 }
1645
+
1646
+ if (*status & FE_HAS_SYNC) {
1647
+ c->cnr.len = 1;
1648
+ c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
1649
+ c->cnr.stat[0].svalue = lgdt3306a_calculate_snr_x100(state) * 10;
1650
+ } else {
1651
+ c->cnr.len = 1;
1652
+ c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1653
+ }
16491654 }
16501655 return ret;
16511656 }
....@@ -1685,7 +1690,10 @@
16851690 case QAM_256:
16861691 case QAM_AUTO:
16871692 /* need to know actual modulation to set proper SNR baseline */
1688
- lgdt3306a_read_reg(state, 0x00a6, &val);
1693
+ ret = lgdt3306a_read_reg(state, 0x00a6, &val);
1694
+ if (lg_chkerr(ret))
1695
+ goto fail;
1696
+
16891697 if(val & 0x04)
16901698 ref_snr = 2800; /* QAM-256 28dB */
16911699 else
....@@ -1887,7 +1895,7 @@
18871895 kfree(state);
18881896 return NULL;
18891897 }
1890
-EXPORT_SYMBOL(lgdt3306a_attach);
1898
+EXPORT_SYMBOL_GPL(lgdt3306a_attach);
18911899
18921900 #ifdef DBG_DUMP
18931901
....@@ -2205,14 +2213,12 @@
22052213 struct dvb_frontend *fe;
22062214 int ret;
22072215
2208
- config = kzalloc(sizeof(struct lgdt3306a_config), GFP_KERNEL);
2216
+ config = kmemdup(client->dev.platform_data,
2217
+ sizeof(struct lgdt3306a_config), GFP_KERNEL);
22092218 if (config == NULL) {
22102219 ret = -ENOMEM;
22112220 goto fail;
22122221 }
2213
-
2214
- memcpy(config, client->dev.platform_data,
2215
- sizeof(struct lgdt3306a_config));
22162222
22172223 config->i2c_addr = client->addr;
22182224 fe = lgdt3306a_attach(config, client->adapter);