.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Support for LGDT3306A - 8VSB/QAM-B |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2013 Fred Richter <frichter@hauppauge.com> |
---|
5 | 6 | * - driver structure based on lgdt3305.[ch] by Michael Krufky |
---|
6 | 7 | * - 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. |
---|
17 | 8 | */ |
---|
18 | 9 | |
---|
19 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
777 | 768 | default: |
---|
778 | 769 | pr_warn("IF=%d KHz is not supported, 3250 assumed\n", |
---|
779 | 770 | if_freq_khz); |
---|
780 | | - /* fallthrough */ |
---|
| 771 | + fallthrough; |
---|
781 | 772 | case 3250: /* 3.25Mhz */ |
---|
782 | 773 | nco1 = 0x34; |
---|
783 | 774 | nco2 = 0x00; |
---|
.. | .. |
---|
855 | 846 | static int lgdt3306a_init(struct dvb_frontend *fe) |
---|
856 | 847 | { |
---|
857 | 848 | struct lgdt3306a_state *state = fe->demodulator_priv; |
---|
| 849 | + struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
---|
858 | 850 | u8 val; |
---|
859 | 851 | int ret; |
---|
860 | 852 | |
---|
.. | .. |
---|
1005 | 997 | /* 15. Sleep (in reset) */ |
---|
1006 | 998 | ret = lgdt3306a_sleep(state); |
---|
1007 | 999 | lg_chkerr(ret); |
---|
| 1000 | + |
---|
| 1001 | + c->cnr.len = 1; |
---|
| 1002 | + c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
---|
1008 | 1003 | |
---|
1009 | 1004 | fail: |
---|
1010 | 1005 | return ret; |
---|
.. | .. |
---|
1606 | 1601 | enum fe_status *status) |
---|
1607 | 1602 | { |
---|
1608 | 1603 | struct lgdt3306a_state *state = fe->demodulator_priv; |
---|
| 1604 | + struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
---|
1609 | 1605 | u16 strength = 0; |
---|
1610 | 1606 | int ret = 0; |
---|
1611 | 1607 | |
---|
.. | .. |
---|
1646 | 1642 | default: |
---|
1647 | 1643 | ret = -EINVAL; |
---|
1648 | 1644 | } |
---|
| 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 | + } |
---|
1649 | 1654 | } |
---|
1650 | 1655 | return ret; |
---|
1651 | 1656 | } |
---|
.. | .. |
---|
1685 | 1690 | case QAM_256: |
---|
1686 | 1691 | case QAM_AUTO: |
---|
1687 | 1692 | /* 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 | + |
---|
1689 | 1697 | if(val & 0x04) |
---|
1690 | 1698 | ref_snr = 2800; /* QAM-256 28dB */ |
---|
1691 | 1699 | else |
---|
.. | .. |
---|
1887 | 1895 | kfree(state); |
---|
1888 | 1896 | return NULL; |
---|
1889 | 1897 | } |
---|
1890 | | -EXPORT_SYMBOL(lgdt3306a_attach); |
---|
| 1898 | +EXPORT_SYMBOL_GPL(lgdt3306a_attach); |
---|
1891 | 1899 | |
---|
1892 | 1900 | #ifdef DBG_DUMP |
---|
1893 | 1901 | |
---|
.. | .. |
---|
2205 | 2213 | struct dvb_frontend *fe; |
---|
2206 | 2214 | int ret; |
---|
2207 | 2215 | |
---|
2208 | | - config = kzalloc(sizeof(struct lgdt3306a_config), GFP_KERNEL); |
---|
| 2216 | + config = kmemdup(client->dev.platform_data, |
---|
| 2217 | + sizeof(struct lgdt3306a_config), GFP_KERNEL); |
---|
2209 | 2218 | if (config == NULL) { |
---|
2210 | 2219 | ret = -ENOMEM; |
---|
2211 | 2220 | goto fail; |
---|
2212 | 2221 | } |
---|
2213 | | - |
---|
2214 | | - memcpy(config, client->dev.platform_data, |
---|
2215 | | - sizeof(struct lgdt3306a_config)); |
---|
2216 | 2222 | |
---|
2217 | 2223 | config->i2c_addr = client->addr; |
---|
2218 | 2224 | fe = lgdt3306a_attach(config, client->adapter); |
---|