Loading drivers/media/dvb-frontends/cxd2880/Kconfig +2 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0 config DVB_CXD2880 tristate "Sony CXD2880 DVB-T2/T tuner + demodulator" depends on DVB_CORE && SPI Loading drivers/media/dvb-frontends/cxd2880/Makefile +2 −4 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0 cxd2880-objs := cxd2880_common.o \ cxd2880_devio_spi.o \ cxd2880_integ.o \ cxd2880_integ_dvbt2.o \ cxd2880_integ_dvbt.o \ cxd2880_io.o \ cxd2880_spi_device.o \ cxd2880_stopwatch_port.o \ cxd2880_tnrdmd.o \ cxd2880_tnrdmd_dvbt2.o \ cxd2880_tnrdmd_dvbt2_mon.o \ cxd2880_tnrdmd_dvbt.o \ cxd2880_tnrdmd_dvbt_mon.o\ cxd2880_tnrdmd_mon.o\ cxd2880_math.o \ cxd2880_top.o obj-$(CONFIG_DVB_CXD2880) += cxd2880.o Loading drivers/media/dvb-frontends/cxd2880/cxd2880.h +2 −19 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * cxd2880.h * Sony CXD2880 DVB-T2/T tuner + demodulator driver public definitions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #ifndef CXD2880_H Loading drivers/media/dvb-frontends/cxd2880/cxd2880_common.c +5 −68 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * cxd2880_common.c * Sony CXD2880 DVB-T2/T tuner + demodulator driver * common functions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #include "cxd2880_common.h" #define MASKUPPER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU << (32 - (n)))) #define MASKLOWER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU >> (32 - (n)))) int cxd2880_convert2s_complement(u32 value, u32 bitlen) { if ((bitlen == 0) || (bitlen >= 32)) if (!bitlen || bitlen >= 32) return (int)value; if (value & (u32)(1 << (bitlen - 1))) return (int)(MASKUPPER(32 - bitlen) | value); return (int)(GENMASK(31, bitlen) | value); else return (int)(MASKLOWER(bitlen) & value); } u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num) { u32 value = 0; u8 *array_read; u8 bit_read; u32 len_remain; if (!array) return 0; if ((bit_num == 0) || (bit_num > 32)) return 0; array_read = array + (start_bit / 8); bit_read = (u8)(start_bit % 8); len_remain = bit_num; if (bit_read != 0) { if (((int)len_remain) <= 8 - bit_read) { value = (*array_read) >> ((8 - bit_read) - len_remain); len_remain = 0; } else { value = *array_read++; len_remain -= 8 - bit_read; } } while (len_remain > 0) { if (len_remain < 8) { value <<= len_remain; value |= (*array_read++ >> (8 - len_remain)); len_remain = 0; } else { value <<= 8; value |= (u32)(*array_read++); len_remain -= 8; } } value &= MASKLOWER(bit_num); return value; return (int)(GENMASK(bitlen - 1, 0) & value); } drivers/media/dvb-frontends/cxd2880/cxd2880_common.h +4 −71 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * cxd2880_common.h * Sony CXD2880 DVB-T2/T tuner + demodulator driver common definitions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #ifndef CXD2880_COMMON_H #define CXD2880_COMMON_H #include <linux/types.h> #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #include <linux/errno.h> #include <linux/delay.h> #define CXD2880_SLEEP(n) msleep(n) #ifndef CXD2880_SLEEP_IN_MON #define CXD2880_SLEEP_IN_MON(n, obj) CXD2880_SLEEP(n) #endif #define CXD2880_ARG_UNUSED(arg) ((void)(arg)) enum cxd2880_ret { CXD2880_RESULT_OK, CXD2880_RESULT_ERROR_ARG, CXD2880_RESULT_ERROR_IO, CXD2880_RESULT_ERROR_SW_STATE, CXD2880_RESULT_ERROR_HW_STATE, CXD2880_RESULT_ERROR_TIMEOUT, CXD2880_RESULT_ERROR_UNLOCK, CXD2880_RESULT_ERROR_RANGE, CXD2880_RESULT_ERROR_NOSUPPORT, CXD2880_RESULT_ERROR_CANCEL, CXD2880_RESULT_ERROR_OTHER, CXD2880_RESULT_ERROR_OVERFLOW, CXD2880_RESULT_OK_CONFIRM }; #include <linux/string.h> int cxd2880_convert2s_complement(u32 value, u32 bitlen); u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num); struct cxd2880_atomic { int counter; }; #define cxd2880_atomic_set(a, i) ((a)->counter = i) #define cxd2880_atomic_read(a) ((a)->counter) struct cxd2880_stopwatch { u32 start_time; }; enum cxd2880_ret cxd2880_stopwatch_start(struct cxd2880_stopwatch *stopwatch); enum cxd2880_ret cxd2880_stopwatch_sleep(struct cxd2880_stopwatch *stopwatch, u32 ms); enum cxd2880_ret cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch *stopwatch, u32 *elapsed); #endif Loading
drivers/media/dvb-frontends/cxd2880/Kconfig +2 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0 config DVB_CXD2880 tristate "Sony CXD2880 DVB-T2/T tuner + demodulator" depends on DVB_CORE && SPI Loading
drivers/media/dvb-frontends/cxd2880/Makefile +2 −4 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0 cxd2880-objs := cxd2880_common.o \ cxd2880_devio_spi.o \ cxd2880_integ.o \ cxd2880_integ_dvbt2.o \ cxd2880_integ_dvbt.o \ cxd2880_io.o \ cxd2880_spi_device.o \ cxd2880_stopwatch_port.o \ cxd2880_tnrdmd.o \ cxd2880_tnrdmd_dvbt2.o \ cxd2880_tnrdmd_dvbt2_mon.o \ cxd2880_tnrdmd_dvbt.o \ cxd2880_tnrdmd_dvbt_mon.o\ cxd2880_tnrdmd_mon.o\ cxd2880_math.o \ cxd2880_top.o obj-$(CONFIG_DVB_CXD2880) += cxd2880.o Loading
drivers/media/dvb-frontends/cxd2880/cxd2880.h +2 −19 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * cxd2880.h * Sony CXD2880 DVB-T2/T tuner + demodulator driver public definitions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #ifndef CXD2880_H Loading
drivers/media/dvb-frontends/cxd2880/cxd2880_common.c +5 −68 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * cxd2880_common.c * Sony CXD2880 DVB-T2/T tuner + demodulator driver * common functions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #include "cxd2880_common.h" #define MASKUPPER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU << (32 - (n)))) #define MASKLOWER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU >> (32 - (n)))) int cxd2880_convert2s_complement(u32 value, u32 bitlen) { if ((bitlen == 0) || (bitlen >= 32)) if (!bitlen || bitlen >= 32) return (int)value; if (value & (u32)(1 << (bitlen - 1))) return (int)(MASKUPPER(32 - bitlen) | value); return (int)(GENMASK(31, bitlen) | value); else return (int)(MASKLOWER(bitlen) & value); } u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num) { u32 value = 0; u8 *array_read; u8 bit_read; u32 len_remain; if (!array) return 0; if ((bit_num == 0) || (bit_num > 32)) return 0; array_read = array + (start_bit / 8); bit_read = (u8)(start_bit % 8); len_remain = bit_num; if (bit_read != 0) { if (((int)len_remain) <= 8 - bit_read) { value = (*array_read) >> ((8 - bit_read) - len_remain); len_remain = 0; } else { value = *array_read++; len_remain -= 8 - bit_read; } } while (len_remain > 0) { if (len_remain < 8) { value <<= len_remain; value |= (*array_read++ >> (8 - len_remain)); len_remain = 0; } else { value <<= 8; value |= (u32)(*array_read++); len_remain -= 8; } } value &= MASKLOWER(bit_num); return value; return (int)(GENMASK(bitlen - 1, 0) & value); }
drivers/media/dvb-frontends/cxd2880/cxd2880_common.h +4 −71 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* * cxd2880_common.h * Sony CXD2880 DVB-T2/T tuner + demodulator driver common definitions * * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation * * 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; version 2 of the License. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, see <http://www.gnu.org/licenses/>. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation */ #ifndef CXD2880_COMMON_H #define CXD2880_COMMON_H #include <linux/types.h> #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #include <linux/errno.h> #include <linux/delay.h> #define CXD2880_SLEEP(n) msleep(n) #ifndef CXD2880_SLEEP_IN_MON #define CXD2880_SLEEP_IN_MON(n, obj) CXD2880_SLEEP(n) #endif #define CXD2880_ARG_UNUSED(arg) ((void)(arg)) enum cxd2880_ret { CXD2880_RESULT_OK, CXD2880_RESULT_ERROR_ARG, CXD2880_RESULT_ERROR_IO, CXD2880_RESULT_ERROR_SW_STATE, CXD2880_RESULT_ERROR_HW_STATE, CXD2880_RESULT_ERROR_TIMEOUT, CXD2880_RESULT_ERROR_UNLOCK, CXD2880_RESULT_ERROR_RANGE, CXD2880_RESULT_ERROR_NOSUPPORT, CXD2880_RESULT_ERROR_CANCEL, CXD2880_RESULT_ERROR_OTHER, CXD2880_RESULT_ERROR_OVERFLOW, CXD2880_RESULT_OK_CONFIRM }; #include <linux/string.h> int cxd2880_convert2s_complement(u32 value, u32 bitlen); u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num); struct cxd2880_atomic { int counter; }; #define cxd2880_atomic_set(a, i) ((a)->counter = i) #define cxd2880_atomic_read(a) ((a)->counter) struct cxd2880_stopwatch { u32 start_time; }; enum cxd2880_ret cxd2880_stopwatch_start(struct cxd2880_stopwatch *stopwatch); enum cxd2880_ret cxd2880_stopwatch_sleep(struct cxd2880_stopwatch *stopwatch, u32 ms); enum cxd2880_ret cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch *stopwatch, u32 *elapsed); #endif