From 700b256be9e8f1079638d630a3b2a60590963023 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Thu, 16 Nov 2017 10:35:07 +0800 Subject: [PATCH 0001/1190] platform/x86: alienware-wmi: lightbar LED support for Dell Inspiron 5675 Inspiron 5675 lightbar compatible with WMI interface on alienware, the difference lies in the zone number and color control. Add Inspiron 5675 DMI quirks to detect by dmi_check_system(). Signed-off-by: Chang Liu Acked-by: Mario Limonciello [andy: massaged commit message] Signed-off-by: Andy Shevchenko --- drivers/platform/x86/alienware-wmi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c index 4eb8e1a472b23..9d7dbd925065c 100644 --- a/drivers/platform/x86/alienware-wmi.c +++ b/drivers/platform/x86/alienware-wmi.c @@ -68,6 +68,14 @@ struct quirk_entry { static struct quirk_entry *quirks; + +static struct quirk_entry quirk_inspiron5675 = { + .num_zones = 2, + .hdmi_mux = 0, + .amplifier = 0, + .deepslp = 0, +}; + static struct quirk_entry quirk_unknown = { .num_zones = 2, .hdmi_mux = 0, @@ -171,6 +179,15 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { }, .driver_data = &quirk_asm201, }, + { + .callback = dmi_matched, + .ident = "Dell Inc. Inspiron 5675", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5675"), + }, + .driver_data = &quirk_inspiron5675, + }, {} }; -- GitLab From db2582afa7444a0ce6bb1ebf1431715969a10b06 Mon Sep 17 00:00:00 2001 From: Kiernan Hager Date: Mon, 20 Nov 2017 14:18:44 -0700 Subject: [PATCH 0002/1190] platform/x86: asus-nb-wmi: Support ALS on the Zenbook UX430UQ This patch adds support for ALS on the Zenbook UX430UQ to the asus_nb_wmi driver. It also renames "quirk_asus_ux330uak" to "quirk_asus_forceals" because it is now used for more than one model of computer, and should thus have a more general name. Signed-off-by: Kiernan Hager [andy: massaged commit message, fixed indentation and commas in the code] Signed-off-by: Andy Shevchenko --- drivers/platform/x86/asus-nb-wmi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c index 5269a01d9bdd9..136ff2b4cce5e 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -111,7 +111,7 @@ static struct quirk_entry quirk_asus_x550lb = { .xusb2pr = 0x01D9, }; -static struct quirk_entry quirk_asus_ux330uak = { +static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; @@ -387,7 +387,7 @@ static const struct dmi_system_id asus_quirks[] = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "UX330UAK"), }, - .driver_data = &quirk_asus_ux330uak, + .driver_data = &quirk_asus_forceals, }, { .callback = dmi_matched, @@ -398,6 +398,15 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_x550lb, }, + { + .callback = dmi_matched, + .ident = "ASUSTeK COMPUTER INC. UX430UQ", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "UX430UQ"), + }, + .driver_data = &quirk_asus_forceals, + }, {}, }; -- GitLab From 75971febd9b14a517c14e83fccf6a961b4c759f1 Mon Sep 17 00:00:00 2001 From: Chris Chiu Date: Tue, 21 Nov 2017 13:30:44 +0800 Subject: [PATCH 0003/1190] platform/x86: Add Acer Wireless Radio Control driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Acer laptops in 2018 will have a separate ACPI device for notifications from the airplane mode hotkey. The device name in the DSDT is SMKB and its ACPI _HID is 10251229. For these models, when the airplane mode hotkey (Fn+F3) pressed, a query 0x02 is started in the Embedded Controller, and all this query does is a notify SMKB with the value 0x80. Scope (_SB.PCI0.LPCB.EC0) { (...) Method (_Q02, 0, NotSerialized) // _Qxx: EC Query { HKEV (0x2, One) Notify (SMKB, 0x80) // Status Change } } Based on code from asus-wireless Signed-off-by: Chris Chiu Reviewed-by: João Paulo Rechi Vita Signed-off-by: Andy Shevchenko --- drivers/platform/x86/Kconfig | 14 ++++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/acer-wireless.c | 71 ++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 drivers/platform/x86/acer-wireless.c diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 2c745e8ccad6c..9d2a6d642f331 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -36,6 +36,20 @@ config ACER_WMI If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M here. +config ACER_WIRELESS + tristate "Acer Wireless Radio Control Driver" + depends on ACPI + depends on INPUT + ---help--- + The Acer Wireless Radio Control handles the airplane mode hotkey + present on new Acer laptops. + + Say Y or M here if you have an Acer notebook with an airplane mode + hotkey. + + If you choose to compile this driver as a module the module will be + called acer-wireless. + config ACERHDF tristate "Acer Aspire One temperature and fan driver" depends on ACPI && THERMAL diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index c32b34a724679..2996536bf54e4 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o obj-$(CONFIG_ACER_WMI) += acer-wmi.o +obj-$(CONFIG_ACER_WIRELESS) += acer-wireless.o obj-$(CONFIG_ACERHDF) += acerhdf.o obj-$(CONFIG_HP_ACCEL) += hp_accel.o obj-$(CONFIG_HP_WIRELESS) += hp-wireless.o diff --git a/drivers/platform/x86/acer-wireless.c b/drivers/platform/x86/acer-wireless.c new file mode 100644 index 0000000000000..858037987b33e --- /dev/null +++ b/drivers/platform/x86/acer-wireless.c @@ -0,0 +1,71 @@ +/* + * Acer Wireless Radio Control Driver + * + * Copyright (C) 2017 Endless Mobile, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +static const struct acpi_device_id acer_wireless_acpi_ids[] = { + {"10251229", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids); + +static void acer_wireless_notify(struct acpi_device *adev, u32 event) +{ + struct input_dev *idev = acpi_driver_data(adev); + + dev_dbg(&adev->dev, "event=%#x\n", event); + if (event != 0x80) { + dev_notice(&adev->dev, "Unknown SMKB event: %#x\n", event); + return; + } + input_report_key(idev, KEY_RFKILL, 1); + input_report_key(idev, KEY_RFKILL, 0); + input_sync(idev); +} + +static int acer_wireless_add(struct acpi_device *adev) +{ + struct input_dev *idev; + + idev = devm_input_allocate_device(&adev->dev); + if (!idev) + return -ENOMEM; + + adev->driver_data = idev; + idev->name = "Acer Wireless Radio Control"; + idev->phys = "acer-wireless/input0"; + idev->id.bustype = BUS_HOST; + idev->id.vendor = PCI_VENDOR_ID_AI; + idev->id.product = 0x1229; + set_bit(EV_KEY, idev->evbit); + set_bit(KEY_RFKILL, idev->keybit); + + return input_register_device(idev); +} + +static struct acpi_driver acer_wireless_driver = { + .name = "Acer Wireless Radio Control Driver", + .class = "hotkey", + .ids = acer_wireless_acpi_ids, + .ops = { + .add = acer_wireless_add, + .notify = acer_wireless_notify, + }, +}; +module_acpi_driver(acer_wireless_driver); + +MODULE_DESCRIPTION("Acer Wireless Radio Control Driver"); +MODULE_AUTHOR("Chris Chiu "); +MODULE_LICENSE("GPL v2"); -- GitLab From 19a525d80836ff969b34bdf8a502c05c5eaf5f75 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 16 Nov 2017 20:24:02 +0100 Subject: [PATCH 0004/1190] platform/x86: Add support for Dollar Cove TI power button This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at: https://github.com/01org/ProductionKernelQuilts Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891 Reviewed-by: Mika Westerberg Signed-off-by: Takashi Iwai Signed-off-by: Andy Shevchenko --- drivers/platform/x86/Kconfig | 11 +++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel_chtdc_ti_pwrbtn.c | 93 ++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 drivers/platform/x86/intel_chtdc_ti_pwrbtn.c diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 9d2a6d642f331..88bf2f46b7a43 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1184,6 +1184,17 @@ config SILEAD_DMI with the OS-image for the device. This option supplies the missing information. Enable this for x86 tablets with Silead touchscreens. +config INTEL_CHTDC_TI_PWRBTN + tristate "Intel Cherry Trail Dollar Cove TI power button driver" + depends on INTEL_SOC_PMIC_CHTDC_TI + depends on INPUT + ---help--- + This option adds a power button driver driver for Dollar Cove TI + PMIC on Intel Cherry Trail devices. + + To compile this driver as a module, choose M here: the module + will be called intel_chtdc_ti_pwrbtn. + endif # X86_PLATFORM_DEVICES config PMC_ATOM diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 2996536bf54e4..4f92dbf30900a 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -89,3 +89,4 @@ obj-$(CONFIG_PMC_ATOM) += pmc_atom.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_MLX_CPLD_PLATFORM) += mlxcpld-hotplug.o obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o +obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN) += intel_chtdc_ti_pwrbtn.o diff --git a/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c b/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c new file mode 100644 index 0000000000000..38b8e7cfe88c0 --- /dev/null +++ b/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c @@ -0,0 +1,93 @@ +/* + * Power-button driver for Dollar Cove TI PMIC + * Copyright (C) 2014 Intel Corp + * Copyright (c) 2017 Takashi Iwai + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define CHTDC_TI_SIRQ_REG 0x3 +#define SIRQ_PWRBTN_REL BIT(0) + +static irqreturn_t chtdc_ti_pwrbtn_interrupt(int irq, void *dev_id) +{ + struct input_dev *input = dev_id; + struct device *dev = input->dev.parent; + struct regmap *regmap = dev_get_drvdata(dev); + int state; + + if (!regmap_read(regmap, CHTDC_TI_SIRQ_REG, &state)) { + dev_dbg(dev, "SIRQ_REG=0x%x\n", state); + input_report_key(input, KEY_POWER, !(state & SIRQ_PWRBTN_REL)); + input_sync(input); + } + + return IRQ_HANDLED; +} + +static int chtdc_ti_pwrbtn_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct intel_soc_pmic *pmic = dev_get_drvdata(dev->parent); + struct input_dev *input; + int irq, err; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + input = devm_input_allocate_device(dev); + if (!input) + return -ENOMEM; + input->name = pdev->name; + input->phys = "power-button/input0"; + input->id.bustype = BUS_HOST; + input_set_capability(input, EV_KEY, KEY_POWER); + err = input_register_device(input); + if (err) + return err; + + dev_set_drvdata(dev, pmic->regmap); + + err = devm_request_threaded_irq(dev, irq, NULL, + chtdc_ti_pwrbtn_interrupt, + 0, KBUILD_MODNAME, input); + if (err) + return err; + + device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, irq); + return 0; +} + +static int chtdc_ti_pwrbtn_remove(struct platform_device *pdev) +{ + dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); + return 0; +} + +static const struct platform_device_id chtdc_ti_pwrbtn_id_table[] = { + { .name = "chtdc_ti_pwrbtn" }, + {}, +}; +MODULE_DEVICE_TABLE(platform, chtdc_ti_pwrbtn_id_table); + +static struct platform_driver chtdc_ti_pwrbtn_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .probe = chtdc_ti_pwrbtn_probe, + .remove = chtdc_ti_pwrbtn_remove, + .id_table = chtdc_ti_pwrbtn_id_table, +}; +module_platform_driver(chtdc_ti_pwrbtn_driver); + +MODULE_DESCRIPTION("Power-button driver for Dollar Cove TI PMIC"); +MODULE_LICENSE("GPL v2"); -- GitLab From 2448f44f31625610ddeafc9c7642da8a78d93c7b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 22 Nov 2017 16:50:33 +0100 Subject: [PATCH 0005/1190] platform/x86: intel_int0002_vgpio: Remove IRQF_NO_THREAD irq flag Remove the IRQF_NO_THREAD irq flag, there is no need for it and it breaks irq-sharing with the "acpi" irq when passing "threadirqs" on the kernel cmdline, as the acpi/osl.c code does not pass IRQF_NO_THREAD. Signed-off-by: Hans de Goede Reported-by: Oleksandr Natalenko Tested-by: Oleksandr Natalenko Signed-off-by: Andy Shevchenko --- drivers/platform/x86/intel_int0002_vgpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_int0002_vgpio.c b/drivers/platform/x86/intel_int0002_vgpio.c index f7b67e898abcf..a473dc51b18d6 100644 --- a/drivers/platform/x86/intel_int0002_vgpio.c +++ b/drivers/platform/x86/intel_int0002_vgpio.c @@ -180,7 +180,7 @@ static int int0002_probe(struct platform_device *pdev) * to gpiochip_set_chained_irqchip, because the irq is shared. */ ret = devm_request_irq(dev, irq, int0002_irq, - IRQF_SHARED | IRQF_NO_THREAD, "INT0002", chip); + IRQF_SHARED, "INT0002", chip); if (ret) { dev_err(dev, "Error requesting IRQ %d: %d\n", irq, ret); return ret; -- GitLab From 9c916549c0345a054431abdc4f2d9ba48e856f80 Mon Sep 17 00:00:00 2001 From: "Chakravarty, Souvik K" Date: Fri, 24 Nov 2017 19:04:41 +0530 Subject: [PATCH 0006/1190] platform/x86: intel_pmc_ipc: Add read64 API Add intel_pmc_gcr_read64() API for reading from 64-bit GCR registers. This API will be called from intel_telemetry. Update description of intel_pmc_gcr_read(). Signed-off-by: Souvik Kumar Chakravarty Signed-off-by: Andy Shevchenko --- arch/x86/include/asm/intel_pmc_ipc.h | 6 +++++ drivers/platform/x86/intel_pmc_ipc.c | 33 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/intel_pmc_ipc.h b/arch/x86/include/asm/intel_pmc_ipc.h index 528ed4be43939..9e7adcdbe031d 100644 --- a/arch/x86/include/asm/intel_pmc_ipc.h +++ b/arch/x86/include/asm/intel_pmc_ipc.h @@ -38,6 +38,7 @@ int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out, u32 outlen); int intel_pmc_s0ix_counter_read(u64 *data); int intel_pmc_gcr_read(u32 offset, u32 *data); +int intel_pmc_gcr_read64(u32 offset, u64 *data); int intel_pmc_gcr_write(u32 offset, u32 data); int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val); @@ -70,6 +71,11 @@ static inline int intel_pmc_gcr_read(u32 offset, u32 *data) return -EINVAL; } +static inline int intel_pmc_gcr_read64(u32 offset, u64 *data) +{ + return -EINVAL; +} + static inline int intel_pmc_gcr_write(u32 offset, u32 data) { return -EINVAL; diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c index e03fa31446ca8..e7edc8c639367 100644 --- a/drivers/platform/x86/intel_pmc_ipc.c +++ b/drivers/platform/x86/intel_pmc_ipc.c @@ -215,11 +215,11 @@ static inline int is_gcr_valid(u32 offset) } /** - * intel_pmc_gcr_read() - Read PMC GCR register + * intel_pmc_gcr_read() - Read a 32-bit PMC GCR register * @offset: offset of GCR register from GCR address base * @data: data pointer for storing the register output * - * Reads the PMC GCR register of given offset. + * Reads the 32-bit PMC GCR register at given offset. * * Return: negative value on error or 0 on success. */ @@ -243,6 +243,35 @@ int intel_pmc_gcr_read(u32 offset, u32 *data) } EXPORT_SYMBOL_GPL(intel_pmc_gcr_read); +/** + * intel_pmc_gcr_read64() - Read a 64-bit PMC GCR register + * @offset: offset of GCR register from GCR address base + * @data: data pointer for storing the register output + * + * Reads the 64-bit PMC GCR register at given offset. + * + * Return: negative value on error or 0 on success. + */ +int intel_pmc_gcr_read64(u32 offset, u64 *data) +{ + int ret; + + spin_lock(&ipcdev.gcr_lock); + + ret = is_gcr_valid(offset); + if (ret < 0) { + spin_unlock(&ipcdev.gcr_lock); + return ret; + } + + *data = readq(ipcdev.gcr_mem_base + offset); + + spin_unlock(&ipcdev.gcr_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(intel_pmc_gcr_read64); + /** * intel_pmc_gcr_write() - Write PMC GCR register * @offset: offset of GCR register from GCR address base -- GitLab From 0946a05fd220a24e7f3843011ef696578d02aa29 Mon Sep 17 00:00:00 2001 From: "Chakravarty, Souvik K" Date: Fri, 24 Nov 2017 19:04:42 +0530 Subject: [PATCH 0007/1190] platform/x86: intel_telemetry: Fix suspend stats Suspend stats are not reported consistently due to a limitation in the PMC firmware. This limitation causes a delay in updating the s0ix counters and residencies in the telemetry log upon s0ix exit. As a consequence, reading these counters from the suspend-exit notifier may result in zero read. This patch fixes this issue by cross-verifying the s0ix residencies from the GCR TELEM registers in case the counters are not incremented in the telemetry log after suspend. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=197833 Reported-and-tested-by: Rajneesh Bhardwaj Signed-off-by: Souvik Kumar Chakravarty Signed-off-by: Andy Shevchenko --- .../platform/x86/intel_telemetry_debugfs.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/platform/x86/intel_telemetry_debugfs.c b/drivers/platform/x86/intel_telemetry_debugfs.c index 4249e8267bbcf..5bc4f208cc8bf 100644 --- a/drivers/platform/x86/intel_telemetry_debugfs.c +++ b/drivers/platform/x86/intel_telemetry_debugfs.c @@ -890,6 +890,31 @@ static int pm_suspend_exit_cb(void) goto out; } + /* + * Due to some design limitations in the firmware, sometimes the + * counters do not get updated by the time we reach here. As a + * workaround, we try to see if this was a genuine case of sleep + * failure or not by cross-checking from PMC GCR registers directly. + */ + if (suspend_shlw_ctr_exit == suspend_shlw_ctr_temp && + suspend_deep_ctr_exit == suspend_deep_ctr_temp) { + ret = intel_pmc_gcr_read64(PMC_GCR_TELEM_SHLW_S0IX_REG, + &suspend_shlw_res_exit); + if (ret < 0) + goto out; + + ret = intel_pmc_gcr_read64(PMC_GCR_TELEM_DEEP_S0IX_REG, + &suspend_deep_res_exit); + if (ret < 0) + goto out; + + if (suspend_shlw_res_exit > suspend_shlw_res_temp) + suspend_shlw_ctr_exit++; + + if (suspend_deep_res_exit > suspend_deep_res_temp) + suspend_deep_ctr_exit++; + } + suspend_shlw_ctr_exit -= suspend_shlw_ctr_temp; suspend_deep_ctr_exit -= suspend_deep_ctr_temp; suspend_shlw_res_exit -= suspend_shlw_res_temp; -- GitLab From ffd623d4c5315a9767a5ee183159baf7295219a6 Mon Sep 17 00:00:00 2001 From: "Chakravarty, Souvik K" Date: Fri, 24 Nov 2017 19:04:43 +0530 Subject: [PATCH 0008/1190] platform/x86: intel_telemetry: Improve S0ix logs Suspend with shallow wakes is not a useful parameter since the phenomena does not exist on deployed devices and is only a parameter of use during device power-on phase. The field always reads zero. Additionally there are other easier methods to detect it, e.g., if the S0ix counter increments by more than one during suspend. Hence the field is superfluous and can be removed. This patch also slightly renames the S0ix total field for better viewability. Signed-off-by: Souvik Kumar Chakravarty Signed-off-by: Andy Shevchenko --- .../platform/x86/intel_telemetry_debugfs.c | 45 +++---------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/drivers/platform/x86/intel_telemetry_debugfs.c b/drivers/platform/x86/intel_telemetry_debugfs.c index 5bc4f208cc8bf..97aae982d2bd6 100644 --- a/drivers/platform/x86/intel_telemetry_debugfs.c +++ b/drivers/platform/x86/intel_telemetry_debugfs.c @@ -98,10 +98,6 @@ static u32 suspend_shlw_ctr_temp, suspend_deep_ctr_temp; static u64 suspend_shlw_res_temp, suspend_deep_res_temp; struct telemetry_susp_stats { - u32 shlw_swake_ctr; - u32 deep_swake_ctr; - u64 shlw_swake_res; - u64 deep_swake_res; u32 shlw_ctr; u32 deep_ctr; u64 shlw_res; @@ -598,19 +594,15 @@ static int telem_soc_states_show(struct seq_file *s, void *unused) seq_printf(s, "S0IX Shallow\t\t\t %10u\t %10llu\n", s0ix_shlw_ctr - - conf->suspend_stats.shlw_ctr - - conf->suspend_stats.shlw_swake_ctr, + conf->suspend_stats.shlw_ctr, (u64)((s0ix_shlw_res - - conf->suspend_stats.shlw_res - - conf->suspend_stats.shlw_swake_res)*10/192)); + conf->suspend_stats.shlw_res)*10/192)); seq_printf(s, "S0IX Deep\t\t\t %10u\t %10llu\n", s0ix_deep_ctr - - conf->suspend_stats.deep_ctr - - conf->suspend_stats.deep_swake_ctr, + conf->suspend_stats.deep_ctr, (u64)((s0ix_deep_res - - conf->suspend_stats.deep_res - - conf->suspend_stats.deep_swake_res)*10/192)); + conf->suspend_stats.deep_res)*10/192)); seq_printf(s, "Suspend(With S0ixShallow)\t %10u\t %10llu\n", conf->suspend_stats.shlw_ctr, @@ -620,13 +612,7 @@ static int telem_soc_states_show(struct seq_file *s, void *unused) conf->suspend_stats.deep_ctr, (u64)(conf->suspend_stats.deep_res*10)/192); - seq_printf(s, "Suspend(With Shallow-Wakes)\t %10u\t %10llu\n", - conf->suspend_stats.shlw_swake_ctr + - conf->suspend_stats.deep_swake_ctr, - (u64)((conf->suspend_stats.shlw_swake_res + - conf->suspend_stats.deep_swake_res)*10/192)); - - seq_printf(s, "S0IX+Suspend Total\t\t %10u\t %10llu\n", s0ix_total_ctr, + seq_printf(s, "TOTAL S0IX\t\t\t %10u\t %10llu\n", s0ix_total_ctr, (u64)(s0ix_total_res*10/192)); seq_puts(s, "\n-------------------------------------------------\n"); seq_puts(s, "\t\tDEVICE STATES\n"); @@ -920,23 +906,15 @@ static int pm_suspend_exit_cb(void) suspend_shlw_res_exit -= suspend_shlw_res_temp; suspend_deep_res_exit -= suspend_deep_res_temp; - if (suspend_shlw_ctr_exit == 1) { + if (suspend_shlw_ctr_exit != 0) { conf->suspend_stats.shlw_ctr += suspend_shlw_ctr_exit; conf->suspend_stats.shlw_res += suspend_shlw_res_exit; } - /* Shallow Wakes Case */ - else if (suspend_shlw_ctr_exit > 1) { - conf->suspend_stats.shlw_swake_ctr += - suspend_shlw_ctr_exit; - - conf->suspend_stats.shlw_swake_res += - suspend_shlw_res_exit; - } - if (suspend_deep_ctr_exit == 1) { + if (suspend_deep_ctr_exit != 0) { conf->suspend_stats.deep_ctr += suspend_deep_ctr_exit; @@ -944,15 +922,6 @@ static int pm_suspend_exit_cb(void) suspend_deep_res_exit; } - /* Shallow Wakes Case */ - else if (suspend_deep_ctr_exit > 1) { - conf->suspend_stats.deep_swake_ctr += - suspend_deep_ctr_exit; - - conf->suspend_stats.deep_swake_res += - suspend_deep_res_exit; - } - out: suspend_prep_ok = 0; return NOTIFY_OK; -- GitLab From c622cbe5d11657a12c473356826017fed0c7669e Mon Sep 17 00:00:00 2001 From: "Chakravarty, Souvik K" Date: Fri, 24 Nov 2017 19:04:44 +0530 Subject: [PATCH 0009/1190] platform/x86: intel_telemetry: Remove redundancies This patch removes unnecessary header files and newlines. It also fixes some alignment issues. Signed-off-by: Souvik Kumar Chakravarty Signed-off-by: Andy Shevchenko --- drivers/platform/x86/intel_telemetry_debugfs.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/intel_telemetry_debugfs.c b/drivers/platform/x86/intel_telemetry_debugfs.c index 97aae982d2bd6..ffd0474b05311 100644 --- a/drivers/platform/x86/intel_telemetry_debugfs.c +++ b/drivers/platform/x86/intel_telemetry_debugfs.c @@ -23,7 +23,6 @@ */ #include #include -#include #include #include #include @@ -32,11 +31,10 @@ #include #include #include -#include #include -#define DRIVER_NAME "telemetry_soc_debugfs" -#define DRIVER_VERSION "1.0.0" +#define DRIVER_NAME "telemetry_soc_debugfs" +#define DRIVER_VERSION "1.0.0" /* ApolloLake SoC Event-IDs */ #define TELEM_APL_PSS_PSTATES_ID 0x2802 @@ -246,7 +244,6 @@ static struct telem_ioss_pg_info telem_apl_ioss_pg_data[] = { {"PRTC", 25}, }; - struct telemetry_debugfs_conf { struct telemetry_susp_stats suspend_stats; struct dentry *telemetry_dbg_dir; @@ -381,7 +378,6 @@ static int telem_pss_states_show(struct seq_file *s, void *unused) TELEM_APL_MASK_PCS_STATE; } - TELEM_CHECK_AND_PARSE_EVTS(conf->pss_idle_id, conf->pss_idle_evts - 1, pss_idle, evtlog[index].telem_evtlog, @@ -401,7 +397,6 @@ static int telem_pss_states_show(struct seq_file *s, void *unused) conf->pcs_s0ix_blkd_data, TELEM_MASK_BYTE); - TELEM_CHECK_AND_PARSE_EVTS(conf->pss_wakeup_id, conf->pss_wakeup_evts, pss_s0ix_wakeup, @@ -494,7 +489,6 @@ static const struct file_operations telem_pss_ops = { .release = single_release, }; - static int telem_ioss_states_show(struct seq_file *s, void *unused) { struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; @@ -613,7 +607,7 @@ static int telem_soc_states_show(struct seq_file *s, void *unused) (u64)(conf->suspend_stats.deep_res*10)/192); seq_printf(s, "TOTAL S0IX\t\t\t %10u\t %10llu\n", s0ix_total_ctr, - (u64)(s0ix_total_res*10/192)); + (u64)(s0ix_total_res*10/192)); seq_puts(s, "\n-------------------------------------------------\n"); seq_puts(s, "\t\tDEVICE STATES\n"); seq_puts(s, "-------------------------------------------------\n"); @@ -758,7 +752,6 @@ static const struct file_operations telem_pss_trc_verb_ops = { .release = single_release, }; - static int telem_ioss_trc_verb_show(struct seq_file *s, void *unused) { u32 verbosity; -- GitLab From a1fcc455899ace544d7130c6eace471d69d2f96a Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Tue, 28 Nov 2017 23:32:40 +0100 Subject: [PATCH 0010/1190] remoteproc: qcom: Use PTR_ERR_OR_ZERO() in glink prob Fix ptr_ret.cocci warnings: drivers/remoteproc/qcom_common.c:60:8-14: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Signed-off-by: Vasyl Gomonovych Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index d487040b528ba..e9b5f2a98c4db 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -57,7 +57,7 @@ static int glink_subdev_probe(struct rproc_subdev *subdev) glink->edge = qcom_glink_smem_register(glink->dev, glink->node); - return IS_ERR(glink->edge) ? PTR_ERR(glink->edge) : 0; + return PTR_ERR_OR_ZERO(glink->edge); } static void glink_subdev_remove(struct rproc_subdev *subdev) -- GitLab From cdd77d3e193031cc67426cd671d8aa370f7dfee4 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 17 Nov 2017 16:23:08 -0800 Subject: [PATCH 0011/1190] nfit, libnvdimm: deprecate the generic SMART ioctl The kernel's ND_IOCTL_SMART_THRESHOLD command is based on a payload definition that has become broken / out-of-sync with recent versions of the NVDIMM_FAMILY_INTEL definition. Deprecate the use of the ND_IOCTL_SMART_THRESHOLD command in favor of the ND_CMD_CALL approach taken by NVDIMM_FAMILY_{HPE,MSFT}, where we can manage the per-vendor variance in userspace. In a couple years, when the new scheme is widely deployed in userspace packages, the ND_IOCTL_SMART_THRESHOLD support can be removed. For now we prevent new binaries from compiling against the kernel header definitions, but kernel still compatible with old binaries. The libndctl.h [1] header is now the authoritative interface definition for NVDIMM SMART. [1]: https://github.com/pmem/ndctl Signed-off-by: Dan Williams --- drivers/nvdimm/bus.c | 3 -- include/uapi/linux/ndctl.h | 54 ------------------------ tools/testing/nvdimm/test/nfit.c | 39 +++++++++++------- tools/testing/nvdimm/test/nfit_test.h | 59 +++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 71 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 0a5e6cd758fe3..78eabc3a1ab13 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -1142,9 +1142,6 @@ int __init nvdimm_bus_init(void) { int rc; - BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128); - BUILD_BUG_ON(sizeof(struct nd_smart_threshold_payload) != 8); - rc = bus_register(&nvdimm_bus_type); if (rc) return rc; diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h index 3f03567631cb0..30ef1236aafa6 100644 --- a/include/uapi/linux/ndctl.h +++ b/include/uapi/linux/ndctl.h @@ -15,54 +15,6 @@ #include -struct nd_cmd_smart { - __u32 status; - __u8 data[128]; -} __packed; - -#define ND_SMART_HEALTH_VALID (1 << 0) -#define ND_SMART_SPARES_VALID (1 << 1) -#define ND_SMART_USED_VALID (1 << 2) -#define ND_SMART_TEMP_VALID (1 << 3) -#define ND_SMART_CTEMP_VALID (1 << 4) -#define ND_SMART_ALARM_VALID (1 << 9) -#define ND_SMART_SHUTDOWN_VALID (1 << 10) -#define ND_SMART_VENDOR_VALID (1 << 11) -#define ND_SMART_SPARE_TRIP (1 << 0) -#define ND_SMART_TEMP_TRIP (1 << 1) -#define ND_SMART_CTEMP_TRIP (1 << 2) -#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0) -#define ND_SMART_CRITICAL_HEALTH (1 << 1) -#define ND_SMART_FATAL_HEALTH (1 << 2) - -struct nd_smart_payload { - __u32 flags; - __u8 reserved0[4]; - __u8 health; - __u8 spares; - __u8 life_used; - __u8 alarm_flags; - __u16 temperature; - __u16 ctrl_temperature; - __u8 reserved1[15]; - __u8 shutdown_state; - __u32 vendor_size; - __u8 vendor_data[92]; -} __packed; - -struct nd_cmd_smart_threshold { - __u32 status; - __u8 data[8]; -} __packed; - -struct nd_smart_threshold_payload { - __u8 alarm_control; - __u8 reserved0; - __u16 temperature; - __u8 spares; - __u8 reserved[3]; -} __packed; - struct nd_cmd_dimm_flags { __u32 status; __u32 flags; @@ -211,12 +163,6 @@ static inline const char *nvdimm_cmd_name(unsigned cmd) #define ND_IOCTL 'N' -#define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\ - struct nd_cmd_smart) - -#define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\ - struct nd_cmd_smart_threshold) - #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\ struct nd_cmd_dimm_flags) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index 7217b2b953b58..640c02b08a502 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -440,39 +440,50 @@ static int nfit_test_cmd_translate_spa(struct nvdimm_bus *bus, return 0; } -static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len) +static int nfit_test_cmd_smart(struct nd_intel_smart *smart, unsigned int buf_len) { - static const struct nd_smart_payload smart_data = { - .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID - | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID - | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID, - .health = ND_SMART_NON_CRITICAL_HEALTH, - .temperature = 23 * 16, + static const struct nd_intel_smart smart_data = { + .flags = ND_INTEL_SMART_HEALTH_VALID + | ND_INTEL_SMART_SPARES_VALID + | ND_INTEL_SMART_ALARM_VALID + | ND_INTEL_SMART_USED_VALID + | ND_INTEL_SMART_SHUTDOWN_VALID + | ND_INTEL_SMART_MTEMP_VALID, + .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH, + .media_temperature = 23 * 16, + .ctrl_temperature = 30 * 16, + .pmic_temperature = 40 * 16, .spares = 75, - .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP, + .alarm_flags = ND_INTEL_SMART_SPARE_TRIP + | ND_INTEL_SMART_TEMP_TRIP, + .ait_status = 1, .life_used = 5, .shutdown_state = 0, .vendor_size = 0, + .shutdown_count = 100, }; if (buf_len < sizeof(*smart)) return -EINVAL; - memcpy(smart->data, &smart_data, sizeof(smart_data)); + memcpy(smart, &smart_data, sizeof(smart_data)); return 0; } -static int nfit_test_cmd_smart_threshold(struct nd_cmd_smart_threshold *smart_t, +static int nfit_test_cmd_smart_threshold( + struct nd_intel_smart_threshold *smart_t, unsigned int buf_len) { - static const struct nd_smart_threshold_payload smart_t_data = { - .alarm_control = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP, - .temperature = 40 * 16, + static const struct nd_intel_smart_threshold smart_t_data = { + .alarm_control = ND_INTEL_SMART_SPARE_TRIP + | ND_INTEL_SMART_TEMP_TRIP, + .media_temperature = 40 * 16, + .ctrl_temperature = 30 * 16, .spares = 5, }; if (buf_len < sizeof(*smart_t)) return -EINVAL; - memcpy(smart_t->data, &smart_t_data, sizeof(smart_t_data)); + memcpy(smart_t, &smart_t_data, sizeof(smart_t_data)); return 0; } diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h index 113b44675a718..b85fba2856c7c 100644 --- a/tools/testing/nvdimm/test/nfit_test.h +++ b/tools/testing/nvdimm/test/nfit_test.h @@ -84,6 +84,65 @@ struct nd_cmd_ars_err_inj_stat { } __packed record[0]; } __packed; +#define ND_INTEL_SMART 1 +#define ND_INTEL_SMART_THRESHOLD 2 + +#define ND_INTEL_SMART_HEALTH_VALID (1 << 0) +#define ND_INTEL_SMART_SPARES_VALID (1 << 1) +#define ND_INTEL_SMART_USED_VALID (1 << 2) +#define ND_INTEL_SMART_MTEMP_VALID (1 << 3) +#define ND_INTEL_SMART_CTEMP_VALID (1 << 4) +#define ND_INTEL_SMART_SHUTDOWN_COUNT_VALID (1 << 5) +#define ND_INTEL_SMART_AIT_STATUS_VALID (1 << 6) +#define ND_INTEL_SMART_PTEMP_VALID (1 << 7) +#define ND_INTEL_SMART_ALARM_VALID (1 << 9) +#define ND_INTEL_SMART_SHUTDOWN_VALID (1 << 10) +#define ND_INTEL_SMART_VENDOR_VALID (1 << 11) +#define ND_INTEL_SMART_SPARE_TRIP (1 << 0) +#define ND_INTEL_SMART_TEMP_TRIP (1 << 1) +#define ND_INTEL_SMART_CTEMP_TRIP (1 << 2) +#define ND_INTEL_SMART_NON_CRITICAL_HEALTH (1 << 0) +#define ND_INTEL_SMART_CRITICAL_HEALTH (1 << 1) +#define ND_INTEL_SMART_FATAL_HEALTH (1 << 2) + +struct nd_intel_smart { + __u32 status; + union { + struct { + __u32 flags; + __u8 reserved0[4]; + __u8 health; + __u8 spares; + __u8 life_used; + __u8 alarm_flags; + __u16 media_temperature; + __u16 ctrl_temperature; + __u32 shutdown_count; + __u8 ait_status; + __u16 pmic_temperature; + __u8 reserved1[8]; + __u8 shutdown_state; + __u32 vendor_size; + __u8 vendor_data[92]; + } __packed; + __u8 data[128]; + }; +} __packed; + +struct nd_intel_smart_threshold { + __u32 status; + union { + struct { + __u16 alarm_control; + __u8 spares; + __u16 media_temperature; + __u16 ctrl_temperature; + __u8 reserved[1]; + } __packed; + __u8 data[8]; + }; +} __packed; + union acpi_object; typedef void *acpi_handle; -- GitLab From ed07c4338dd5ceadb5ffed0a5be03488ac54f5d2 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 24 Nov 2017 14:32:27 -0800 Subject: [PATCH 0012/1190] tools/testing/nvdimm: smart alarm/threshold control Allow the smart_threshold values to be changed via the 'set smart threshold command' and trigger notifications when the thresholds are met. Signed-off-by: Dan Williams --- tools/testing/nvdimm/test/nfit.c | 157 ++++++++++++++++++-------- tools/testing/nvdimm/test/nfit_test.h | 9 ++ 2 files changed, 122 insertions(+), 44 deletions(-) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index 640c02b08a502..2b57254342aaa 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -168,6 +168,8 @@ struct nfit_test { spinlock_t lock; } ars_state; struct device *dimm_dev[NUM_DCR]; + struct nd_intel_smart *smart; + struct nd_intel_smart_threshold *smart_threshold; struct badrange badrange; struct work_struct work; }; @@ -440,50 +442,66 @@ static int nfit_test_cmd_translate_spa(struct nvdimm_bus *bus, return 0; } -static int nfit_test_cmd_smart(struct nd_intel_smart *smart, unsigned int buf_len) +static int nfit_test_cmd_smart(struct nd_intel_smart *smart, unsigned int buf_len, + struct nd_intel_smart *smart_data) { - static const struct nd_intel_smart smart_data = { - .flags = ND_INTEL_SMART_HEALTH_VALID - | ND_INTEL_SMART_SPARES_VALID - | ND_INTEL_SMART_ALARM_VALID - | ND_INTEL_SMART_USED_VALID - | ND_INTEL_SMART_SHUTDOWN_VALID - | ND_INTEL_SMART_MTEMP_VALID, - .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH, - .media_temperature = 23 * 16, - .ctrl_temperature = 30 * 16, - .pmic_temperature = 40 * 16, - .spares = 75, - .alarm_flags = ND_INTEL_SMART_SPARE_TRIP - | ND_INTEL_SMART_TEMP_TRIP, - .ait_status = 1, - .life_used = 5, - .shutdown_state = 0, - .vendor_size = 0, - .shutdown_count = 100, - }; - if (buf_len < sizeof(*smart)) return -EINVAL; - memcpy(smart, &smart_data, sizeof(smart_data)); + memcpy(smart, smart_data, sizeof(*smart)); return 0; } static int nfit_test_cmd_smart_threshold( - struct nd_intel_smart_threshold *smart_t, - unsigned int buf_len) + struct nd_intel_smart_threshold *out, + unsigned int buf_len, + struct nd_intel_smart_threshold *smart_t) { - static const struct nd_intel_smart_threshold smart_t_data = { - .alarm_control = ND_INTEL_SMART_SPARE_TRIP - | ND_INTEL_SMART_TEMP_TRIP, - .media_temperature = 40 * 16, - .ctrl_temperature = 30 * 16, - .spares = 5, - }; - if (buf_len < sizeof(*smart_t)) return -EINVAL; - memcpy(smart_t, &smart_t_data, sizeof(smart_t_data)); + memcpy(out, smart_t, sizeof(*smart_t)); + return 0; +} + +static void smart_notify(struct device *bus_dev, + struct device *dimm_dev, struct nd_intel_smart *smart, + struct nd_intel_smart_threshold *thresh) +{ + dev_dbg(dimm_dev, "%s: alarm: %#x spares: %d (%d) mtemp: %d (%d) ctemp: %d (%d)\n", + __func__, thresh->alarm_control, thresh->spares, + smart->spares, thresh->media_temperature, + smart->media_temperature, thresh->ctrl_temperature, + smart->ctrl_temperature); + if (((thresh->alarm_control & ND_INTEL_SMART_SPARE_TRIP) + && smart->spares + <= thresh->spares) + || ((thresh->alarm_control & ND_INTEL_SMART_TEMP_TRIP) + && smart->media_temperature + >= thresh->media_temperature) + || ((thresh->alarm_control & ND_INTEL_SMART_CTEMP_TRIP) + && smart->ctrl_temperature + >= thresh->ctrl_temperature)) { + device_lock(bus_dev); + __acpi_nvdimm_notify(dimm_dev, 0x81); + device_unlock(bus_dev); + } +} + +static int nfit_test_cmd_smart_set_threshold( + struct nd_intel_smart_set_threshold *in, + unsigned int buf_len, + struct nd_intel_smart_threshold *thresh, + struct nd_intel_smart *smart, + struct device *bus_dev, struct device *dimm_dev) +{ + unsigned int size; + + size = sizeof(*in) - 4; + if (buf_len < size) + return -EINVAL; + memcpy(thresh->data, in, size); + in->status = 0; + smart_notify(bus_dev, dimm_dev, smart, thresh); + return 0; } @@ -608,7 +626,7 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, || !test_bit(func, &nfit_mem->dsm_mask)) return -ENOTTY; - /* lookup label space for the given dimm */ + /* lookup per-dimm data */ for (i = 0; i < ARRAY_SIZE(handle); i++) if (__to_nfit_memdev(nfit_mem)->device_handle == handle[i]) @@ -631,14 +649,19 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, rc = nfit_test_cmd_set_config_data(buf, buf_len, t->label[i - t->dcr_idx]); break; - case ND_CMD_SMART: - rc = nfit_test_cmd_smart(buf, buf_len); + case ND_INTEL_SMART: + rc = nfit_test_cmd_smart(buf, buf_len, + &t->smart[i - t->dcr_idx]); + break; + case ND_INTEL_SMART_THRESHOLD: + rc = nfit_test_cmd_smart_threshold(buf, buf_len, + &t->smart_threshold[i - t->dcr_idx]); break; - case ND_CMD_SMART_THRESHOLD: - rc = nfit_test_cmd_smart_threshold(buf, buf_len); - device_lock(&t->pdev.dev); - __acpi_nvdimm_notify(t->dimm_dev[i], 0x81); - device_unlock(&t->pdev.dev); + case ND_INTEL_SMART_SET_THRESHOLD: + rc = nfit_test_cmd_smart_set_threshold(buf, buf_len, + &t->smart_threshold[i - t->dcr_idx], + &t->smart[i - t->dcr_idx], + &t->pdev.dev, t->dimm_dev[i]); break; default: return -ENOTTY; @@ -883,6 +906,44 @@ static const struct attribute_group *nfit_test_dimm_attribute_groups[] = { NULL, }; +static void smart_init(struct nfit_test *t) +{ + int i; + const struct nd_intel_smart_threshold smart_t_data = { + .alarm_control = ND_INTEL_SMART_SPARE_TRIP + | ND_INTEL_SMART_TEMP_TRIP, + .media_temperature = 40 * 16, + .ctrl_temperature = 30 * 16, + .spares = 5, + }; + const struct nd_intel_smart smart_data = { + .flags = ND_INTEL_SMART_HEALTH_VALID + | ND_INTEL_SMART_SPARES_VALID + | ND_INTEL_SMART_ALARM_VALID + | ND_INTEL_SMART_USED_VALID + | ND_INTEL_SMART_SHUTDOWN_VALID + | ND_INTEL_SMART_MTEMP_VALID, + .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH, + .media_temperature = 23 * 16, + .ctrl_temperature = 30 * 16, + .pmic_temperature = 40 * 16, + .spares = 75, + .alarm_flags = ND_INTEL_SMART_SPARE_TRIP + | ND_INTEL_SMART_TEMP_TRIP, + .ait_status = 1, + .life_used = 5, + .shutdown_state = 0, + .vendor_size = 0, + .shutdown_count = 100, + }; + + for (i = 0; i < t->num_dcr; i++) { + memcpy(&t->smart[i], &smart_data, sizeof(smart_data)); + memcpy(&t->smart_threshold[i], &smart_t_data, + sizeof(smart_t_data)); + } +} + static int nfit_test0_alloc(struct nfit_test *t) { size_t nfit_size = sizeof(struct acpi_nfit_system_address) * NUM_SPA @@ -950,6 +1011,7 @@ static int nfit_test0_alloc(struct nfit_test *t) return -ENOMEM; } + smart_init(t); return ars_state_init(&t->pdev.dev, &t->ars_state); } @@ -980,6 +1042,7 @@ static int nfit_test1_alloc(struct nfit_test *t) if (!t->spa_set[1]) return -ENOMEM; + smart_init(t); return ars_state_init(&t->pdev.dev, &t->ars_state); } @@ -1653,13 +1716,14 @@ static void nfit_test0_setup(struct nfit_test *t) set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_cmd_force_en); set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); - set_bit(ND_CMD_SMART, &acpi_desc->dimm_cmd_force_en); + set_bit(ND_INTEL_SMART, &acpi_desc->dimm_cmd_force_en); + set_bit(ND_INTEL_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en); + set_bit(ND_INTEL_SMART_SET_THRESHOLD, &acpi_desc->dimm_cmd_force_en); set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_cmd_force_en); set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); set_bit(ND_CMD_CALL, &acpi_desc->bus_cmd_force_en); - set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en); set_bit(NFIT_CMD_TRANSLATE_SPA, &acpi_desc->bus_nfit_cmd_force_en); set_bit(NFIT_CMD_ARS_INJECT_SET, &acpi_desc->bus_nfit_cmd_force_en); set_bit(NFIT_CMD_ARS_INJECT_CLEAR, &acpi_desc->bus_nfit_cmd_force_en); @@ -2065,6 +2129,11 @@ static int nfit_test_probe(struct platform_device *pdev) sizeof(struct nfit_test_dcr *), GFP_KERNEL); nfit_test->dcr_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t), GFP_KERNEL); + nfit_test->smart = devm_kcalloc(dev, num, + sizeof(struct nd_intel_smart), GFP_KERNEL); + nfit_test->smart_threshold = devm_kcalloc(dev, num, + sizeof(struct nd_intel_smart_threshold), + GFP_KERNEL); if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label && nfit_test->label_dma && nfit_test->dcr && nfit_test->dcr_dma && nfit_test->flush diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h index b85fba2856c7c..ba230f6f76769 100644 --- a/tools/testing/nvdimm/test/nfit_test.h +++ b/tools/testing/nvdimm/test/nfit_test.h @@ -86,6 +86,7 @@ struct nd_cmd_ars_err_inj_stat { #define ND_INTEL_SMART 1 #define ND_INTEL_SMART_THRESHOLD 2 +#define ND_INTEL_SMART_SET_THRESHOLD 17 #define ND_INTEL_SMART_HEALTH_VALID (1 << 0) #define ND_INTEL_SMART_SPARES_VALID (1 << 1) @@ -143,6 +144,14 @@ struct nd_intel_smart_threshold { }; } __packed; +struct nd_intel_smart_set_threshold { + __u16 alarm_control; + __u8 spares; + __u16 media_temperature; + __u16 ctrl_temperature; + __u32 status; +} __packed; + union acpi_object; typedef void *acpi_handle; -- GitLab From 7e5d1fd75c3dde9fc10c4472b9368089d1b81d00 Mon Sep 17 00:00:00 2001 From: Gottfried Haider Date: Tue, 26 Sep 2017 11:59:51 +0000 Subject: [PATCH 0013/1190] pwm: Set class for exported channels in sysfs Notifications for devices without bus or class set get dropped by dev_uevent_filter(). Adding the class to the exported child matches what the GPIO subsystem is doing. With this change exporting a channel triggers a udev event, which gives userspace a chance to fixup permissions and makes it possible for non-root users to make use of the PWM subsystem. Signed-off-by: Gottfried Haider CC: Thierry Reding CC: H Hartley Sweeten CC: linux-pwm@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org CC: linux-rpi-kernel@lists.infradead.org Signed-off-by: Thierry Reding --- drivers/pwm/sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index a813239300c3d..83f2b0b15712b 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -263,6 +263,7 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm) export->pwm = pwm; mutex_init(&export->lock); + export->child.class = parent->class; export->child.release = pwm_export_release; export->child.parent = parent; export->child.devt = MKDEV(0, 0); -- GitLab From 8472b529e113e0863ea064fdee51bf73c3f86fd6 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 7 Nov 2017 13:18:53 +0800 Subject: [PATCH 0014/1190] pwm: stmpe: Fix wrong register offset for hwpwm=2 case Fix trivial copy/paste bug. Signed-off-by: Axel Lin Reviewed-by: Linus Walleij Fixes: ef1f09eca74a ("pwm: Add a driver for the STMPE PWM") Signed-off-by: Thierry Reding --- drivers/pwm/pwm-stmpe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c index e464582a390a5..3439f1e902cb0 100644 --- a/drivers/pwm/pwm-stmpe.c +++ b/drivers/pwm/pwm-stmpe.c @@ -145,7 +145,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, break; case 2: - offset = STMPE24XX_PWMIC1; + offset = STMPE24XX_PWMIC2; break; default: -- GitLab From a52d97ca0d44b7f5096136afaa9714e973091ad3 Mon Sep 17 00:00:00 2001 From: Jian Hu Date: Mon, 4 Dec 2017 14:00:16 +0800 Subject: [PATCH 0015/1190] dt-bindings: pwm: Update bindings for the Meson-AXG Update the doc to explicitly support Meson-AXG Signed-off-by: Jian Hu Signed-off-by: Yixun Lan Reviewed-by: Rob Herring Signed-off-by: Thierry Reding --- Documentation/devicetree/bindings/pwm/pwm-meson.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/pwm/pwm-meson.txt b/Documentation/devicetree/bindings/pwm/pwm-meson.txt index 1ee81321c35e7..1fa3f71821334 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-meson.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-meson.txt @@ -5,6 +5,8 @@ Required properties: - compatible: Shall contain "amlogic,meson8b-pwm" or "amlogic,meson-gxbb-pwm" or "amlogic,meson-gxbb-ao-pwm" + or "amlogic,meson-axg-ee-pwm" + or "amlogic,meson-axg-ao-pwm" - #pwm-cells: Should be 3. See pwm.txt in this directory for a description of the cells format. -- GitLab From bccaa3f917c90917a758020dfbdd9027290a7c4e Mon Sep 17 00:00:00 2001 From: Jian Hu Date: Mon, 4 Dec 2017 14:00:17 +0800 Subject: [PATCH 0016/1190] pwm: meson: Add clock source configuration for Meson-AXG For PWM controller in the Meson-AXG SoC, the EE domain and AO domain have different clock sources. This patch tries to describe them in the DT compatible data. Signed-off-by: Jian Hu Signed-off-by: Yixun Lan Signed-off-by: Thierry Reding --- drivers/pwm/pwm-meson.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index d589331d1884b..0767deba8e622 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -411,6 +411,24 @@ static const struct meson_pwm_data pwm_gxbb_ao_data = { .num_parents = ARRAY_SIZE(pwm_gxbb_ao_parent_names), }; +static const char * const pwm_axg_ee_parent_names[] = { + "xtal", "fclk_div5", "fclk_div4", "fclk_div3" +}; + +static const struct meson_pwm_data pwm_axg_ee_data = { + .parent_names = pwm_axg_ee_parent_names, + .num_parents = ARRAY_SIZE(pwm_axg_ee_parent_names), +}; + +static const char * const pwm_axg_ao_parent_names[] = { + "aoclk81", "xtal", "fclk_div4", "fclk_div5" +}; + +static const struct meson_pwm_data pwm_axg_ao_data = { + .parent_names = pwm_axg_ao_parent_names, + .num_parents = ARRAY_SIZE(pwm_axg_ao_parent_names), +}; + static const struct of_device_id meson_pwm_matches[] = { { .compatible = "amlogic,meson8b-pwm", @@ -424,6 +442,14 @@ static const struct of_device_id meson_pwm_matches[] = { .compatible = "amlogic,meson-gxbb-ao-pwm", .data = &pwm_gxbb_ao_data }, + { + .compatible = "amlogic,meson-axg-ee-pwm", + .data = &pwm_axg_ee_data + }, + { + .compatible = "amlogic,meson-axg-ao-pwm", + .data = &pwm_axg_ao_data + }, {}, }; MODULE_DEVICE_TABLE(of, meson_pwm_matches); -- GitLab From ed608eb0be578472ba1b23bca92f7dec61b24053 Mon Sep 17 00:00:00 2001 From: Pravin Shedge Date: Wed, 6 Dec 2017 22:32:41 +0530 Subject: [PATCH 0017/1190] drivers: rpmsg: remove duplicate includes These duplicate includes have been found with scripts/checkincludes.pl but they have been removed manually to avoid removing false positives. Signed-off-by: Pravin Shedge Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_smem.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c index 5cdaa5f8fb61e..057528e23d3ab 100644 --- a/drivers/rpmsg/qcom_glink_smem.c +++ b/drivers/rpmsg/qcom_glink_smem.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include #include "qcom_glink_native.h" -- GitLab From f550f2dd7c7e881eb296c2fa4e5f0bebeb4311c9 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sun, 12 Nov 2017 06:27:29 -0500 Subject: [PATCH 0018/1190] media: dt-bindings: et8ek8: Document support for flash and lens devices Document dts support of LED/focus. Signed-off-by: Pavel Machek Reviewed-by: Sebastian Reichel Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- .../devicetree/bindings/media/i2c/toshiba,et8ek8.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt b/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt index 0b7b6a4d84fff..e80d5891b7edd 100644 --- a/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt +++ b/Documentation/devicetree/bindings/media/i2c/toshiba,et8ek8.txt @@ -20,6 +20,13 @@ Mandatory properties is in hardware standby mode when the signal is in the low state. +Optional properties +------------------- + +- flash-leds: See ../video-interfaces.txt +- lens-focus: See ../video-interfaces.txt + + Endpoint node mandatory properties ---------------------------------- -- GitLab From 4884c50631ff30d90565366b9552d0a22ee3c09b Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sun, 12 Nov 2017 06:25:29 -0500 Subject: [PATCH 0019/1190] media: ARM: dts: nokia n900: enable autofocus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Connect voice coil lens to the camera sensor, so that it can be used by camera applications. Signed-off-by: Pavel Machek Acked-by: Pali Rohár Reviewed-by: Sebastian Reichel Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- arch/arm/boot/dts/omap3-n900.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts index 669c51c00c000..59cc7432b6d66 100644 --- a/arch/arm/boot/dts/omap3-n900.dts +++ b/arch/arm/boot/dts/omap3-n900.dts @@ -778,6 +778,8 @@ reset-gpio = <&gpio4 6 GPIO_ACTIVE_HIGH>; /* 102 */ + lens-focus = <&ad5820>; + port { csi_cam1: endpoint { bus-type = <3>; /* CCP2 */ -- GitLab From 344aa836e813a6b097c23f2e0633dd17f62c2ed7 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Fri, 24 Nov 2017 09:40:44 -0500 Subject: [PATCH 0020/1190] media: ov7670: use v4l2_async_unregister_subdev() The sub-device for ov7670 is registered by v4l2_async_register_subdev(). So it should be unregistered by v4l2_async_unregister_subdev() instead of v4l2_device_unregister_subdev(). Cc: Jonathan Corbet Signed-off-by: Akinobu Mita Reviewed-by: Kieran Bingham Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov7670.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 950a0acf85fb8..b61d88e7f3eb0 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -1820,7 +1820,7 @@ static int ov7670_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); struct ov7670_info *info = to_state(sd); - v4l2_device_unregister_subdev(sd); + v4l2_async_unregister_subdev(sd); v4l2_ctrl_handler_free(&info->hdl); clk_disable_unprepare(info->clk); #if defined(CONFIG_MEDIA_CONTROLLER) -- GitLab From b48d908d2b04e5c11bf0f9035bf52f7c0c988603 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Fri, 24 Nov 2017 09:40:45 -0500 Subject: [PATCH 0021/1190] media: ov7670: add V4L2_CID_TEST_PATTERN control The ov7670 has the test pattern generator features. This makes use of it through V4L2_CID_TEST_PATTERN control. Cc: Jonathan Corbet Signed-off-by: Akinobu Mita Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov7670.c | 46 +++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index b61d88e7f3eb0..c6c32f6497772 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -163,6 +163,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); #define DBLV_X6 0x10 /* clock x6 */ #define DBLV_X8 0x11 /* clock x8 */ +#define REG_SCALING_XSC 0x70 /* Test pattern and horizontal scale factor */ +#define TEST_PATTTERN_0 0x80 +#define REG_SCALING_YSC 0x71 /* Test pattern and vertical scale factor */ +#define TEST_PATTTERN_1 0x80 + #define REG_REG76 0x76 /* OV's name */ #define R76_BLKPCOR 0x80 /* Black pixel correction enable */ #define R76_WHTPCOR 0x40 /* White pixel correction enable */ @@ -292,7 +297,8 @@ static struct regval_list ov7670_default_regs[] = { { REG_COM3, 0 }, { REG_COM14, 0 }, /* Mystery scaling numbers */ - { 0x70, 0x3a }, { 0x71, 0x35 }, + { REG_SCALING_XSC, 0x3a }, + { REG_SCALING_YSC, 0x35 }, { 0x72, 0x11 }, { 0x73, 0xf0 }, { 0xa2, 0x02 }, { REG_COM10, 0x0 }, @@ -568,6 +574,19 @@ static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg, return ov7670_write_i2c(sd, reg, value); } +static int ov7670_update_bits(struct v4l2_subdev *sd, unsigned char reg, + unsigned char mask, unsigned char value) +{ + unsigned char orig; + int ret; + + ret = ov7670_read(sd, reg, &orig); + if (ret) + return ret; + + return ov7670_write(sd, reg, (orig & ~mask) | (value & mask)); +} + /* * Write a list of register settings; ff/ff stops the process. */ @@ -1470,6 +1489,25 @@ static int ov7670_s_autoexp(struct v4l2_subdev *sd, return ret; } +static const char * const ov7670_test_pattern_menu[] = { + "No test output", + "Shifting \"1\"", + "8-bar color bar", + "Fade to gray color bar", +}; + +static int ov7670_s_test_pattern(struct v4l2_subdev *sd, int value) +{ + int ret; + + ret = ov7670_update_bits(sd, REG_SCALING_XSC, TEST_PATTTERN_0, + value & BIT(0) ? TEST_PATTTERN_0 : 0); + if (ret) + return ret; + + return ov7670_update_bits(sd, REG_SCALING_YSC, TEST_PATTTERN_1, + value & BIT(1) ? TEST_PATTTERN_1 : 0); +} static int ov7670_g_volatile_ctrl(struct v4l2_ctrl *ctrl) { @@ -1516,6 +1554,8 @@ static int ov7670_s_ctrl(struct v4l2_ctrl *ctrl) return ov7670_s_exp(sd, info->exposure->val); } return ov7670_s_autoexp(sd, ctrl->val); + case V4L2_CID_TEST_PATTERN: + return ov7670_s_test_pattern(sd, ctrl->val); } return -EINVAL; } @@ -1770,6 +1810,10 @@ static int ov7670_probe(struct i2c_client *client, info->auto_exposure = v4l2_ctrl_new_std_menu(&info->hdl, &ov7670_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL, 0, V4L2_EXPOSURE_AUTO); + v4l2_ctrl_new_std_menu_items(&info->hdl, &ov7670_ctrl_ops, + V4L2_CID_TEST_PATTERN, + ARRAY_SIZE(ov7670_test_pattern_menu) - 1, 0, 0, + ov7670_test_pattern_menu); sd->ctrl_handler = &info->hdl; if (info->hdl.error) { ret = info->hdl.error; -- GitLab From 7df66d778317353c94c3a2832cd26e320ca28b7d Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Fri, 24 Nov 2017 17:04:37 -0500 Subject: [PATCH 0022/1190] media: v4l: mt9v032: Disable clock on error paths mt9v032_power_on() leaves clk enabled in case of errors, but it is not expected by its callers. There is a similar problem in mt9v032_registered(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9v032.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 8a430640c85d5..4de63b2df3346 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -294,14 +294,22 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032) /* Reset the chip and stop data read out */ ret = regmap_write(map, MT9V032_RESET, 1); if (ret < 0) - return ret; + goto err; ret = regmap_write(map, MT9V032_RESET, 0); if (ret < 0) - return ret; + goto err; + + ret = regmap_write(map, MT9V032_CHIP_CONTROL, + MT9V032_CHIP_CONTROL_MASTER_MODE); + if (ret < 0) + goto err; + + return 0; - return regmap_write(map, MT9V032_CHIP_CONTROL, - MT9V032_CHIP_CONTROL_MASTER_MODE); +err: + clk_disable_unprepare(mt9v032->clk); + return ret; } static void mt9v032_power_off(struct mt9v032 *mt9v032) @@ -876,6 +884,9 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) /* Read and check the sensor version */ ret = regmap_read(mt9v032->regmap, MT9V032_CHIP_VERSION, &version); + + mt9v032_power_off(mt9v032); + if (ret < 0) { dev_err(&client->dev, "Failed reading chip version\n"); return ret; @@ -894,8 +905,6 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) return -ENODEV; } - mt9v032_power_off(mt9v032); - dev_info(&client->dev, "%s detected at address 0x%02x\n", mt9v032->version->name, client->addr); -- GitLab From b0fe777884f5cebc46427f63bc9df1a78bfab1a1 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Thu, 3 Aug 2017 09:50:23 -0400 Subject: [PATCH 0023/1190] media: i2c: adv748x: Store the pixel rate ctrl on CSI objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current implementation has to search the list of controls for the pixel rate control, each time it is set. This can be optimised easily by storing the ctrl pointer in the CSI/TX object, and referencing that directly. While at it, fix up a missing blank line also highlighted in review comments. Signed-off-by: Kieran Bingham Tested-by: Niklas Söderlund Acked-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv748x/adv748x-afe.c | 1 + drivers/media/i2c/adv748x/adv748x-csi2.c | 13 +++++++------ drivers/media/i2c/adv748x/adv748x.h | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c index 4aa8e45b5cd39..5188178588c90 100644 --- a/drivers/media/i2c/adv748x/adv748x-afe.c +++ b/drivers/media/i2c/adv748x/adv748x-afe.c @@ -267,6 +267,7 @@ static int adv748x_afe_g_input_status(struct v4l2_subdev *sd, u32 *status) ret = adv748x_afe_status(afe, status, NULL); mutex_unlock(&state->mutex); + return ret; } diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index 979825d4a419b..820b44ed56a86 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -223,13 +223,12 @@ static const struct v4l2_subdev_ops adv748x_csi2_ops = { int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate) { - struct v4l2_ctrl *ctrl; + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); - ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE); - if (!ctrl) + if (!tx->pixel_rate) return -EINVAL; - return v4l2_ctrl_s_ctrl_int64(ctrl, rate); + return v4l2_ctrl_s_ctrl_int64(tx->pixel_rate, rate); } static int adv748x_csi2_s_ctrl(struct v4l2_ctrl *ctrl) @@ -251,8 +250,10 @@ static int adv748x_csi2_init_controls(struct adv748x_csi2 *tx) v4l2_ctrl_handler_init(&tx->ctrl_hdl, 1); - v4l2_ctrl_new_std(&tx->ctrl_hdl, &adv748x_csi2_ctrl_ops, - V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); + tx->pixel_rate = v4l2_ctrl_new_std(&tx->ctrl_hdl, + &adv748x_csi2_ctrl_ops, + V4L2_CID_PIXEL_RATE, 1, INT_MAX, + 1, 1); tx->sd.ctrl_handler = &tx->ctrl_hdl; if (tx->ctrl_hdl.error) { diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h index cc4151b5b31e2..6789e2f3bc8c2 100644 --- a/drivers/media/i2c/adv748x/adv748x.h +++ b/drivers/media/i2c/adv748x/adv748x.h @@ -97,6 +97,7 @@ struct adv748x_csi2 { struct media_pad pads[ADV748X_CSI2_NR_PADS]; struct v4l2_ctrl_handler ctrl_hdl; + struct v4l2_ctrl *pixel_rate; struct v4l2_subdev sd; }; -- GitLab From 12059481fd7d6dc2dc5f2686745bcaa11640e08f Mon Sep 17 00:00:00 2001 From: Srishti Sharma Date: Fri, 8 Sep 2017 10:08:18 -0400 Subject: [PATCH 0024/1190] media: Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON() Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel. Signed-off-by: Srishti Sharma Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index c26c99fd4a24a..b1036baebb035 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss) return; mutex_lock(&iss->iss_mutex); - BUG_ON(iss->ref_count == 0); + WARN_ON(iss->ref_count == 0); if (--iss->ref_count == 0) { iss_disable_interrupts(iss); /* Reset the ISS if an entity has failed to stop. This is the -- GitLab From f54fb924a93b2e74acc0b7033a4b89d2d7886eb3 Mon Sep 17 00:00:00 2001 From: Srishti Sharma Date: Fri, 8 Sep 2017 11:11:09 -0400 Subject: [PATCH 0025/1190] media: Staging: media: imx: Prefer using BIT macro Use BIT(x) instead of (1< Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index d409170632bd3..e5b8d2953be52 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -310,16 +310,16 @@ void imx_media_capture_device_set_format(struct imx_media_video_dev *vdev, void imx_media_capture_device_error(struct imx_media_video_dev *vdev); /* subdev group ids */ -#define IMX_MEDIA_GRP_ID_SENSOR (1 << 8) -#define IMX_MEDIA_GRP_ID_VIDMUX (1 << 9) -#define IMX_MEDIA_GRP_ID_CSI2 (1 << 10) +#define IMX_MEDIA_GRP_ID_SENSOR BIT(8) +#define IMX_MEDIA_GRP_ID_VIDMUX BIT(9) +#define IMX_MEDIA_GRP_ID_CSI2 BIT(10) #define IMX_MEDIA_GRP_ID_CSI_BIT 11 #define IMX_MEDIA_GRP_ID_CSI (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_CSI0 (1 << IMX_MEDIA_GRP_ID_CSI_BIT) +#define IMX_MEDIA_GRP_ID_CSI0 BIT(IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI1 (2 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_VDIC (1 << 13) -#define IMX_MEDIA_GRP_ID_IC_PRP (1 << 14) -#define IMX_MEDIA_GRP_ID_IC_PRPENC (1 << 15) -#define IMX_MEDIA_GRP_ID_IC_PRPVF (1 << 16) +#define IMX_MEDIA_GRP_ID_VDIC BIT(13) +#define IMX_MEDIA_GRP_ID_IC_PRP BIT(14) +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15) +#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(16) #endif -- GitLab From 06ac35e52ba7d934501a37c308c1b0163c706dbf Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 8 Sep 2017 17:08:51 -0400 Subject: [PATCH 0026/1190] media: tuners: mxl5005s: make arrays static const, reduces object code size Don't populate the arrays RegAddr on the stack, instead make them static const. Makes the object code smaller by over 980 bytes: Before: text data bss dec hex filename 64923 304 0 65227 fecb drivers/media/tuners/mxl5005s.o After: text data bss dec hex filename 63779 464 0 64243 faf3 drivers/media/tuners/mxl5005s.o Signed-off-by: Colin Ian King Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/mxl5005s.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c index dd59c2c0e4a52..77a0fa1d1a2f5 100644 --- a/drivers/media/tuners/mxl5005s.c +++ b/drivers/media/tuners/mxl5005s.c @@ -3591,10 +3591,11 @@ static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, u16 status = 0; int i ; - u8 RegAddr[] = { + static const u8 RegAddr[] = { 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73, 76, 77, 91, 134, 135, 137, 147, - 156, 166, 167, 168, 25 }; + 156, 166, 167, 168, 25 + }; *count = ARRAY_SIZE(RegAddr); @@ -3616,11 +3617,15 @@ static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, /* add 77, 166, 167, 168 register for 2.6.12 */ #ifdef _MXL_PRODUCTION - u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106, - 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; + static const u8 RegAddr[] = { + 14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106, + 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 + }; #else - u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106, - 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; + static const u8 RegAddr[] = { + 14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106, + 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 + }; /* u8 RegAddr[171]; for (i = 0; i <= 170; i++) -- GitLab From d259f91c0efb3896daadc1cd0c5207e5c81cb6b7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 15 Sep 2017 15:52:04 -0400 Subject: [PATCH 0027/1190] media: solo6x10: hide unused variable When building without CONFIG_GPIOLIB, we get a harmless warning about an unused variable: drivers/media/pci/solo6x10/solo6x10-gpio.c: In function 'solo_gpio_init': drivers/media/pci/solo6x10/solo6x10-gpio.c:165:6: error: unused variable 'ret' [-Werror=unused-variable] This adds another #ifdef around the declaration. Fixes: d3202d1981dc ("media: solo6x10: export hardware GPIO pins 8:31 to gpiolib interface") Signed-off-by: Arnd Bergmann Signed-off-by: Ismael Luceno Acked-by: Anton Sviridenko Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/solo6x10/solo6x10-gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/solo6x10/solo6x10-gpio.c b/drivers/media/pci/solo6x10/solo6x10-gpio.c index 3d0d1aa2f6a80..7b4641a2cb84b 100644 --- a/drivers/media/pci/solo6x10/solo6x10-gpio.c +++ b/drivers/media/pci/solo6x10/solo6x10-gpio.c @@ -162,7 +162,9 @@ static void solo_gpiochip_set(struct gpio_chip *chip, int solo_gpio_init(struct solo_dev *solo_dev) { +#ifdef CONFIG_GPIOLIB int ret; +#endif solo_gpio_config(solo_dev); #ifdef CONFIG_GPIOLIB -- GitLab From cee32edb2302b6199dd763d44573f6b4f220f0e8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 18 Sep 2017 10:24:44 -0400 Subject: [PATCH 0028/1190] media: cxusb: pass buf as a const u8 * pointer and make buf static const Don't populate the read-only u8 array buf on the stack at run time but instead make it static const; makes object code smaller saving over 480 bytes: Before: text data bss dec hex filename 33030 65936 192 99158 18356 drivers/media/usb/dvb-usb/cxusb.o After: text data bss dec hex filename 32446 66032 192 98670 1816e drivers/media/usb/dvb-usb/cxusb.o Signed-off-by: Colin Ian King Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb/cxusb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 37dea0adc6953..247dc164dd638 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c @@ -56,7 +56,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args) static int cxusb_ctrl_msg(struct dvb_usb_device *d, - u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) + u8 cmd, const u8 *wbuf, int wlen, u8 *rbuf, int rlen) { struct cxusb_state *st = d->priv; int ret; @@ -290,7 +290,8 @@ static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff) /* FIXME: We don't know why, but we need to configure the * lgdt3303 with the register settings below on resume */ int i; - u8 buf, bufs[] = { + u8 buf; + static const u8 bufs[] = { 0x0e, 0x2, 0x00, 0x7f, 0x0e, 0x2, 0x02, 0xfe, 0x0e, 0x2, 0x02, 0x01, -- GitLab From c0f71bbb810237a38734607ca4599632f7f5d47f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 22 Sep 2017 09:07:06 -0400 Subject: [PATCH 0029/1190] media: hdpvr: Fix an error handling path in hdpvr_probe() Here, hdpvr_register_videodev() is responsible for setup and register a video device. Also defining and initializing a worker. hdpvr_register_videodev() is calling by hdpvr_probe at last. So no need to flush any work here. Unregister v4l2, free buffers and memory. If hdpvr_probe() will fail. Signed-off-by: Arvind Yadav Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-core.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index dbe29c6c4d8b3..1e8cbaf368961 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -292,7 +292,7 @@ static int hdpvr_probe(struct usb_interface *interface, /* register v4l2_device early so it can be used for printks */ if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { dev_err(&interface->dev, "v4l2_device_register failed\n"); - goto error; + goto error_free_dev; } mutex_init(&dev->io_mutex); @@ -301,7 +301,7 @@ static int hdpvr_probe(struct usb_interface *interface, dev->usbc_buf = kmalloc(64, GFP_KERNEL); if (!dev->usbc_buf) { v4l2_err(&dev->v4l2_dev, "Out of memory\n"); - goto error; + goto error_v4l2_unregister; } init_waitqueue_head(&dev->wait_buffer); @@ -339,13 +339,13 @@ static int hdpvr_probe(struct usb_interface *interface, } if (!dev->bulk_in_endpointAddr) { v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); - goto error; + goto error_put_usb; } /* init the device */ if (hdpvr_device_init(dev)) { v4l2_err(&dev->v4l2_dev, "device init failed\n"); - goto error; + goto error_put_usb; } mutex_lock(&dev->io_mutex); @@ -353,7 +353,7 @@ static int hdpvr_probe(struct usb_interface *interface, mutex_unlock(&dev->io_mutex); v4l2_err(&dev->v4l2_dev, "allocating transfer buffers failed\n"); - goto error; + goto error_put_usb; } mutex_unlock(&dev->io_mutex); @@ -361,7 +361,7 @@ static int hdpvr_probe(struct usb_interface *interface, retval = hdpvr_register_i2c_adapter(dev); if (retval < 0) { v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); - goto error; + goto error_free_buffers; } client = hdpvr_register_ir_rx_i2c(dev); @@ -394,13 +394,17 @@ static int hdpvr_probe(struct usb_interface *interface, reg_fail: #if IS_ENABLED(CONFIG_I2C) i2c_del_adapter(&dev->i2c_adapter); +error_free_buffers: #endif + hdpvr_free_buffers(dev); +error_put_usb: + usb_put_dev(dev->udev); + kfree(dev->usbc_buf); +error_v4l2_unregister: + v4l2_device_unregister(&dev->v4l2_dev); +error_free_dev: + kfree(dev); error: - if (dev) { - flush_work(&dev->worker); - /* this frees allocated memory */ - hdpvr_delete(dev); - } return retval; } -- GitLab From 6e298d58473520a806d59b7aa51dcb194d1a1b03 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 22 Sep 2017 09:48:41 -0400 Subject: [PATCH 0030/1190] media: stk-webcam: Fix use after free on disconnect We free the stk_camera device too early. It's allocate first in probe and it should be freed last in stk_camera_disconnect(). Reported-by: Andrey Konovalov Signed-off-by: Dan Carpenter Acked-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/stkwebcam/stk-webcam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index c0bba773db25b..e748c976d9675 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c @@ -1241,7 +1241,6 @@ static void stk_v4l_dev_release(struct video_device *vd) if (dev->sio_bufs != NULL || dev->isobufs != NULL) pr_err("We are leaking memory\n"); usb_put_intf(dev->interface); - kfree(dev); } static const struct video_device stk_v4l_data = { @@ -1391,6 +1390,7 @@ static void stk_camera_disconnect(struct usb_interface *interface) video_unregister_device(&dev->vdev); v4l2_ctrl_handler_free(&dev->hdl); v4l2_device_unregister(&dev->v4l2_dev); + kfree(dev); } #ifdef CONFIG_PM -- GitLab From 52173c5f3f6476eb9100691ec47b10d6740eed4a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 22 Sep 2017 14:33:35 -0400 Subject: [PATCH 0031/1190] media: gspca: Convert PERR to gspca_err Use a more typical kernel logging style. The current macro hides the gspca_dev argument so add it to the macro uses instead. Miscellanea: o Add missing '\n' terminations to formats o Realign arguments to open parenthesis Signed-off-by: Joe Perches Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/benq.c | 6 +- drivers/media/usb/gspca/conex.c | 6 +- drivers/media/usb/gspca/cpia1.c | 24 ++++---- drivers/media/usb/gspca/dtcs033.c | 12 ++-- drivers/media/usb/gspca/etoms.c | 4 +- drivers/media/usb/gspca/gl860/gl860.c | 2 +- drivers/media/usb/gspca/gspca.c | 26 +++++---- drivers/media/usb/gspca/gspca.h | 4 +- drivers/media/usb/gspca/jeilinj.c | 2 +- drivers/media/usb/gspca/konica.c | 26 +++++---- drivers/media/usb/gspca/m5602/m5602_core.c | 2 +- drivers/media/usb/gspca/mr97310a.c | 6 +- drivers/media/usb/gspca/ov519.c | 65 ++++++++++++---------- drivers/media/usb/gspca/ov534.c | 4 +- drivers/media/usb/gspca/pac7302.c | 2 +- drivers/media/usb/gspca/pac7311.c | 2 +- drivers/media/usb/gspca/sn9c2028.c | 4 +- drivers/media/usb/gspca/sonixj.c | 4 +- drivers/media/usb/gspca/spca1528.c | 4 +- drivers/media/usb/gspca/spca500.c | 36 ++++++------ drivers/media/usb/gspca/spca501.c | 4 +- drivers/media/usb/gspca/spca505.c | 2 +- drivers/media/usb/gspca/spca508.c | 3 +- drivers/media/usb/gspca/spca561.c | 2 +- drivers/media/usb/gspca/sq905.c | 2 +- drivers/media/usb/gspca/sq905c.c | 6 +- drivers/media/usb/gspca/sq930x.c | 2 +- drivers/media/usb/gspca/stv0680.c | 16 +++--- drivers/media/usb/gspca/stv06xx/stv06xx.c | 10 ++-- drivers/media/usb/gspca/sunplus.c | 2 +- drivers/media/usb/gspca/touptek.c | 38 +++++++------ drivers/media/usb/gspca/w996Xcf.c | 2 +- 32 files changed, 174 insertions(+), 156 deletions(-) diff --git a/drivers/media/usb/gspca/benq.c b/drivers/media/usb/gspca/benq.c index 60a728203b3be..b5955bf0d0fc7 100644 --- a/drivers/media/usb/gspca/benq.c +++ b/drivers/media/usb/gspca/benq.c @@ -180,9 +180,9 @@ static void sd_isoc_irq(struct urb *urb) /* check the packet status and length */ if (urb0->iso_frame_desc[i].actual_length != SD_PKT_SZ || urb->iso_frame_desc[i].actual_length != SD_PKT_SZ) { - PERR("ISOC bad lengths %d / %d", - urb0->iso_frame_desc[i].actual_length, - urb->iso_frame_desc[i].actual_length); + gspca_err(gspca_dev, "ISOC bad lengths %d / %d\n", + urb0->iso_frame_desc[i].actual_length, + urb->iso_frame_desc[i].actual_length); gspca_dev->last_packet_type = DISCARD_PACKET; continue; } diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c index bdcdf7999c564..0223b33156dd1 100644 --- a/drivers/media/usb/gspca/conex.c +++ b/drivers/media/usb/gspca/conex.c @@ -70,7 +70,7 @@ static void reg_r(struct gspca_dev *gspca_dev, struct usb_device *dev = gspca_dev->dev; if (len > USB_BUF_SZ) { - PERR("reg_r: buffer overflow\n"); + gspca_err(gspca_dev, "reg_r: buffer overflow\n"); return; } @@ -109,7 +109,7 @@ static void reg_w(struct gspca_dev *gspca_dev, struct usb_device *dev = gspca_dev->dev; if (len > USB_BUF_SZ) { - PERR("reg_w: buffer overflow\n"); + gspca_err(gspca_dev, "reg_w: buffer overflow\n"); return; } PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); @@ -683,7 +683,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) reg_w_val(gspca_dev, 0x0053, 0x00); } while (--retry); if (retry == 0) - PERR("Damned Errors sending jpeg Table"); + gspca_err(gspca_dev, "Damned Errors sending jpeg Table\n"); /* send the qtable now */ reg_r(gspca_dev, 0x0001, 1); /* -> 0x18 */ length = 8; diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c index e91d00762e94b..99b456d64729e 100644 --- a/drivers/media/usb/gspca/cpia1.c +++ b/drivers/media/usb/gspca/cpia1.c @@ -419,7 +419,8 @@ static int cpia_usb_transferCmd(struct gspca_dev *gspca_dev, u8 *command) pipe = usb_sndctrlpipe(gspca_dev->dev, 0); requesttype = USB_TYPE_VENDOR | USB_RECIP_DEVICE; } else { - PERR("Unexpected first byte of command: %x", command[0]); + gspca_err(gspca_dev, "Unexpected first byte of command: %x\n", + command[0]); return -EINVAL; } @@ -722,8 +723,8 @@ static int goto_low_power(struct gspca_dev *gspca_dev) if (sd->params.status.systemState != LO_POWER_STATE) { if (sd->params.status.systemState != WARM_BOOT_STATE) { - PERR("unexpected state after lo power cmd: %02x", - sd->params.status.systemState); + gspca_err(gspca_dev, "unexpected state after lo power cmd: %02x\n", + sd->params.status.systemState); printstatus(gspca_dev, &sd->params); } return -EIO; @@ -752,8 +753,8 @@ static int goto_high_power(struct gspca_dev *gspca_dev) return ret; if (sd->params.status.systemState != HI_POWER_STATE) { - PERR("unexpected state after hi power cmd: %02x", - sd->params.status.systemState); + gspca_err(gspca_dev, "unexpected state after hi power cmd: %02x\n", + sd->params.status.systemState); printstatus(gspca_dev, &sd->params); return -EIO; } @@ -1445,8 +1446,8 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->params.version.firmwareVersion = 0; get_version_information(gspca_dev); if (sd->params.version.firmwareVersion != 1) { - PERR("only firmware version 1 is supported (got: %d)", - sd->params.version.firmwareVersion); + gspca_err(gspca_dev, "only firmware version 1 is supported (got: %d)\n", + sd->params.version.firmwareVersion); return -ENODEV; } @@ -1471,8 +1472,8 @@ static int sd_start(struct gspca_dev *gspca_dev) /* Start the camera in low power mode */ if (goto_low_power(gspca_dev)) { if (sd->params.status.systemState != WARM_BOOT_STATE) { - PERR("unexpected systemstate: %02x", - sd->params.status.systemState); + gspca_err(gspca_dev, "unexpected systemstate: %02x\n", + sd->params.status.systemState); printstatus(gspca_dev, &sd->params); return -ENODEV; } @@ -1519,8 +1520,9 @@ static int sd_start(struct gspca_dev *gspca_dev) return ret; if (sd->params.status.fatalError) { - PERR("fatal_error: %04x, vp_status: %04x", - sd->params.status.fatalError, sd->params.status.vpStatus); + gspca_err(gspca_dev, "fatal_error: %04x, vp_status: %04x\n", + sd->params.status.fatalError, + sd->params.status.vpStatus); return -EIO; } diff --git a/drivers/media/usb/gspca/dtcs033.c b/drivers/media/usb/gspca/dtcs033.c index 96bfd4e0f0ebf..b4d42940d5de2 100644 --- a/drivers/media/usb/gspca/dtcs033.c +++ b/drivers/media/usb/gspca/dtcs033.c @@ -71,8 +71,8 @@ static int reg_reqs(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) { - PERR("usb error request no: %d / %d\n", - i, n_reqs); + gspca_err(gspca_dev, "usb error request no: %d / %d\n", + i, n_reqs); } else if (preq->bRequestType & USB_DIR_IN) { PDEBUG(D_STREAM, @@ -176,12 +176,12 @@ static void dtcs033_setexposure(struct gspca_dev *gspca_dev, reg_rw(gspca_dev, bRequestType, bRequest, wValue, wIndex, 0); if (gspca_dev->usb_err < 0) - PERR("usb error in setexposure(gain) sequence.\n"); + gspca_err(gspca_dev, "usb error in setexposure(gain) sequence\n"); reg_rw(gspca_dev, bRequestType, bRequest, (xtimeVal<<4), 0x6300, 0); if (gspca_dev->usb_err < 0) - PERR("usb error in setexposure(time) sequence.\n"); + gspca_err(gspca_dev, "usb error in setexposure(time) sequence\n"); } /* specific webcam descriptor */ @@ -239,8 +239,8 @@ static int dtcs033_init_controls(struct gspca_dev *gspca_dev) V4L2_CID_GAIN, 14, 33, 1, 24);/* [dB] */ if (hdl->error) { - PERR("Could not initialize controls: %d\n", - hdl->error); + gspca_err(gspca_dev, "Could not initialize controls: %d\n", + hdl->error); return hdl->error; } diff --git a/drivers/media/usb/gspca/etoms.c b/drivers/media/usb/gspca/etoms.c index 8f84292936e98..a88ae69d6c1e6 100644 --- a/drivers/media/usb/gspca/etoms.c +++ b/drivers/media/usb/gspca/etoms.c @@ -160,7 +160,7 @@ static void reg_r(struct gspca_dev *gspca_dev, struct usb_device *dev = gspca_dev->dev; if (len > USB_BUF_SZ) { - PERR("reg_r: buffer overflow\n"); + gspca_err(gspca_dev, "reg_r: buffer overflow\n"); return; } @@ -268,7 +268,7 @@ static int et_video(struct gspca_dev *gspca_dev, : 0); /* stopvideo */ ret = Et_WaitStatus(gspca_dev); if (ret != 0) - PERR("timeout video on/off"); + gspca_err(gspca_dev, "timeout video on/off\n"); return ret; } diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c index cea8d7f51c3cc..add298cc9ab22 100644 --- a/drivers/media/usb/gspca/gl860/gl860.c +++ b/drivers/media/usb/gspca/gl860/gl860.c @@ -582,7 +582,7 @@ int gl860_RTx(struct gspca_dev *gspca_dev, pr_err("ctrl transfer failed %4d [p%02x r%d v%04x i%04x len%d]\n", r, pref, req, val, index, len); else if (len > 1 && r < len) - PERR("short ctrl transfer %d/%d", r, len); + gspca_err(gspca_dev, "short ctrl transfer %d/%d\n", r, len); msleep(1); diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 961343873fd08..da81cb3059beb 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -122,7 +122,7 @@ static void int_irq(struct urb *urb) case 0: if (gspca_dev->sd_desc->int_pkt_scan(gspca_dev, urb->transfer_buffer, urb->actual_length) < 0) { - PERR("Unknown packet received"); + gspca_err(gspca_dev, "Unknown packet received\n"); } break; @@ -136,7 +136,8 @@ static void int_irq(struct urb *urb) break; default: - PERR("URB error %i, resubmitting", urb->status); + gspca_err(gspca_dev, "URB error %i, resubmitting\n", + urb->status); urb->status = 0; ret = 0; } @@ -221,7 +222,8 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev, urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ret = usb_submit_urb(urb, GFP_KERNEL); if (ret < 0) { - PERR("submit int URB failed with error %i", ret); + gspca_err(gspca_dev, "submit int URB failed with error %i\n", + ret); goto error_submit; } gspca_dev->int_urb = urb; @@ -307,7 +309,7 @@ static void fill_frame(struct gspca_dev *gspca_dev, if (gspca_dev->frozen) return; #endif - PERR("urb status: %d", urb->status); + gspca_err(gspca_dev, "urb status: %d\n", urb->status); urb->status = 0; goto resubmit; } @@ -380,7 +382,7 @@ static void bulk_irq(struct urb *urb) if (gspca_dev->frozen) return; #endif - PERR("urb status: %d", urb->status); + gspca_err(gspca_dev, "urb status: %d\n", urb->status); urb->status = 0; goto resubmit; } @@ -452,9 +454,9 @@ void gspca_frame_add(struct gspca_dev *gspca_dev, /* append the packet to the frame buffer */ if (len > 0) { if (gspca_dev->image_len + len > gspca_dev->frsz) { - PERR("frame overflow %d > %d", - gspca_dev->image_len + len, - gspca_dev->frsz); + gspca_err(gspca_dev, "frame overflow %d > %d\n", + gspca_dev->image_len + len, + gspca_dev->frsz); packet_type = DISCARD_PACKET; } else { /* !! image is NULL only when last pkt is LAST or DISCARD @@ -952,7 +954,8 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) /* the bandwidth is not wide enough * negotiate or try a lower alternate setting */ retry: - PERR("alt %d - bandwidth not wide enough, trying again", alt); + gspca_err(gspca_dev, "alt %d - bandwidth not wide enough, trying again\n", + alt); msleep(20); /* wait for kill complete */ if (gspca_dev->sd_desc->isoc_nego) { ret = gspca_dev->sd_desc->isoc_nego(gspca_dev); @@ -1738,7 +1741,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, frame->data, frame->v4l2_buf.bytesused)) { - PERR("dqbuf cp to user failed"); + gspca_err(gspca_dev, "dqbuf cp to user failed\n"); ret = -EFAULT; } } @@ -1950,7 +1953,8 @@ static ssize_t dev_read(struct file *file, char __user *data, count = frame->v4l2_buf.bytesused; ret = copy_to_user(data, frame->data, count); if (ret != 0) { - PERR("read cp to user lack %d / %zd", ret, count); + gspca_err(gspca_dev, "read cp to user lack %d / %zd\n", + ret, count); ret = -EFAULT; goto out; } diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h index 9e0cf711642b9..da65fef6aaccd 100644 --- a/drivers/media/usb/gspca/gspca.h +++ b/drivers/media/usb/gspca/gspca.h @@ -29,8 +29,8 @@ extern int gspca_debug; #define PDEBUG(level, fmt, ...) \ v4l2_dbg(level, gspca_debug, &gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__) -#define PERR(fmt, ...) \ - v4l2_err(&gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__) +#define gspca_err(gspca_dev, fmt, ...) \ + v4l2_err(&(gspca_dev)->v4l2_dev, fmt, ##__VA_ARGS__) #define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */ /* image transfers */ diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c index 34e043b7d1bc3..7215c68790700 100644 --- a/drivers/media/usb/gspca/jeilinj.c +++ b/drivers/media/usb/gspca/jeilinj.c @@ -262,7 +262,7 @@ static int jlj_start(struct gspca_dev *gspca_dev) msleep(2); setfreq(gspca_dev, v4l2_ctrl_g_ctrl(sd->freq)); if (gspca_dev->usb_err < 0) - PERR("Start streaming command failed"); + gspca_err(gspca_dev, "Start streaming command failed\n"); return gspca_dev->usb_err; } diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c index 31b2117e8f1df..d51aca01167fd 100644 --- a/drivers/media/usb/gspca/konica.c +++ b/drivers/media/usb/gspca/konica.c @@ -274,7 +274,7 @@ static void sd_isoc_irq(struct urb *urb) if (gspca_dev->frozen) return; #endif - PERR("urb status: %d", urb->status); + gspca_err(gspca_dev, "urb status: %d\n", urb->status); st = usb_submit_urb(urb, GFP_ATOMIC); if (st < 0) pr_err("resubmit urb error %d\n", st); @@ -292,30 +292,31 @@ static void sd_isoc_irq(struct urb *urb) sd->last_data_urb = NULL; if (!data_urb || data_urb->start_frame != status_urb->start_frame) { - PERR("lost sync on frames"); + gspca_err(gspca_dev, "lost sync on frames\n"); goto resubmit; } if (data_urb->number_of_packets != status_urb->number_of_packets) { - PERR("no packets does not match, data: %d, status: %d", - data_urb->number_of_packets, - status_urb->number_of_packets); + gspca_err(gspca_dev, "no packets does not match, data: %d, status: %d\n", + data_urb->number_of_packets, + status_urb->number_of_packets); goto resubmit; } for (i = 0; i < status_urb->number_of_packets; i++) { if (data_urb->iso_frame_desc[i].status || status_urb->iso_frame_desc[i].status) { - PERR("pkt %d data-status %d, status-status %d", i, - data_urb->iso_frame_desc[i].status, - status_urb->iso_frame_desc[i].status); + gspca_err(gspca_dev, "pkt %d data-status %d, status-status %d\n", + i, + data_urb->iso_frame_desc[i].status, + status_urb->iso_frame_desc[i].status); gspca_dev->last_packet_type = DISCARD_PACKET; continue; } if (status_urb->iso_frame_desc[i].actual_length != 1) { - PERR("bad status packet length %d", - status_urb->iso_frame_desc[i].actual_length); + gspca_err(gspca_dev, "bad status packet length %d\n", + status_urb->iso_frame_desc[i].actual_length); gspca_dev->last_packet_type = DISCARD_PACKET; continue; } @@ -360,11 +361,12 @@ static void sd_isoc_irq(struct urb *urb) if (data_urb) { st = usb_submit_urb(data_urb, GFP_ATOMIC); if (st < 0) - PERR("usb_submit_urb(data_urb) ret %d", st); + gspca_err(gspca_dev, "usb_submit_urb(data_urb) ret %d\n", + st); } st = usb_submit_urb(status_urb, GFP_ATOMIC); if (st < 0) - PERR("usb_submit_urb(status_urb) ret %d\n", st); + gspca_err(gspca_dev, "usb_submit_urb(status_urb) ret %d\n", st); } static int sd_s_ctrl(struct v4l2_ctrl *ctrl) diff --git a/drivers/media/usb/gspca/m5602/m5602_core.c b/drivers/media/usb/gspca/m5602/m5602_core.c index f1dcd90219838..4aab17efa4cc5 100644 --- a/drivers/media/usb/gspca/m5602/m5602_core.c +++ b/drivers/media/usb/gspca/m5602/m5602_core.c @@ -397,7 +397,7 @@ static int m5602_configure(struct gspca_dev *gspca_dev, return 0; fail: - PERR("ALi m5602 webcam failed"); + gspca_err(gspca_dev, "ALi m5602 webcam failed\n"); cam->cam_mode = NULL; cam->nmodes = 0; diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c index 8b0e32a649acf..34aacaee44534 100644 --- a/drivers/media/usb/gspca/mr97310a.c +++ b/drivers/media/usb/gspca/mr97310a.c @@ -284,7 +284,7 @@ static int zero_the_pointer(struct gspca_dev *gspca_dev) return err_code; } if (status != 0x0a) - PERR("status is %02x", status); + gspca_err(gspca_dev, "status is %02x\n", status); tries = 0; while (tries < 4) { @@ -325,7 +325,7 @@ static void stream_stop(struct gspca_dev *gspca_dev) gspca_dev->usb_buf[0] = 0x01; gspca_dev->usb_buf[1] = 0x00; if (mr_write(gspca_dev, 2) < 0) - PERR("Stream Stop failed"); + gspca_err(gspca_dev, "Stream Stop failed\n"); } static void lcd_stop(struct gspca_dev *gspca_dev) @@ -333,7 +333,7 @@ static void lcd_stop(struct gspca_dev *gspca_dev) gspca_dev->usb_buf[0] = 0x19; gspca_dev->usb_buf[1] = 0x54; if (mr_write(gspca_dev, 2) < 0) - PERR("LCD Stop failed"); + gspca_err(gspca_dev, "LCD Stop failed\n"); } static int isoc_enable(struct gspca_dev *gspca_dev) diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c index 1b30434b72ef2..14ffefbb5ac1b 100644 --- a/drivers/media/usb/gspca/ov519.c +++ b/drivers/media/usb/gspca/ov519.c @@ -2039,7 +2039,7 @@ static void reg_w(struct sd *sd, u16 index, u16 value) sd->gspca_dev.usb_buf, 1, 500); leave: if (ret < 0) { - PERR("reg_w %02x failed %d\n", index, ret); + gspca_err(gspca_dev, "reg_w %02x failed %d\n", index, ret); sd->gspca_dev.usb_err = ret; return; } @@ -2081,7 +2081,7 @@ static int reg_r(struct sd *sd, u16 index) PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", req, index, ret); } else { - PERR("reg_r %02x failed %d\n", index, ret); + gspca_err(gspca_dev, "reg_r %02x failed %d\n", index, ret); sd->gspca_dev.usb_err = ret; } @@ -2109,7 +2109,7 @@ static int reg_r8(struct sd *sd, if (ret >= 0) { ret = sd->gspca_dev.usb_buf[0]; } else { - PERR("reg_r8 %02x failed %d\n", index, ret); + gspca_err(gspca_dev, "reg_r8 %02x failed %d\n", index, ret); sd->gspca_dev.usb_err = ret; } @@ -2165,7 +2165,7 @@ static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) 0, index, sd->gspca_dev.usb_buf, n, 500); if (ret < 0) { - PERR("reg_w32 %02x failed %d\n", index, ret); + gspca_err(gspca_dev, "reg_w32 %02x failed %d\n", index, ret); sd->gspca_dev.usb_err = ret; } } @@ -2340,7 +2340,7 @@ static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) (u16) value, (u16) reg, NULL, 0, 500); if (ret < 0) { - PERR("ovfx2_i2c_w %02x failed %d\n", reg, ret); + gspca_err(gspca_dev, "ovfx2_i2c_w %02x failed %d\n", reg, ret); sd->gspca_dev.usb_err = ret; } @@ -2365,7 +2365,7 @@ static int ovfx2_i2c_r(struct sd *sd, u8 reg) ret = sd->gspca_dev.usb_buf[0]; PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret); } else { - PERR("ovfx2_i2c_r %02x failed %d\n", reg, ret); + gspca_err(gspca_dev, "ovfx2_i2c_r %02x failed %d\n", reg, ret); sd->gspca_dev.usb_err = ret; } @@ -2617,7 +2617,7 @@ static void ov_hires_configure(struct sd *sd) int high, low; if (sd->bridge != BRIDGE_OVFX2) { - PERR("error hires sensors only supported with ovfx2\n"); + gspca_err(gspca_dev, "error hires sensors only supported with ovfx2\n"); return; } @@ -2652,7 +2652,8 @@ static void ov_hires_configure(struct sd *sd) } break; } - PERR("Error unknown sensor type: %02x%02x\n", high, low); + gspca_err(gspca_dev, "Error unknown sensor type: %02x%02x\n", + high, low); } /* This initializes the OV8110, OV8610 sensor. The OV8110 uses @@ -2668,13 +2669,14 @@ static void ov8xx0_configure(struct sd *sd) /* Detect sensor (sub)type */ rc = i2c_r(sd, OV7610_REG_COM_I); if (rc < 0) { - PERR("Error detecting sensor type"); + gspca_err(gspca_dev, "Error detecting sensor type\n"); return; } if ((rc & 3) == 1) sd->sensor = SEN_OV8610; else - PERR("Unknown image sensor version: %d\n", rc & 3); + gspca_err(gspca_dev, "Unknown image sensor version: %d\n", + rc & 3); } /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses @@ -2693,7 +2695,7 @@ static void ov7xx0_configure(struct sd *sd) /* add OV7670 here * it appears to be wrongly detected as a 7610 by default */ if (rc < 0) { - PERR("Error detecting sensor type\n"); + gspca_err(gspca_dev, "Error detecting sensor type\n"); return; } if ((rc & 3) == 3) { @@ -2721,19 +2723,19 @@ static void ov7xx0_configure(struct sd *sd) /* try to read product id registers */ high = i2c_r(sd, 0x0a); if (high < 0) { - PERR("Error detecting camera chip PID\n"); + gspca_err(gspca_dev, "Error detecting camera chip PID\n"); return; } low = i2c_r(sd, 0x0b); if (low < 0) { - PERR("Error detecting camera chip VER\n"); + gspca_err(gspca_dev, "Error detecting camera chip VER\n"); return; } if (high == 0x76) { switch (low) { case 0x30: - PERR("Sensor is an OV7630/OV7635\n"); - PERR("7630 is not supported by this driver\n"); + gspca_err(gspca_dev, "Sensor is an OV7630/OV7635\n"); + gspca_err(gspca_dev, "7630 is not supported by this driver\n"); return; case 0x40: PDEBUG(D_PROBE, "Sensor is an OV7645"); @@ -2752,7 +2754,8 @@ static void ov7xx0_configure(struct sd *sd) sd->sensor = SEN_OV7660; break; default: - PERR("Unknown sensor: 0x76%02x\n", low); + gspca_err(gspca_dev, "Unknown sensor: 0x76%02x\n", + low); return; } } else { @@ -2760,7 +2763,8 @@ static void ov7xx0_configure(struct sd *sd) sd->sensor = SEN_OV7620; } } else { - PERR("Unknown image sensor version: %d\n", rc & 3); + gspca_err(gspca_dev, "Unknown image sensor version: %d\n", + rc & 3); } } @@ -2775,7 +2779,7 @@ static void ov6xx0_configure(struct sd *sd) /* Detect sensor (sub)type */ rc = i2c_r(sd, OV7610_REG_COM_I); if (rc < 0) { - PERR("Error detecting sensor type\n"); + gspca_err(gspca_dev, "Error detecting sensor type\n"); return; } @@ -2804,7 +2808,8 @@ static void ov6xx0_configure(struct sd *sd) pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n"); break; default: - PERR("FATAL: Unknown sensor version: 0x%02x\n", rc); + gspca_err(gspca_dev, "FATAL: Unknown sensor version: 0x%02x\n", + rc); return; } @@ -3295,7 +3300,7 @@ static int sd_init(struct gspca_dev *gspca_dev) } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { ov_hires_configure(sd); } else { - PERR("Can't determine sensor slave IDs\n"); + gspca_err(gspca_dev, "Can't determine sensor slave IDs\n"); goto error; } @@ -3428,7 +3433,7 @@ static int sd_init(struct gspca_dev *gspca_dev) } return gspca_dev->usb_err; error: - PERR("OV519 Config failed"); + gspca_err(gspca_dev, "OV519 Config failed\n"); return -EINVAL; } @@ -3463,7 +3468,7 @@ static void ov511_mode_init_regs(struct sd *sd) intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); if (!alt) { - PERR("Couldn't get altsetting\n"); + gspca_err(gspca_dev, "Couldn't get altsetting\n"); sd->gspca_dev.usb_err = -EIO; return; } @@ -3589,7 +3594,7 @@ static void ov518_mode_init_regs(struct sd *sd) intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); if (!alt) { - PERR("Couldn't get altsetting\n"); + gspca_err(gspca_dev, "Couldn't get altsetting\n"); sd->gspca_dev.usb_err = -EIO; return; } @@ -4323,10 +4328,10 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev, /* Frame end */ if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width || (in[10] + 1) * 8 != gspca_dev->pixfmt.height) { - PERR("Invalid frame size, got: %dx%d, requested: %dx%d\n", - (in[9] + 1) * 8, (in[10] + 1) * 8, - gspca_dev->pixfmt.width, - gspca_dev->pixfmt.height); + gspca_err(gspca_dev, "Invalid frame size, got: %dx%d, requested: %dx%d\n", + (in[9] + 1) * 8, (in[10] + 1) * 8, + gspca_dev->pixfmt.width, + gspca_dev->pixfmt.height); gspca_dev->last_packet_type = DISCARD_PACKET; return; } @@ -4374,8 +4379,8 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev, except that they may contain part of the footer), are numbered 0 */ else if (sd->packet_nr == 0 || data[len]) { - PERR("Invalid packet nr: %d (expect: %d)", - (int)data[len], (int)sd->packet_nr); + gspca_err(gspca_dev, "Invalid packet nr: %d (expect: %d)\n", + (int)data[len], (int)sd->packet_nr); gspca_dev->last_packet_type = DISCARD_PACKET; return; } @@ -4918,7 +4923,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF); if (hdl->error) { - PERR("Could not initialize controls\n"); + gspca_err(gspca_dev, "Could not initialize controls\n"); return hdl->error; } if (gspca_dev->autogain) diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c index 32849ff86b09d..bba2c5ce331c9 100644 --- a/drivers/media/usb/gspca/ov534.c +++ b/drivers/media/usb/gspca/ov534.c @@ -689,8 +689,8 @@ static int sccb_check_status(struct gspca_dev *gspca_dev) case 0x03: break; default: - PERR("sccb status 0x%02x, attempt %d/5", - data, i + 1); + gspca_err(gspca_dev, "sccb status 0x%02x, attempt %d/5\n", + data, i + 1); } } return 0; diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c index 595535e143e64..b8ff201c7bb92 100644 --- a/drivers/media/usb/gspca/pac7302.c +++ b/drivers/media/usb/gspca/pac7302.c @@ -339,7 +339,7 @@ static void reg_w_var(struct gspca_dev *gspca_dev, break; default: if (len > USB_BUF_SZ) { - PERR("Incorrect variable sequence"); + gspca_err(gspca_dev, "Incorrect variable sequence\n"); return; } while (len > 0) { diff --git a/drivers/media/usb/gspca/pac7311.c b/drivers/media/usb/gspca/pac7311.c index 8bac2d9326bf8..44db4f4afa221 100644 --- a/drivers/media/usb/gspca/pac7311.c +++ b/drivers/media/usb/gspca/pac7311.c @@ -258,7 +258,7 @@ static void reg_w_var(struct gspca_dev *gspca_dev, break; default: if (len > USB_BUF_SZ) { - PERR("Incorrect variable sequence"); + gspca_err(gspca_dev, "Incorrect variable sequence\n"); return; } while (len > 0) { diff --git a/drivers/media/usb/gspca/sn9c2028.c b/drivers/media/usb/gspca/sn9c2028.c index 5d32dd359d84d..469bc2ced1a3d 100644 --- a/drivers/media/usb/gspca/sn9c2028.c +++ b/drivers/media/usb/gspca/sn9c2028.c @@ -849,13 +849,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) result = sn9c2028_read1(gspca_dev); if (result < 0) - PERR("Camera Stop read failed"); + gspca_err(gspca_dev, "Camera Stop read failed\n"); memset(data, 0, 6); data[0] = 0x14; result = sn9c2028_command(gspca_dev, data); if (result < 0) - PERR("Camera Stop command failed"); + gspca_err(gspca_dev, "Camera Stop command failed\n"); } static void do_autogain(struct gspca_dev *gspca_dev, int avg_lum) diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c index 5eeaf16ac5e82..9d7c3d8c226fe 100644 --- a/drivers/media/usb/gspca/sonixj.c +++ b/drivers/media/usb/gspca/sonixj.c @@ -1155,7 +1155,7 @@ static void reg_r(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; if (len > USB_BUF_SZ) { - PERR("reg_r: buffer overflow\n"); + gspca_err(gspca_dev, "reg_r: buffer overflow\n"); return; } @@ -1209,7 +1209,7 @@ static void reg_w(struct gspca_dev *gspca_dev, value, buffer[0], buffer[1]); if (len > USB_BUF_SZ) { - PERR("reg_w: buffer overflow\n"); + gspca_err(gspca_dev, "reg_w: buffer overflow\n"); return; } diff --git a/drivers/media/usb/gspca/spca1528.c b/drivers/media/usb/gspca/spca1528.c index 327ec901abe14..e53dd3c7066cc 100644 --- a/drivers/media/usb/gspca/spca1528.c +++ b/drivers/media/usb/gspca/spca1528.c @@ -142,7 +142,7 @@ static void wait_status_0(struct gspca_dev *gspca_dev) w += 15; msleep(w); } while (--i > 0); - PERR("wait_status_0 timeout"); + gspca_err(gspca_dev, "wait_status_0 timeout\n"); gspca_dev->usb_err = -ETIME; } @@ -160,7 +160,7 @@ static void wait_status_1(struct gspca_dev *gspca_dev) return; } } while (--i > 0); - PERR("wait_status_1 timeout"); + gspca_err(gspca_dev, "wait_status_1 timeout\n"); gspca_dev->usb_err = -ETIME; } diff --git a/drivers/media/usb/gspca/spca500.c b/drivers/media/usb/gspca/spca500.c index da2d9027914c6..b25960643f7b2 100644 --- a/drivers/media/usb/gspca/spca500.c +++ b/drivers/media/usb/gspca/spca500.c @@ -485,7 +485,7 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev) return err; err = reg_r_wait(gspca_dev, 0x06, 0, 0); if (err < 0) { - PERR("reg_r_wait() failed"); + gspca_err(gspca_dev, "reg_r_wait() failed\n"); return err; } /* all ok */ @@ -501,7 +501,7 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev) static int spca500_synch310(struct gspca_dev *gspca_dev) { if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) { - PERR("Set packet size: set interface error"); + gspca_err(gspca_dev, "Set packet size: set interface error\n"); goto error; } spca500_ping310(gspca_dev); @@ -515,7 +515,7 @@ static int spca500_synch310(struct gspca_dev *gspca_dev) if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, gspca_dev->alt) < 0) { - PERR("Set packet size: set interface error"); + gspca_err(gspca_dev, "Set packet size: set interface error\n"); goto error; } return 0; @@ -540,7 +540,7 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, qtable_pocketdv); if (err < 0) - PERR("spca50x_setup_qtable failed on init"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed on init\n"); /* set qtable index */ reg_w(gspca_dev, 0x00, 0x8880, 2); @@ -636,7 +636,7 @@ static int sd_start(struct gspca_dev *gspca_dev) 0x00, 0x8800, 0x8840, qtable_creative_pccam); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); /* Init SDRAM - needed for SDRAM access */ reg_w(gspca_dev, 0x00, 0x870a, 0x04); @@ -644,7 +644,7 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x00, 0x8000, 0x0004); msleep(500); if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) - PERR("reg_r_wait() failed"); + gspca_err(gspca_dev, "reg_r_wait() failed\n"); reg_r(gspca_dev, 0x816b, 1); Data = gspca_dev->usb_buf[0]; @@ -657,13 +657,13 @@ static int sd_start(struct gspca_dev *gspca_dev) /* enable drop packet */ err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001); if (err < 0) - PERR("failed to enable drop packet"); + gspca_err(gspca_dev, "failed to enable drop packet\n"); reg_w(gspca_dev, 0x00, 0x8880, 3); err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, qtable_creative_pccam); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); /* Init SDRAM - needed for SDRAM access */ reg_w(gspca_dev, 0x00, 0x870a, 0x04); @@ -672,7 +672,7 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x00, 0x8000, 0x0004); if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) - PERR("reg_r_wait() failed"); + gspca_err(gspca_dev, "reg_r_wait() failed\n"); reg_r(gspca_dev, 0x816b, 1); Data = gspca_dev->usb_buf[0]; @@ -686,18 +686,18 @@ static int sd_start(struct gspca_dev *gspca_dev) /* do a full reset */ err = spca500_full_reset(gspca_dev); if (err < 0) - PERR("spca500_full_reset failed"); + gspca_err(gspca_dev, "spca500_full_reset failed\n"); /* enable drop packet */ err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001); if (err < 0) - PERR("failed to enable drop packet"); + gspca_err(gspca_dev, "failed to enable drop packet\n"); reg_w(gspca_dev, 0x00, 0x8880, 3); err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, qtable_creative_pccam); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); spca500_setmode(gspca_dev, xmult, ymult); reg_w(gspca_dev, 0x20, 0x0001, 0x0004); @@ -706,7 +706,7 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x00, 0x8000, 0x0004); if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) - PERR("reg_r_wait() failed"); + gspca_err(gspca_dev, "reg_r_wait() failed\n"); reg_r(gspca_dev, 0x816b, 1); Data = gspca_dev->usb_buf[0]; @@ -719,7 +719,7 @@ static int sd_start(struct gspca_dev *gspca_dev) /* do a full reset */ err = spca500_full_reset(gspca_dev); if (err < 0) - PERR("spca500_full_reset failed"); + gspca_err(gspca_dev, "spca500_full_reset failed\n"); /* enable drop packet */ reg_w(gspca_dev, 0x00, 0x850a, 0x0001); reg_w(gspca_dev, 0x00, 0x8880, 0); @@ -727,7 +727,7 @@ static int sd_start(struct gspca_dev *gspca_dev) 0x00, 0x8800, 0x8840, qtable_kodak_ez200); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); spca500_setmode(gspca_dev, xmult, ymult); reg_w(gspca_dev, 0x20, 0x0001, 0x0004); @@ -736,7 +736,7 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x00, 0x8000, 0x0004); if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) - PERR("reg_r_wait() failed"); + gspca_err(gspca_dev, "reg_r_wait() failed\n"); reg_r(gspca_dev, 0x816b, 1); Data = gspca_dev->usb_buf[0]; @@ -762,7 +762,7 @@ static int sd_start(struct gspca_dev *gspca_dev) err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, qtable_pocketdv); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); reg_w(gspca_dev, 0x00, 0x8880, 2); /* familycam Quicksmart pocketDV stuff */ @@ -792,7 +792,7 @@ static int sd_start(struct gspca_dev *gspca_dev) 0x00, 0x8800, 0x8840, qtable_creative_pccam); if (err < 0) - PERR("spca50x_setup_qtable failed"); + gspca_err(gspca_dev, "spca50x_setup_qtable failed\n"); reg_w(gspca_dev, 0x00, 0x8880, 3); reg_w(gspca_dev, 0x00, 0x800a, 0x00); /* Init SDRAM - needed for SDRAM access */ diff --git a/drivers/media/usb/gspca/spca501.c b/drivers/media/usb/gspca/spca501.c index ae5a80987553a..29861588302f8 100644 --- a/drivers/media/usb/gspca/spca501.c +++ b/drivers/media/usb/gspca/spca501.c @@ -1779,8 +1779,8 @@ static int write_vector(struct gspca_dev *gspca_dev, const __u16 data[][3]) ret = reg_write(gspca_dev, data[i][0], data[i][2], data[i][1]); if (ret < 0) { - PERR("Reg write failed for 0x%02x,0x%02x,0x%02x", - data[i][0], data[i][1], data[i][2]); + gspca_err(gspca_dev, "Reg write failed for 0x%02x,0x%02x,0x%02x\n", + data[i][0], data[i][1], data[i][2]); return ret; } i++; diff --git a/drivers/media/usb/gspca/spca505.c b/drivers/media/usb/gspca/spca505.c index 1553cc766c042..02b5e2d81c643 100644 --- a/drivers/media/usb/gspca/spca505.c +++ b/drivers/media/usb/gspca/spca505.c @@ -650,7 +650,7 @@ static int sd_start(struct gspca_dev *gspca_dev) ret = reg_read(gspca_dev, 0x06, 0x16); if (ret < 0) { - PERR("register read failed err: %d", ret); + gspca_err(gspca_dev, "register read failed err: %d\n", ret); return ret; } if (ret != 0x0101) { diff --git a/drivers/media/usb/gspca/spca508.c b/drivers/media/usb/gspca/spca508.c index 1e0ba6b24e218..aafffaf1d2b52 100644 --- a/drivers/media/usb/gspca/spca508.c +++ b/drivers/media/usb/gspca/spca508.c @@ -1309,7 +1309,8 @@ static int ssi_w(struct gspca_dev *gspca_dev, if (gspca_dev->usb_buf[0] == 0) break; if (--retry <= 0) { - PERR("ssi_w busy %02x", gspca_dev->usb_buf[0]); + gspca_err(gspca_dev, "ssi_w busy %02x\n", + gspca_dev->usb_buf[0]); ret = -1; break; } diff --git a/drivers/media/usb/gspca/spca561.c b/drivers/media/usb/gspca/spca561.c index 4ff704cf9ed6c..a75bd90bd9e3e 100644 --- a/drivers/media/usb/gspca/spca561.c +++ b/drivers/media/usb/gspca/spca561.c @@ -728,7 +728,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, /* This should never happen */ if (len < 2) { - PERR("Short SOF packet, ignoring"); + gspca_err(gspca_dev, "Short SOF packet, ignoring\n"); gspca_dev->last_packet_type = DISCARD_PACKET; return; } diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c index f1da34a10ce88..948808305a6af 100644 --- a/drivers/media/usb/gspca/sq905.c +++ b/drivers/media/usb/gspca/sq905.c @@ -382,7 +382,7 @@ static int sd_start(struct gspca_dev *gspca_dev) } if (ret < 0) { - PERR("Start streaming command failed"); + gspca_err(gspca_dev, "Start streaming command failed\n"); return ret; } /* Start the workqueue function to do the streaming */ diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c index 8b4e4948a0cb6..4fbfcf366f71c 100644 --- a/drivers/media/usb/gspca/sq905c.c +++ b/drivers/media/usb/gspca/sq905c.c @@ -211,13 +211,13 @@ static int sd_config(struct gspca_dev *gspca_dev, ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0); if (ret < 0) { - PERR("Get version command failed"); + gspca_err(gspca_dev, "Get version command failed\n"); return ret; } ret = sq905c_read(gspca_dev, 0xf5, 0, 20); if (ret < 0) { - PERR("Reading version command failed"); + gspca_err(gspca_dev, "Reading version command failed\n"); return ret; } /* Note we leave out the usb id and the manufacturing date */ @@ -279,7 +279,7 @@ static int sd_start(struct gspca_dev *gspca_dev) } if (ret < 0) { - PERR("Start streaming command failed"); + gspca_err(gspca_dev, "Start streaming command failed\n"); return ret; } /* Start the workqueue function to do the streaming */ diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c index aa9a9411b8018..af48bd6dbe8cd 100644 --- a/drivers/media/usb/gspca/sq930x.c +++ b/drivers/media/usb/gspca/sq930x.c @@ -538,7 +538,7 @@ static void ucbus_write(struct gspca_dev *gspca_dev, return; if ((batchsize - 1) * 3 > USB_BUF_SZ) { - PERR("Bug: usb_buf overflow\n"); + gspca_err(gspca_dev, "Bug: usb_buf overflow\n"); gspca_dev->usb_err = -ENOMEM; return; } diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c index 29a65d05cbb22..4ff6ae18d8dd2 100644 --- a/drivers/media/usb/gspca/stv0680.c +++ b/drivers/media/usb/gspca/stv0680.c @@ -82,8 +82,8 @@ static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val, static int stv0680_handle_error(struct gspca_dev *gspca_dev, int ret) { stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02); /* Get Last Error */ - PERR("last error: %i, command = 0x%x", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); + gspca_err(gspca_dev, "last error: %i, command = 0x%x\n", + gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); return ret; } @@ -94,7 +94,7 @@ static int stv0680_get_video_mode(struct gspca_dev *gspca_dev) gspca_dev->usb_buf[0] = 0x0f; if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) { - PERR("Get_Camera_Mode failed"); + gspca_err(gspca_dev, "Get_Camera_Mode failed\n"); return stv0680_handle_error(gspca_dev, -EIO); } @@ -112,13 +112,13 @@ static int stv0680_set_video_mode(struct gspca_dev *gspca_dev, u8 mode) gspca_dev->usb_buf[0] = mode; if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) { - PERR("Set_Camera_Mode failed"); + gspca_err(gspca_dev, "Set_Camera_Mode failed\n"); return stv0680_handle_error(gspca_dev, -EIO); } /* Verify we got what we've asked for */ if (stv0680_get_video_mode(gspca_dev) != mode) { - PERR("Error setting camera video mode!"); + gspca_err(gspca_dev, "Error setting camera video mode!\n"); return -EIO; } @@ -142,7 +142,7 @@ static int sd_config(struct gspca_dev *gspca_dev, /* ping camera to be sure STV0680 is present */ if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 || gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) { - PERR("STV(e): camera ping failed!!"); + gspca_err(gspca_dev, "STV(e): camera ping failed!!\n"); return stv0680_handle_error(gspca_dev, -ENODEV); } @@ -152,7 +152,7 @@ static int sd_config(struct gspca_dev *gspca_dev, if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 || gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) { - PERR("Could not get descriptor 0200."); + gspca_err(gspca_dev, "Could not get descriptor 0200\n"); return stv0680_handle_error(gspca_dev, -ENODEV); } if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02) @@ -163,7 +163,7 @@ static int sd_config(struct gspca_dev *gspca_dev, return stv0680_handle_error(gspca_dev, -ENODEV); if (!(gspca_dev->usb_buf[7] & 0x09)) { - PERR("Camera supports neither CIF nor QVGA mode"); + gspca_err(gspca_dev, "Camera supports neither CIF nor QVGA mode\n"); return -ENODEV; } if (gspca_dev->usb_buf[7] & 0x01) diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c index e72c3e1ab9ff4..3db1c24b3d6d7 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c @@ -285,7 +285,7 @@ static int stv06xx_start(struct gspca_dev *gspca_dev) intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); if (!alt) { - PERR("Couldn't get altsetting"); + gspca_err(gspca_dev, "Couldn't get altsetting\n"); return -EIO; } @@ -343,7 +343,7 @@ static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev) ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); if (ret < 0) - PERR("set alt 1 err %d", ret); + gspca_err(gspca_dev, "set alt 1 err %d\n", ret); return ret; } @@ -408,7 +408,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, len -= 4; if (len < chunk_len) { - PERR("URB packet length is smaller than the specified chunk length"); + gspca_err(gspca_dev, "URB packet length is smaller than the specified chunk length\n"); gspca_dev->last_packet_type = DISCARD_PACKET; return; } @@ -450,7 +450,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, sd->to_skip = gspca_dev->pixfmt.width * 4; if (chunk_len) - PERR("Chunk length is non-zero on a SOF"); + gspca_err(gspca_dev, "Chunk length is non-zero on a SOF\n"); break; case 0x8002: @@ -463,7 +463,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, NULL, 0); if (chunk_len) - PERR("Chunk length is non-zero on a EOF"); + gspca_err(gspca_dev, "Chunk length is non-zero on a EOF\n"); break; case 0x0005: diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c index 8c2785aea3cd0..44b07344f0f72 100644 --- a/drivers/media/usb/gspca/sunplus.c +++ b/drivers/media/usb/gspca/sunplus.c @@ -248,7 +248,7 @@ static void reg_r(struct gspca_dev *gspca_dev, int ret; if (len > USB_BUF_SZ) { - PERR("reg_r: buffer overflow\n"); + gspca_err(gspca_dev, "reg_r: buffer overflow\n"); return; } if (gspca_dev->usb_err < 0) diff --git a/drivers/media/usb/gspca/touptek.c b/drivers/media/usb/gspca/touptek.c index b8af4370d27c5..a1bb1704d3394 100644 --- a/drivers/media/usb/gspca/touptek.c +++ b/drivers/media/usb/gspca/touptek.c @@ -195,15 +195,15 @@ static const struct v4l2_pix_format vga_mode[] = { static int val_reply(struct gspca_dev *gspca_dev, const char *reply, int rc) { if (rc < 0) { - PERR("reply has error %d", rc); + gspca_err(gspca_dev, "reply has error %d\n", rc); return -EIO; } if (rc != 1) { - PERR("Bad reply size %d", rc); + gspca_err(gspca_dev, "Bad reply size %d\n", rc); return -EIO; } if (reply[0] != 0x08) { - PERR("Bad reply 0x%02x", (int)reply[0]); + gspca_err(gspca_dev, "Bad reply 0x%02x\n", (int)reply[0]); return -EIO; } return 0; @@ -221,14 +221,14 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) 0x0B, 0xC0, value, index, buff, 1, 500); PDEBUG(D_USBO, "rc=%d, ret={0x%02x}", rc, (int)buff[0]); if (rc < 0) { - PERR("Failed reg_w(0x0B, 0xC0, 0x%04X, 0x%04X) w/ rc %d\n", - value, index, rc); + gspca_err(gspca_dev, "Failed reg_w(0x0B, 0xC0, 0x%04X, 0x%04X) w/ rc %d\n", + value, index, rc); gspca_dev->usb_err = rc; return; } if (val_reply(gspca_dev, buff, rc)) { - PERR("Bad reply to reg_w(0x0B, 0xC0, 0x%04X, 0x%04X\n", - value, index); + gspca_err(gspca_dev, "Bad reply to reg_w(0x0B, 0xC0, 0x%04X, 0x%04X\n", + value, index); gspca_dev->usb_err = -EIO; } } @@ -254,7 +254,7 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 val) else if (w == 3264) value = val * 3 / 2; else { - PERR("Invalid width %u\n", w); + gspca_err(gspca_dev, "Invalid width %u\n", w); gspca_dev->usb_err = -EINVAL; return; } @@ -372,7 +372,7 @@ static void configure_wh(struct gspca_dev *gspca_dev) reg_w_buf(gspca_dev, reg_init_res, ARRAY_SIZE(reg_init_res)); } else { - PERR("bad width %u\n", w); + gspca_err(gspca_dev, "bad width %u\n", w); gspca_dev->usb_err = -EINVAL; return; } @@ -392,7 +392,7 @@ static void configure_wh(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x0B4B, REG_FRAME_LENGTH_LINES_); reg_w(gspca_dev, 0x1F40, REG_LINE_LENGTH_PCK_); } else { - PERR("bad width %u\n", w); + gspca_err(gspca_dev, "bad width %u\n", w); gspca_dev->usb_err = -EINVAL; return; } @@ -458,7 +458,7 @@ static int configure(struct gspca_dev *gspca_dev) rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 0x16, 0xC0, 0x0000, 0x0000, buff, 2, 500); if (val_reply(gspca_dev, buff, rc)) { - PERR("failed key req"); + gspca_err(gspca_dev, "failed key req\n"); return -EIO; } @@ -475,21 +475,24 @@ static int configure(struct gspca_dev *gspca_dev) rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x01, 0x40, 0x0001, 0x000F, NULL, 0, 500); if (rc < 0) { - PERR("failed to replay packet 176 w/ rc %d\n", rc); + gspca_err(gspca_dev, "failed to replay packet 176 w/ rc %d\n", + rc); return rc; } rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x01, 0x40, 0x0000, 0x000F, NULL, 0, 500); if (rc < 0) { - PERR("failed to replay packet 178 w/ rc %d\n", rc); + gspca_err(gspca_dev, "failed to replay packet 178 w/ rc %d\n", + rc); return rc; } rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x01, 0x40, 0x0001, 0x000F, NULL, 0, 500); if (rc < 0) { - PERR("failed to replay packet 180 w/ rc %d\n", rc); + gspca_err(gspca_dev, "failed to replay packet 180 w/ rc %d\n", + rc); return rc; } @@ -511,7 +514,8 @@ static int configure(struct gspca_dev *gspca_dev) rc = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x01, 0x40, 0x0003, 0x000F, NULL, 0, 500); if (rc < 0) { - PERR("failed to replay final packet w/ rc %d\n", rc); + gspca_err(gspca_dev, "failed to replay final packet w/ rc %d\n", + rc); return rc; } @@ -545,7 +549,7 @@ static int sd_start(struct gspca_dev *gspca_dev) rc = configure(gspca_dev); if (rc < 0) { - PERR("Failed configure"); + gspca_err(gspca_dev, "Failed configure\n"); return rc; } /* First two frames have messed up gains @@ -641,7 +645,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) V4L2_CID_RED_BALANCE, 0, 1023, 1, 295); if (hdl->error) { - PERR("Could not initialize controls\n"); + gspca_err(gspca_dev, "Could not initialize controls\n"); return hdl->error; } return 0; diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c index 728d2322c433a..d149cb7f00190 100644 --- a/drivers/media/usb/gspca/w996Xcf.c +++ b/drivers/media/usb/gspca/w996Xcf.c @@ -333,7 +333,7 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) ret = value; PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); } else - PERR("i2c read [0x%02x] failed", reg); + gspca_err(gspca_dev, "i2c read [0x%02x] failed\n", reg); return ret; } -- GitLab From 37d5efb01910752d8d3846a2c4db0528c1dfa137 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 22 Sep 2017 15:20:33 -0400 Subject: [PATCH 0032/1190] media: gspca: Convert PDEBUG to gspca_dbg Use a more typical logging style. The current macro hides the gspca_dev argument so add it to the macro uses instead. Miscellanea: o Add missing '\n' terminations to formats o Realign arguments to open parenthesis o Remove commented out uses of PDEBUG Signed-off-by: Joe Perches Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/autogain_functions.c | 16 +-- drivers/media/usb/gspca/benq.c | 2 +- drivers/media/usb/gspca/conex.c | 7 +- drivers/media/usb/gspca/cpia1.c | 50 +++---- drivers/media/usb/gspca/dtcs033.c | 16 +-- drivers/media/usb/gspca/etoms.c | 34 ++--- drivers/media/usb/gspca/finepix.c | 4 +- drivers/media/usb/gspca/gl860/gl860.c | 35 ++--- drivers/media/usb/gspca/gspca.c | 127 +++++++++--------- drivers/media/usb/gspca/gspca.h | 5 +- drivers/media/usb/gspca/jeilinj.c | 17 +-- drivers/media/usb/gspca/jl2005bcd.c | 45 ++++--- drivers/media/usb/gspca/kinect.c | 11 +- drivers/media/usb/gspca/konica.c | 2 +- drivers/media/usb/gspca/m5602/m5602_core.c | 32 ++--- drivers/media/usb/gspca/m5602/m5602_mt9m111.c | 21 +-- drivers/media/usb/gspca/m5602/m5602_ov7660.c | 11 +- drivers/media/usb/gspca/m5602/m5602_ov9650.c | 26 ++-- drivers/media/usb/gspca/m5602/m5602_po1030.c | 27 ++-- drivers/media/usb/gspca/m5602/m5602_s5k4aa.c | 16 +-- drivers/media/usb/gspca/m5602/m5602_s5k83a.c | 2 +- drivers/media/usb/gspca/mars.c | 4 +- drivers/media/usb/gspca/mr97310a.c | 23 ++-- drivers/media/usb/gspca/nw80x.c | 24 ++-- drivers/media/usb/gspca/ov519.c | 90 +++++++------ drivers/media/usb/gspca/ov534.c | 21 +-- drivers/media/usb/gspca/ov534_9.c | 23 ++-- drivers/media/usb/gspca/pac207.c | 16 +-- drivers/media/usb/gspca/pac_common.h | 7 +- drivers/media/usb/gspca/sn9c2028.c | 30 +++-- drivers/media/usb/gspca/sn9c2028.h | 7 +- drivers/media/usb/gspca/sn9c20x.c | 2 +- drivers/media/usb/gspca/sonixj.c | 54 ++++---- drivers/media/usb/gspca/spca1528.c | 13 +- drivers/media/usb/gspca/spca500.c | 30 +++-- drivers/media/usb/gspca/spca501.c | 6 +- drivers/media/usb/gspca/spca505.c | 4 +- drivers/media/usb/gspca/spca506.c | 16 ++- drivers/media/usb/gspca/spca508.c | 17 ++- drivers/media/usb/gspca/spca561.c | 20 +-- drivers/media/usb/gspca/sq905.c | 14 +- drivers/media/usb/gspca/sq905c.c | 31 ++--- drivers/media/usb/gspca/sq930x.c | 27 ++-- drivers/media/usb/gspca/stk014.c | 6 +- drivers/media/usb/gspca/stk1135.c | 15 ++- drivers/media/usb/gspca/stv0680.c | 20 +-- drivers/media/usb/gspca/stv06xx/stv06xx.c | 64 ++++----- .../media/usb/gspca/stv06xx/stv06xx_hdcs.c | 10 +- .../media/usb/gspca/stv06xx/stv06xx_pb0100.c | 23 ++-- .../media/usb/gspca/stv06xx/stv06xx_st6422.c | 2 +- .../media/usb/gspca/stv06xx/stv06xx_vv6410.c | 16 +-- drivers/media/usb/gspca/sunplus.c | 34 ++--- drivers/media/usb/gspca/t613.c | 24 ++-- drivers/media/usb/gspca/topro.c | 6 +- drivers/media/usb/gspca/touptek.c | 51 +++---- drivers/media/usb/gspca/vc032x.c | 51 +++---- drivers/media/usb/gspca/w996Xcf.c | 7 +- drivers/media/usb/gspca/xirlink_cit.c | 32 ++--- drivers/media/usb/gspca/zc3xx.c | 83 ++++++------ 59 files changed, 742 insertions(+), 687 deletions(-) diff --git a/drivers/media/usb/gspca/autogain_functions.c b/drivers/media/usb/gspca/autogain_functions.c index 427db745e0274..f721e83596be1 100644 --- a/drivers/media/usb/gspca/autogain_functions.c +++ b/drivers/media/usb/gspca/autogain_functions.c @@ -41,8 +41,8 @@ int gspca_expo_autogain( desired lumination fast (with the risc of a slight overshoot) */ steps = abs(desired_avg_lum - avg_lum) / deadzone; - PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d", - avg_lum, desired_avg_lum, steps); + gspca_dbg(gspca_dev, D_FRAM, "autogain: lum: %d, desired: %d, steps: %d\n", + avg_lum, desired_avg_lum, steps); for (i = 0; i < steps; i++) { if (avg_lum > desired_avg_lum) { @@ -84,8 +84,8 @@ int gspca_expo_autogain( } if (retval) - PDEBUG(D_FRAM, "autogain: changed gain: %d, expo: %d", - gain, exposure); + gspca_dbg(gspca_dev, D_FRAM, "autogain: changed gain: %d, expo: %d\n", + gain, exposure); return retval; } EXPORT_SYMBOL(gspca_expo_autogain); @@ -126,8 +126,8 @@ int gspca_coarse_grained_expo_autogain( desired lumination fast (with the risc of a slight overshoot) */ steps = (desired_avg_lum - avg_lum) / deadzone; - PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d", - avg_lum, desired_avg_lum, steps); + gspca_dbg(gspca_dev, D_FRAM, "autogain: lum: %d, desired: %d, steps: %d\n", + avg_lum, desired_avg_lum, steps); if ((gain + steps) > gain_high && exposure < gspca_dev->exposure->maximum) { @@ -167,8 +167,8 @@ int gspca_coarse_grained_expo_autogain( } if (retval) - PDEBUG(D_FRAM, "autogain: changed gain: %d, expo: %d", - gain, exposure); + gspca_dbg(gspca_dev, D_FRAM, "autogain: changed gain: %d, expo: %d\n", + gain, exposure); return retval; } EXPORT_SYMBOL(gspca_coarse_grained_expo_autogain); diff --git a/drivers/media/usb/gspca/benq.c b/drivers/media/usb/gspca/benq.c index b5955bf0d0fc7..8a8db5eb6d5fd 100644 --- a/drivers/media/usb/gspca/benq.c +++ b/drivers/media/usb/gspca/benq.c @@ -152,7 +152,7 @@ static void sd_isoc_irq(struct urb *urb) u8 *data; int i, st; - PDEBUG(D_PACK, "sd isoc irq"); + gspca_dbg(gspca_dev, D_PACK, "sd isoc irq\n"); if (!gspca_dev->streaming) return; if (urb->status != 0) { diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c index 0223b33156dd1..6df4e204e2913 100644 --- a/drivers/media/usb/gspca/conex.c +++ b/drivers/media/usb/gspca/conex.c @@ -81,8 +81,8 @@ static void reg_r(struct gspca_dev *gspca_dev, 0, index, gspca_dev->usb_buf, len, 500); - PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", - index, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg read [%02x] -> %02x ..\n", + index, gspca_dev->usb_buf[0]); } /* the bytes to write are in gspca_dev->usb_buf */ @@ -112,7 +112,8 @@ static void reg_w(struct gspca_dev *gspca_dev, gspca_err(gspca_dev, "reg_w: buffer overflow\n"); return; } - PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); + gspca_dbg(gspca_dev, D_USBO, "reg write [%02x] = %02x..\n", + index, *buffer); memcpy(gspca_dev->usb_buf, buffer, len); usb_control_msg(dev, diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c index 99b456d64729e..8d41cd46a79d6 100644 --- a/drivers/media/usb/gspca/cpia1.c +++ b/drivers/media/usb/gspca/cpia1.c @@ -701,11 +701,11 @@ static void reset_camera_params(struct gspca_dev *gspca_dev) static void printstatus(struct gspca_dev *gspca_dev, struct cam_params *params) { - PDEBUG(D_PROBE, "status: %02x %02x %02x %02x %02x %02x %02x %02x", - params->status.systemState, params->status.grabState, - params->status.streamState, params->status.fatalError, - params->status.cmdError, params->status.debugFlags, - params->status.vpStatus, params->status.errorCode); + gspca_dbg(gspca_dev, D_PROBE, "status: %02x %02x %02x %02x %02x %02x %02x %02x\n", + params->status.systemState, params->status.grabState, + params->status.streamState, params->status.fatalError, + params->status.cmdError, params->status.debugFlags, + params->status.vpStatus, params->status.errorCode); } static int goto_low_power(struct gspca_dev *gspca_dev) @@ -730,7 +730,7 @@ static int goto_low_power(struct gspca_dev *gspca_dev) return -EIO; } - PDEBUG(D_CONF, "camera now in LOW power state"); + gspca_dbg(gspca_dev, D_CONF, "camera now in LOW power state\n"); return 0; } @@ -759,7 +759,7 @@ static int goto_high_power(struct gspca_dev *gspca_dev) return -EIO; } - PDEBUG(D_CONF, "camera now in HIGH power state"); + gspca_dbg(gspca_dev, D_CONF, "camera now in HIGH power state\n"); return 0; } @@ -1302,7 +1302,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) sd->params.exposure.coarseExpHi = new_exposure >> 8; setexp = 1; sd->exposure_status = EXPOSURE_NORMAL; - PDEBUG(D_CONF, "Automatically decreasing sensor_fps"); + gspca_dbg(gspca_dev, D_CONF, "Automatically decreasing sensor_fps\n"); } else if ((sd->exposure_status == EXPOSURE_VERY_LIGHT || sd->exposure_status == EXPOSURE_LIGHT) && @@ -1331,7 +1331,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) sd->params.exposure.coarseExpHi = new_exposure >> 8; setexp = 1; sd->exposure_status = EXPOSURE_NORMAL; - PDEBUG(D_CONF, "Automatically increasing sensor_fps"); + gspca_dbg(gspca_dev, D_CONF, "Automatically increasing sensor_fps\n"); } } else { /* Flicker control off */ @@ -1349,7 +1349,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) setexp = 1; } sd->exposure_status = EXPOSURE_NORMAL; - PDEBUG(D_CONF, "Automatically decreasing sensor_fps"); + gspca_dbg(gspca_dev, D_CONF, "Automatically decreasing sensor_fps\n"); } else if ((sd->exposure_status == EXPOSURE_VERY_LIGHT || sd->exposure_status == EXPOSURE_LIGHT) && @@ -1366,7 +1366,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) setexp = 1; } sd->exposure_status = EXPOSURE_NORMAL; - PDEBUG(D_CONF, "Automatically increasing sensor_fps"); + gspca_dbg(gspca_dev, D_CONF, "Automatically increasing sensor_fps\n"); } } @@ -1434,8 +1434,8 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->mainsFreq = FREQ_DEF == V4L2_CID_POWER_LINE_FREQUENCY_60HZ; reset_camera_params(gspca_dev); - PDEBUG(D_PROBE, "cpia CPiA camera detected (vid/pid 0x%04X:0x%04X)", - id->idVendor, id->idProduct); + gspca_dbg(gspca_dev, D_PROBE, "cpia CPiA camera detected (vid/pid 0x%04X:0x%04X)\n", + id->idVendor, id->idProduct); cam = &gspca_dev->cam; cam->cam_mode = mode; @@ -1669,18 +1669,18 @@ static int sd_init(struct gspca_dev *gspca_dev) sd_stopN(gspca_dev); - PDEBUG(D_PROBE, "CPIA Version: %d.%02d (%d.%d)", - sd->params.version.firmwareVersion, - sd->params.version.firmwareRevision, - sd->params.version.vcVersion, - sd->params.version.vcRevision); - PDEBUG(D_PROBE, "CPIA PnP-ID: %04x:%04x:%04x", - sd->params.pnpID.vendor, sd->params.pnpID.product, - sd->params.pnpID.deviceRevision); - PDEBUG(D_PROBE, "VP-Version: %d.%d %04x", - sd->params.vpVersion.vpVersion, - sd->params.vpVersion.vpRevision, - sd->params.vpVersion.cameraHeadID); + gspca_dbg(gspca_dev, D_PROBE, "CPIA Version: %d.%02d (%d.%d)\n", + sd->params.version.firmwareVersion, + sd->params.version.firmwareRevision, + sd->params.version.vcVersion, + sd->params.version.vcRevision); + gspca_dbg(gspca_dev, D_PROBE, "CPIA PnP-ID: %04x:%04x:%04x", + sd->params.pnpID.vendor, sd->params.pnpID.product, + sd->params.pnpID.deviceRevision); + gspca_dbg(gspca_dev, D_PROBE, "VP-Version: %d.%d %04x", + sd->params.vpVersion.vpVersion, + sd->params.vpVersion.vpRevision, + sd->params.vpVersion.cameraHeadID); return 0; } diff --git a/drivers/media/usb/gspca/dtcs033.c b/drivers/media/usb/gspca/dtcs033.c index b4d42940d5de2..cdf27cf0112a8 100644 --- a/drivers/media/usb/gspca/dtcs033.c +++ b/drivers/media/usb/gspca/dtcs033.c @@ -75,14 +75,14 @@ static int reg_reqs(struct gspca_dev *gspca_dev, i, n_reqs); } else if (preq->bRequestType & USB_DIR_IN) { - PDEBUG(D_STREAM, - "USB IN (%d) returned[%d] %02X %02X %02X %s", - i, - preq->wLength, - gspca_dev->usb_buf[0], - gspca_dev->usb_buf[1], - gspca_dev->usb_buf[2], - preq->wLength > 3 ? "...\n" : "\n"); + gspca_dbg(gspca_dev, D_STREAM, + "USB IN (%d) returned[%d] %02X %02X %02X %s\n", + i, + preq->wLength, + gspca_dev->usb_buf[0], + gspca_dev->usb_buf[1], + gspca_dev->usb_buf[2], + preq->wLength > 3 ? "...\n" : "\n"); } i++; diff --git a/drivers/media/usb/gspca/etoms.c b/drivers/media/usb/gspca/etoms.c index a88ae69d6c1e6..48b28897051f2 100644 --- a/drivers/media/usb/gspca/etoms.c +++ b/drivers/media/usb/gspca/etoms.c @@ -170,8 +170,8 @@ static void reg_r(struct gspca_dev *gspca_dev, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 0, index, gspca_dev->usb_buf, len, 500); - PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", - index, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg read [%02x] -> %02x ..\n", + index, gspca_dev->usb_buf[0]); } static void reg_w_val(struct gspca_dev *gspca_dev, @@ -200,7 +200,8 @@ static void reg_w(struct gspca_dev *gspca_dev, pr_err("reg_w: buffer overflow\n"); return; } - PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); + gspca_dbg(gspca_dev, D_USBO, "reg write [%02x] = %02x..\n", + index, *buffer); memcpy(gspca_dev->usb_buf, buffer, len); usb_control_msg(dev, @@ -277,7 +278,7 @@ static void Et_init2(struct gspca_dev *gspca_dev) __u8 value; static const __u8 FormLine[] = { 0x84, 0x03, 0x14, 0xf4, 0x01, 0x05 }; - PDEBUG(D_STREAM, "Open Init2 ET"); + gspca_dbg(gspca_dev, D_STREAM, "Open Init2 ET\n"); reg_w_val(gspca_dev, ET_GPIO_DIR_CTRL, 0x2f); reg_w_val(gspca_dev, ET_GPIO_OUT, 0x10); reg_r(gspca_dev, ET_GPIO_IN, 1); @@ -416,8 +417,6 @@ static void setcolors(struct gspca_dev *gspca_dev, s32 val) i2c_w(gspca_dev, PAS106_REG13, &i2cflags, 1, 3); i2c_w(gspca_dev, PAS106_REG9, I2cc, sizeof I2cc, 1); } -/* PDEBUG(D_CONF , "Etoms red %d blue %d green %d", - I2cc[3], I2cc[0], green); */ } static s32 getcolors(struct gspca_dev *gspca_dev) @@ -451,7 +450,7 @@ static void Et_init1(struct gspca_dev *gspca_dev) /* __u8 I2c0 [] = {0x0a, 0x12, 0x05, 0xfe, 0xfe, 0xc0, 0x01, 0x00}; * 1/60000 hmm ?? */ - PDEBUG(D_STREAM, "Open Init1 ET"); + gspca_dbg(gspca_dev, D_STREAM, "Open Init1 ET\n\n"); reg_w_val(gspca_dev, ET_GPIO_DIR_CTRL, 7); reg_r(gspca_dev, ET_GPIO_IN, 1); reg_w_val(gspca_dev, ET_RESET_ALL, 1); @@ -463,9 +462,9 @@ static void Et_init1(struct gspca_dev *gspca_dev) value = ET_COMP_VAL1; else value = ET_COMP_VAL0; - PDEBUG(D_STREAM, "Open mode %d Compression %d", - gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv, - value); + gspca_dbg(gspca_dev, D_STREAM, "Open mode %d Compression %d\n", + gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv, + value); reg_w_val(gspca_dev, ET_COMP, value); reg_w_val(gspca_dev, ET_MAXQt, 0x1d); reg_w_val(gspca_dev, ET_MINQt, 0x02); @@ -604,7 +603,8 @@ static __u8 Et_getgainG(struct gspca_dev *gspca_dev) if (sd->sensor == SENSOR_PAS106) { i2c_r(gspca_dev, PAS106_REG0e); - PDEBUG(D_CONF, "Etoms gain G %d", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_CONF, "Etoms gain G %d\n", + gspca_dev->usb_buf[0]); return gspca_dev->usb_buf[0]; } return 0x1f; @@ -652,11 +652,11 @@ static void do_autogain(struct gspca_dev *gspca_dev) b = ((b << 7) >> 10); g = ((g << 9) + (g << 7) + (g << 5)) >> 10; luma = LIMIT(r + g + b); - PDEBUG(D_FRAM, "Etoms luma G %d", luma); + gspca_dbg(gspca_dev, D_FRAM, "Etoms luma G %d\n", luma); if (luma < luma_mean - luma_delta || luma > luma_mean + luma_delta) { Gbright += (luma_mean - luma) >> spring; Gbright = BLIMIT(Gbright); - PDEBUG(D_FRAM, "Etoms Gbright %d", Gbright); + gspca_dbg(gspca_dev, D_FRAM, "Etoms Gbright %d\n", Gbright); Et_setgainG(gspca_dev, (__u8) Gbright); } } @@ -673,10 +673,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, seqframe = data[0] & 0x3f; len = (int) (((data[0] & 0xc0) << 2) | data[1]); if (seqframe == 0x3f) { - PDEBUG(D_FRAM, - "header packet found datalength %d !!", len); - PDEBUG(D_FRAM, "G %d R %d G %d B %d", - data[2], data[3], data[4], data[5]); + gspca_dbg(gspca_dev, D_FRAM, + "header packet found datalength %d !!\n", len); + gspca_dbg(gspca_dev, D_FRAM, "G %d R %d G %d B %d", + data[2], data[3], data[4], data[5]); data += 30; /* don't change datalength as the chips provided it */ gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); diff --git a/drivers/media/usb/gspca/finepix.c b/drivers/media/usb/gspca/finepix.c index 7bb469aa61a73..1ef1239eb3db6 100644 --- a/drivers/media/usb/gspca/finepix.c +++ b/drivers/media/usb/gspca/finepix.c @@ -89,7 +89,7 @@ static void dostream(struct work_struct *work) int ret = 0; int len; - PDEBUG(D_STREAM, "dostream started"); + gspca_dbg(gspca_dev, D_STREAM, "dostream started\n"); /* loop reading a frame */ again: @@ -160,7 +160,7 @@ static void dostream(struct work_struct *work) } out: - PDEBUG(D_STREAM, "dostream stopped"); + gspca_dbg(gspca_dev, D_STREAM, "dostream stopped\n"); } /* this function is called at probe time */ diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c index add298cc9ab22..262200af76a34 100644 --- a/drivers/media/usb/gspca/gl860/gl860.c +++ b/drivers/media/usb/gspca/gl860/gl860.c @@ -661,7 +661,7 @@ static int gl860_guess_sensor(struct gspca_dev *gspca_dev, ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL); msleep(56); - PDEBUG(D_PROBE, "probing for sensor MI2020 or OVXXXX"); + gspca_dbg(gspca_dev, D_PROBE, "probing for sensor MI2020 or OVXXXX\n"); nOV = 0; for (ntry = 0; ntry < 4; ntry++) { ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); @@ -671,14 +671,14 @@ static int gl860_guess_sensor(struct gspca_dev *gspca_dev, ctrl_out(gspca_dev, 0x40, 1, 0x7a00, 0x8030, 0, NULL); msleep(10); ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &probe); - PDEBUG(D_PROBE, "probe=0x%02x", probe); + gspca_dbg(gspca_dev, D_PROBE, "probe=0x%02x\n", probe); if (probe == 0xff) nOV++; } if (nOV) { - PDEBUG(D_PROBE, "0xff -> OVXXXX"); - PDEBUG(D_PROBE, "probing for sensor OV2640 or OV9655"); + gspca_dbg(gspca_dev, D_PROBE, "0xff -> OVXXXX\n"); + gspca_dbg(gspca_dev, D_PROBE, "probing for sensor OV2640 or OV9655"); nb26 = nb96 = 0; for (ntry = 0; ntry < 4; ntry++) { @@ -694,22 +694,23 @@ static int gl860_guess_sensor(struct gspca_dev *gspca_dev, 1, &probe); if (probe == 0x26 || probe == 0x40) { - PDEBUG(D_PROBE, - "probe=0x%02x -> OV2640", - probe); + gspca_dbg(gspca_dev, D_PROBE, + "probe=0x%02x -> OV2640\n", + probe); sd->sensor = ID_OV2640; nb26 += 4; break; } if (probe == 0x96 || probe == 0x55) { - PDEBUG(D_PROBE, - "probe=0x%02x -> OV9655", - probe); + gspca_dbg(gspca_dev, D_PROBE, + "probe=0x%02x -> OV9655\n", + probe); sd->sensor = ID_OV9655; nb96 += 4; break; } - PDEBUG(D_PROBE, "probe=0x%02x", probe); + gspca_dbg(gspca_dev, D_PROBE, "probe=0x%02x\n", + probe); if (probe == 0x00) nb26++; if (probe == 0xff) @@ -719,21 +720,21 @@ static int gl860_guess_sensor(struct gspca_dev *gspca_dev, if (nb26 < 4 && nb96 < 4) return -1; } else { - PDEBUG(D_PROBE, "Not any 0xff -> MI2020"); + gspca_dbg(gspca_dev, D_PROBE, "Not any 0xff -> MI2020\n"); sd->sensor = ID_MI2020; } } if (_MI1320_) { - PDEBUG(D_PROBE, "05e3:f191 sensor MI1320 (1.3M)"); + gspca_dbg(gspca_dev, D_PROBE, "05e3:f191 sensor MI1320 (1.3M)\n"); } else if (_MI2020_) { - PDEBUG(D_PROBE, "05e3:0503 sensor MI2020 (2.0M)"); + gspca_dbg(gspca_dev, D_PROBE, "05e3:0503 sensor MI2020 (2.0M)\n"); } else if (_OV9655_) { - PDEBUG(D_PROBE, "05e3:0503 sensor OV9655 (1.3M)"); + gspca_dbg(gspca_dev, D_PROBE, "05e3:0503 sensor OV9655 (1.3M)\n"); } else if (_OV2640_) { - PDEBUG(D_PROBE, "05e3:0503 sensor OV2640 (2.0M)"); + gspca_dbg(gspca_dev, D_PROBE, "05e3:0503 sensor OV2640 (2.0M)\n"); } else { - PDEBUG(D_PROBE, "***** Unknown sensor *****"); + gspca_dbg(gspca_dev, D_PROBE, "***** Unknown sensor *****\n"); return -1; } diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index da81cb3059beb..101649770ef47 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -63,18 +63,18 @@ static void PDEBUG_MODE(struct gspca_dev *gspca_dev, int debug, char *txt, __u32 pixfmt, int w, int h) { if ((pixfmt >> 24) >= '0' && (pixfmt >> 24) <= 'z') { - PDEBUG(debug, "%s %c%c%c%c %dx%d", - txt, - pixfmt & 0xff, - (pixfmt >> 8) & 0xff, - (pixfmt >> 16) & 0xff, - pixfmt >> 24, - w, h); + gspca_dbg(gspca_dev, debug, "%s %c%c%c%c %dx%d\n", + txt, + pixfmt & 0xff, + (pixfmt >> 8) & 0xff, + (pixfmt >> 16) & 0xff, + pixfmt >> 24, + w, h); } else { - PDEBUG(debug, "%s 0x%08x %dx%d", - txt, - pixfmt, - w, h); + gspca_dbg(gspca_dev, debug, "%s 0x%08x %dx%d\n", + txt, + pixfmt, + w, h); } } @@ -198,8 +198,8 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev, buffer_len = le16_to_cpu(ep->wMaxPacketSize); interval = ep->bInterval; - PDEBUG(D_CONF, "found int in endpoint: 0x%x, buffer_len=%u, interval=%u", - ep->bEndpointAddress, buffer_len, interval); + gspca_dbg(gspca_dev, D_CONF, "found int in endpoint: 0x%x, buffer_len=%u, interval=%u\n", + ep->bEndpointAddress, buffer_len, interval); dev = gspca_dev->dev; @@ -332,8 +332,8 @@ static void fill_frame(struct gspca_dev *gspca_dev, } /* let the packet be analyzed by the subdriver */ - PDEBUG(D_PACK, "packet [%d] o:%d l:%d", - i, urb->iso_frame_desc[i].offset, len); + gspca_dbg(gspca_dev, D_PACK, "packet [%d] o:%d l:%d\n", + i, urb->iso_frame_desc[i].offset, len); data = (u8 *) urb->transfer_buffer + urb->iso_frame_desc[i].offset; pkt_scan(gspca_dev, data, len); @@ -355,7 +355,7 @@ static void isoc_irq(struct urb *urb) { struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; - PDEBUG(D_PACK, "isoc irq"); + gspca_dbg(gspca_dev, D_PACK, "isoc irq\n"); if (!gspca_dev->streaming) return; fill_frame(gspca_dev, urb); @@ -369,7 +369,7 @@ static void bulk_irq(struct urb *urb) struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; int st; - PDEBUG(D_PACK, "bulk irq"); + gspca_dbg(gspca_dev, D_PACK, "bulk irq\n"); if (!gspca_dev->streaming) return; switch (urb->status) { @@ -387,7 +387,7 @@ static void bulk_irq(struct urb *urb) goto resubmit; } - PDEBUG(D_PACK, "packet l:%d", urb->actual_length); + gspca_dbg(gspca_dev, D_PACK, "packet l:%d\n", urb->actual_length); gspca_dev->sd_desc->pkt_scan(gspca_dev, urb->transfer_buffer, urb->actual_length); @@ -420,7 +420,7 @@ void gspca_frame_add(struct gspca_dev *gspca_dev, struct gspca_frame *frame; int i, j; - PDEBUG(D_PACK, "add t:%d l:%d", packet_type, len); + gspca_dbg(gspca_dev, D_PACK, "add t:%d l:%d\n", packet_type, len); if (packet_type == FIRST_PACKET) { i = atomic_read(&gspca_dev->fr_i); @@ -486,8 +486,8 @@ void gspca_frame_add(struct gspca_dev *gspca_dev, i = (i + 1) % GSPCA_MAX_FRAMES; atomic_set(&gspca_dev->fr_i, i); wake_up_interruptible(&gspca_dev->wq); /* event = new frame */ - PDEBUG(D_FRAM, "frame complete len:%d", - frame->v4l2_buf.bytesused); + gspca_dbg(gspca_dev, D_FRAM, "frame complete len:%d\n", + frame->v4l2_buf.bytesused); gspca_dev->image = NULL; gspca_dev->image_len = 0; } @@ -502,7 +502,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file, int i; frsz = gspca_dev->pixfmt.sizeimage; - PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); + gspca_dbg(gspca_dev, D_STREAM, "frame alloc frsz: %d\n", frsz); frsz = PAGE_ALIGN(frsz); if (count >= GSPCA_MAX_FRAMES) count = GSPCA_MAX_FRAMES - 1; @@ -537,7 +537,7 @@ static void frame_free(struct gspca_dev *gspca_dev) { int i; - PDEBUG(D_STREAM, "frame free"); + gspca_dbg(gspca_dev, D_STREAM, "frame free\n"); if (gspca_dev->frbuf != NULL) { vfree(gspca_dev->frbuf); gspca_dev->frbuf = NULL; @@ -555,7 +555,7 @@ static void destroy_urbs(struct gspca_dev *gspca_dev) struct urb *urb; unsigned int i; - PDEBUG(D_STREAM, "kill transfer"); + gspca_dbg(gspca_dev, D_STREAM, "kill transfer\n"); for (i = 0; i < MAX_NURBS; i++) { urb = gspca_dev->urb[i]; if (urb == NULL) @@ -596,7 +596,7 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev) gspca_input_create_urb(gspca_dev); if (gspca_dev->sd_desc->stop0) gspca_dev->sd_desc->stop0(gspca_dev); - PDEBUG(D_STREAM, "stream off OK"); + gspca_dbg(gspca_dev, D_STREAM, "stream off OK\n"); } /* @@ -655,7 +655,7 @@ static u32 which_bandwidth(struct gspca_dev *gspca_dev) bandwidth *= 30; /* 30 fps */ } - PDEBUG(D_STREAM, "min bandwidth: %d", bandwidth); + gspca_dbg(gspca_dev, D_STREAM, "min bandwidth: %d\n", bandwidth); return bandwidth; } @@ -715,8 +715,8 @@ static int build_isoc_ep_tb(struct gspca_dev *gspca_dev, } if (!found) break; - PDEBUG(D_STREAM, "alt %d bandwidth %d", - ep_tb->alt, ep_tb->bandwidth); + gspca_dbg(gspca_dev, D_STREAM, "alt %d bandwidth %d\n", + ep_tb->alt, ep_tb->bandwidth); last_bw = ep_tb->bandwidth; i++; ep_tb++; @@ -734,7 +734,7 @@ static int build_isoc_ep_tb(struct gspca_dev *gspca_dev, gspca_dev->dev->speed == USB_SPEED_FULL && last_bw >= 1000000 && i > 1) { - PDEBUG(D_STREAM, "dev has usb audio, skipping highest alt"); + gspca_dbg(gspca_dev, D_STREAM, "dev has usb audio, skipping highest alt\n"); i--; ep_tb--; } @@ -774,16 +774,16 @@ static int create_urbs(struct gspca_dev *gspca_dev, if (npkt == 0) npkt = 32; /* default value */ bsize = psize * npkt; - PDEBUG(D_STREAM, - "isoc %d pkts size %d = bsize:%d", - npkt, psize, bsize); + gspca_dbg(gspca_dev, D_STREAM, + "isoc %d pkts size %d = bsize:%d\n", + npkt, psize, bsize); nurbs = DEF_NURBS; } else { /* bulk */ npkt = 0; bsize = gspca_dev->cam.bulk_size; if (bsize == 0) bsize = psize; - PDEBUG(D_STREAM, "bulk bsize:%d", bsize); + gspca_dbg(gspca_dev, D_STREAM, "bulk bsize:%d\n", bsize); if (gspca_dev->cam.bulk_nurbs != 0) nurbs = gspca_dev->cam.bulk_nurbs; else @@ -902,7 +902,8 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) } } if (!gspca_dev->cam.no_urb_create) { - PDEBUG(D_STREAM, "init transfer alt %d", alt); + gspca_dbg(gspca_dev, D_STREAM, "init transfer alt %d\n", + alt); ret = create_urbs(gspca_dev, alt_xfer(&intf->altsetting[alt], xfer, gspca_dev->xfer_ep)); @@ -1285,7 +1286,7 @@ static int dev_open(struct file *file) struct gspca_dev *gspca_dev = video_drvdata(file); int ret; - PDEBUG(D_STREAM, "[%s] open", current->comm); + gspca_dbg(gspca_dev, D_STREAM, "[%s] open\n", current->comm); /* protect the subdriver against rmmod */ if (!try_module_get(gspca_dev->module)) @@ -1301,7 +1302,7 @@ static int dev_close(struct file *file) { struct gspca_dev *gspca_dev = video_drvdata(file); - PDEBUG(D_STREAM, "[%s] close", current->comm); + gspca_dbg(gspca_dev, D_STREAM, "[%s] close\n", current->comm); /* Needed for gspca_stream_off, always lock before queue_lock! */ if (mutex_lock_interruptible(&gspca_dev->usb_lock)) @@ -1322,7 +1323,7 @@ static int dev_close(struct file *file) mutex_unlock(&gspca_dev->queue_lock); mutex_unlock(&gspca_dev->usb_lock); - PDEBUG(D_STREAM, "close done"); + gspca_dbg(gspca_dev, D_STREAM, "close done\n"); return v4l2_fh_release(file); } @@ -1443,7 +1444,7 @@ static int vidioc_reqbufs(struct file *file, void *priv, } out: mutex_unlock(&gspca_dev->queue_lock); - PDEBUG(D_STREAM, "reqbufs st:%d c:%d", ret, rb->count); + gspca_dbg(gspca_dev, D_STREAM, "reqbufs st:%d c:%d\n", ret, rb->count); return ret; } @@ -1601,7 +1602,8 @@ static int dev_mmap(struct file *file, struct vm_area_struct *vma) start = vma->vm_start; size = vma->vm_end - vma->vm_start; - PDEBUG(D_STREAM, "mmap start:%08x size:%d", (int) start, (int) size); + gspca_dbg(gspca_dev, D_STREAM, "mmap start:%08x size:%d\n", + (int) start, (int)size); if (mutex_lock_interruptible(&gspca_dev->queue_lock)) return -ERESTARTSYS; @@ -1613,7 +1615,7 @@ static int dev_mmap(struct file *file, struct vm_area_struct *vma) frame = NULL; for (i = 0; i < gspca_dev->nframes; ++i) { if (gspca_dev->frame[i].v4l2_buf.memory != V4L2_MEMORY_MMAP) { - PDEBUG(D_STREAM, "mmap bad memory type"); + gspca_dbg(gspca_dev, D_STREAM, "mmap bad memory type\n"); break; } if ((gspca_dev->frame[i].v4l2_buf.m.offset >> PAGE_SHIFT) @@ -1623,12 +1625,12 @@ static int dev_mmap(struct file *file, struct vm_area_struct *vma) } } if (frame == NULL) { - PDEBUG(D_STREAM, "mmap no frame buffer found"); + gspca_dbg(gspca_dev, D_STREAM, "mmap no frame buffer found\n"); ret = -EINVAL; goto out; } if (size != frame->v4l2_buf.length) { - PDEBUG(D_STREAM, "mmap bad size"); + gspca_dbg(gspca_dev, D_STREAM, "mmap bad size\n"); ret = -EINVAL; goto out; } @@ -1696,7 +1698,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct gspca_frame *frame; int i, j, ret; - PDEBUG(D_FRAM, "dqbuf"); + gspca_dbg(gspca_dev, D_FRAM, "dqbuf\n"); if (mutex_lock_interruptible(&gspca_dev->queue_lock)) return -ERESTARTSYS; @@ -1734,7 +1736,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf); - PDEBUG(D_FRAM, "dqbuf %d", j); + gspca_dbg(gspca_dev, D_FRAM, "dqbuf %d\n", j); ret = 0; if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { @@ -1772,27 +1774,27 @@ static int vidioc_qbuf(struct file *file, void *priv, struct gspca_frame *frame; int i, index, ret; - PDEBUG(D_FRAM, "qbuf %d", v4l2_buf->index); + gspca_dbg(gspca_dev, D_FRAM, "qbuf %d\n", v4l2_buf->index); if (mutex_lock_interruptible(&gspca_dev->queue_lock)) return -ERESTARTSYS; index = v4l2_buf->index; if ((unsigned) index >= gspca_dev->nframes) { - PDEBUG(D_FRAM, - "qbuf idx %d >= %d", index, gspca_dev->nframes); + gspca_dbg(gspca_dev, D_FRAM, + "qbuf idx %d >= %d\n", index, gspca_dev->nframes); ret = -EINVAL; goto out; } if (v4l2_buf->memory != gspca_dev->memory) { - PDEBUG(D_FRAM, "qbuf bad memory type"); + gspca_dbg(gspca_dev, D_FRAM, "qbuf bad memory type\n"); ret = -EINVAL; goto out; } frame = &gspca_dev->frame[index]; if (frame->v4l2_buf.flags & BUF_ALL_FLAGS) { - PDEBUG(D_FRAM, "qbuf bad state"); + gspca_dbg(gspca_dev, D_FRAM, "qbuf bad state\n"); ret = -EINVAL; goto out; } @@ -1826,7 +1828,7 @@ static int read_alloc(struct gspca_dev *gspca_dev, struct v4l2_buffer v4l2_buf; int i, ret; - PDEBUG(D_STREAM, "read alloc"); + gspca_dbg(gspca_dev, D_STREAM, "read alloc\n"); if (mutex_lock_interruptible(&gspca_dev->usb_lock)) return -ERESTARTSYS; @@ -1840,7 +1842,8 @@ static int read_alloc(struct gspca_dev *gspca_dev, rb.memory = GSPCA_MEMORY_READ; ret = vidioc_reqbufs(file, gspca_dev, &rb); if (ret != 0) { - PDEBUG(D_STREAM, "read reqbuf err %d", ret); + gspca_dbg(gspca_dev, D_STREAM, "read reqbuf err %d\n", + ret); goto out; } memset(&v4l2_buf, 0, sizeof v4l2_buf); @@ -1850,7 +1853,8 @@ static int read_alloc(struct gspca_dev *gspca_dev, v4l2_buf.index = i; ret = vidioc_qbuf(file, gspca_dev, &v4l2_buf); if (ret != 0) { - PDEBUG(D_STREAM, "read qbuf err: %d", ret); + gspca_dbg(gspca_dev, D_STREAM, "read qbuf err: %d\n", + ret); goto out; } } @@ -1859,7 +1863,7 @@ static int read_alloc(struct gspca_dev *gspca_dev, /* start streaming */ ret = vidioc_streamon(file, gspca_dev, V4L2_BUF_TYPE_VIDEO_CAPTURE); if (ret != 0) - PDEBUG(D_STREAM, "read streamon err %d", ret); + gspca_dbg(gspca_dev, D_STREAM, "read streamon err %d\n", ret); out: mutex_unlock(&gspca_dev->usb_lock); return ret; @@ -1871,7 +1875,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait) unsigned long req_events = poll_requested_events(wait); int ret = 0; - PDEBUG(D_FRAM, "poll"); + gspca_dbg(gspca_dev, D_FRAM, "poll\n"); if (req_events & POLLPRI) ret |= v4l2_ctrl_poll(file, wait); @@ -1913,7 +1917,7 @@ static ssize_t dev_read(struct file *file, char __user *data, struct timeval timestamp; int n, ret, ret2; - PDEBUG(D_FRAM, "read (%zd)", count); + gspca_dbg(gspca_dev, D_FRAM, "read (%zd)\n", count); if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* first time ? */ ret = read_alloc(gspca_dev, file); if (ret != 0) @@ -1930,7 +1934,8 @@ static ssize_t dev_read(struct file *file, char __user *data, v4l2_buf.memory = GSPCA_MEMORY_READ; ret = vidioc_dqbuf(file, gspca_dev, &v4l2_buf); if (ret != 0) { - PDEBUG(D_STREAM, "read dqbuf err %d", ret); + gspca_dbg(gspca_dev, D_STREAM, "read dqbuf err %d\n", + ret); return ret; } @@ -1943,7 +1948,8 @@ static ssize_t dev_read(struct file *file, char __user *data, break; ret = vidioc_qbuf(file, gspca_dev, &v4l2_buf); if (ret != 0) { - PDEBUG(D_STREAM, "read qbuf err %d", ret); + gspca_dbg(gspca_dev, D_STREAM, "read qbuf err %d\n", + ret); return ret; } } @@ -2132,7 +2138,8 @@ int gspca_dev_probe2(struct usb_interface *intf, } usb_set_intfdata(intf, gspca_dev); - PDEBUG(D_PROBE, "%s created", video_device_node_name(&gspca_dev->vdev)); + gspca_dbg(gspca_dev, D_PROBE, "%s created\n", + video_device_node_name(&gspca_dev->vdev)); gspca_input_create_urb(gspca_dev); @@ -2187,8 +2194,8 @@ void gspca_disconnect(struct usb_interface *intf) struct input_dev *input_dev; #endif - PDEBUG(D_PROBE, "%s disconnect", - video_device_node_name(&gspca_dev->vdev)); + gspca_dbg(gspca_dev, D_PROBE, "%s disconnect\n", + video_device_node_name(&gspca_dev->vdev)); mutex_lock(&gspca_dev->usb_lock); diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h index da65fef6aaccd..249cb38a542fe 100644 --- a/drivers/media/usb/gspca/gspca.h +++ b/drivers/media/usb/gspca/gspca.h @@ -26,8 +26,9 @@ extern int gspca_debug; -#define PDEBUG(level, fmt, ...) \ - v4l2_dbg(level, gspca_debug, &gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__) +#define gspca_dbg(gspca_dev, level, fmt, ...) \ + v4l2_dbg(level, gspca_debug, &(gspca_dev)->v4l2_dev, \ + fmt, ##__VA_ARGS__) #define gspca_err(gspca_dev, fmt, ...) \ v4l2_err(&(gspca_dev)->v4l2_dev, fmt, ##__VA_ARGS__) diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c index 7215c68790700..86d0a0a456313 100644 --- a/drivers/media/usb/gspca/jeilinj.c +++ b/drivers/media/usb/gspca/jeilinj.c @@ -273,17 +273,18 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, int packet_type; u32 header_marker; - PDEBUG(D_STREAM, "Got %d bytes out of %d for Block 0", - len, JEILINJ_MAX_TRANSFER); + gspca_dbg(gspca_dev, D_STREAM, "Got %d bytes out of %d for Block 0\n", + len, JEILINJ_MAX_TRANSFER); if (len != JEILINJ_MAX_TRANSFER) { - PDEBUG(D_PACK, "bad length"); + gspca_dbg(gspca_dev, D_PACK, "bad length\n"); goto discard; } /* check if it's start of frame */ header_marker = ((u32 *)data)[0]; if (header_marker == FRAME_START) { sd->blocks_left = data[0x0a] - 1; - PDEBUG(D_STREAM, "blocks_left = 0x%x", sd->blocks_left); + gspca_dbg(gspca_dev, D_STREAM, "blocks_left = 0x%x\n", + sd->blocks_left); /* Start a new frame, and add the JPEG header, first thing */ gspca_frame_add(gspca_dev, FIRST_PACKET, sd->jpeg_hdr, JPEG_HDR_SZ); @@ -292,8 +293,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, data + FRAME_HEADER_LEN, JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN); } else if (sd->blocks_left > 0) { - PDEBUG(D_STREAM, "%d blocks remaining for frame", - sd->blocks_left); + gspca_dbg(gspca_dev, D_STREAM, "%d blocks remaining for frame\n", + sd->blocks_left); sd->blocks_left -= 1; if (sd->blocks_left == 0) packet_type = LAST_PACKET; @@ -378,8 +379,8 @@ static int sd_start(struct gspca_dev *gspca_dev) gspca_dev->pixfmt.width, 0x21); /* JPEG 422 */ jpeg_set_qual(dev->jpeg_hdr, dev->quality); - PDEBUG(D_STREAM, "Start streaming at %dx%d", - gspca_dev->pixfmt.height, gspca_dev->pixfmt.width); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at %dx%d\n", + gspca_dev->pixfmt.height, gspca_dev->pixfmt.width); jlj_start(gspca_dev); return gspca_dev->usb_err; } diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c index 17c7a953564ce..d668589598d64 100644 --- a/drivers/media/usb/gspca/jl2005bcd.c +++ b/drivers/media/usb/gspca/jl2005bcd.c @@ -149,7 +149,8 @@ static int jl2005c_start_new_frame(struct gspca_dev *gspca_dev) return retval; i++; } - PDEBUG(D_FRAM, "frame_brightness is 0x%02x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_FRAM, "frame_brightness is 0x%02x\n", + gspca_dev->usb_buf[0]); return retval; } @@ -176,10 +177,11 @@ static int jl2005c_get_firmware_id(struct gspca_dev *gspca_dev) int retval = -1; unsigned char regs_to_read[] = {0x57, 0x02, 0x03, 0x5d, 0x5e, 0x5f}; - PDEBUG(D_PROBE, "Running jl2005c_get_firmware_id"); + gspca_dbg(gspca_dev, D_PROBE, "Running jl2005c_get_firmware_id\n"); /* Read the first ID byte once for warmup */ retval = jl2005c_read_reg(gspca_dev, regs_to_read[0]); - PDEBUG(D_PROBE, "response is %02x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_PROBE, "response is %02x\n", + gspca_dev->usb_buf[0]); if (retval < 0) return retval; /* Now actually get the ID string */ @@ -189,13 +191,13 @@ static int jl2005c_get_firmware_id(struct gspca_dev *gspca_dev) return retval; sd->firmware_id[i] = gspca_dev->usb_buf[0]; } - PDEBUG(D_PROBE, "firmware ID is %02x%02x%02x%02x%02x%02x", - sd->firmware_id[0], - sd->firmware_id[1], - sd->firmware_id[2], - sd->firmware_id[3], - sd->firmware_id[4], - sd->firmware_id[5]); + gspca_dbg(gspca_dev, D_PROBE, "firmware ID is %02x%02x%02x%02x%02x%02x\n", + sd->firmware_id[0], + sd->firmware_id[1], + sd->firmware_id[2], + sd->firmware_id[3], + sd->firmware_id[4], + sd->firmware_id[5]); return 0; } @@ -341,9 +343,9 @@ static void jl2005c_dostream(struct work_struct *work) usb_rcvbulkpipe(gspca_dev->dev, 0x82), buffer, JL2005C_MAX_TRANSFER, &act_len, JL2005C_DATA_TIMEOUT); - PDEBUG(D_PACK, - "Got %d bytes out of %d for header", - act_len, JL2005C_MAX_TRANSFER); + gspca_dbg(gspca_dev, D_PACK, + "Got %d bytes out of %d for header\n", + act_len, JL2005C_MAX_TRANSFER); if (ret < 0 || act_len < JL2005C_MAX_TRANSFER) goto quit_stream; /* Check whether we actually got the first blodk */ @@ -354,7 +356,8 @@ static void jl2005c_dostream(struct work_struct *work) /* total size to fetch is byte 7, times blocksize * of which we already got act_len */ bytes_left = buffer[0x07] * dev->block_size - act_len; - PDEBUG(D_PACK, "bytes_left = 0x%x", bytes_left); + gspca_dbg(gspca_dev, D_PACK, "bytes_left = 0x%x\n", + bytes_left); /* We keep the header. It has other information, too.*/ packet_type = FIRST_PACKET; gspca_frame_add(gspca_dev, packet_type, @@ -370,9 +373,9 @@ static void jl2005c_dostream(struct work_struct *work) JL2005C_DATA_TIMEOUT); if (ret < 0 || act_len < data_len) goto quit_stream; - PDEBUG(D_PACK, - "Got %d bytes out of %d for frame", - data_len, bytes_left); + gspca_dbg(gspca_dev, D_PACK, + "Got %d bytes out of %d for frame\n", + data_len, bytes_left); bytes_left -= data_len; if (bytes_left == 0) { packet_type = LAST_PACKET; @@ -449,19 +452,19 @@ static int sd_start(struct gspca_dev *gspca_dev) switch (gspca_dev->pixfmt.width) { case 640: - PDEBUG(D_STREAM, "Start streaming at vga resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at vga resolution\n"); jl2005c_stream_start_vga_lg(gspca_dev); break; case 320: - PDEBUG(D_STREAM, "Start streaming at qvga resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at qvga resolution\n"); jl2005c_stream_start_vga_small(gspca_dev); break; case 352: - PDEBUG(D_STREAM, "Start streaming at cif resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at cif resolution\n"); jl2005c_stream_start_cif_lg(gspca_dev); break; case 176: - PDEBUG(D_STREAM, "Start streaming at qcif resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at qcif resolution\n"); jl2005c_stream_start_cif_small(gspca_dev); break; default: diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c index 2f28b38c5479c..0cfdf8a1e19df 100644 --- a/drivers/media/usb/gspca/kinect.c +++ b/drivers/media/usb/gspca/kinect.c @@ -151,8 +151,9 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf, memcpy(obuf+sizeof(*chdr), cmdbuf, cmd_len); res = kinect_write(udev, obuf, cmd_len + sizeof(*chdr)); - PDEBUG(D_USBO, "Control cmd=%04x tag=%04x len=%04x: %d", cmd, - sd->cam_tag, cmd_len, res); + gspca_dbg(gspca_dev, D_USBO, "Control cmd=%04x tag=%04x len=%04x: %d\n", + cmd, + sd->cam_tag, cmd_len, res); if (res < 0) { pr_err("send_cmd: Output control transfer failed (%d)\n", res); return res; @@ -161,7 +162,7 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf, do { actual_len = kinect_read(udev, ibuf, 0x200); } while (actual_len == 0); - PDEBUG(D_USBO, "Control reply: %d", actual_len); + gspca_dbg(gspca_dev, D_USBO, "Control reply: %d\n", actual_len); if (actual_len < sizeof(*rhdr)) { pr_err("send_cmd: Input control transfer failed (%d)\n", actual_len); @@ -213,7 +214,7 @@ static int write_register(struct gspca_dev *gspca_dev, uint16_t reg, cmd[0] = cpu_to_le16(reg); cmd[1] = cpu_to_le16(data); - PDEBUG(D_USBO, "Write Reg 0x%04x <= 0x%02x", reg, data); + gspca_dbg(gspca_dev, D_USBO, "Write Reg 0x%04x <= 0x%02x\n", reg, data); res = send_cmd(gspca_dev, 0x03, cmd, 4, reply, 4); if (res < 0) return res; @@ -274,7 +275,7 @@ static int sd_config_depth(struct gspca_dev *gspca_dev, /* this function is called at probe and resume time */ static int sd_init(struct gspca_dev *gspca_dev) { - PDEBUG(D_PROBE, "Kinect Camera device."); + gspca_dbg(gspca_dev, D_PROBE, "Kinect Camera device.\n"); return 0; } diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c index d51aca01167fd..989ae997f66de 100644 --- a/drivers/media/usb/gspca/konica.c +++ b/drivers/media/usb/gspca/konica.c @@ -263,7 +263,7 @@ static void sd_isoc_irq(struct urb *urb) u8 *data; int i, st; - PDEBUG(D_PACK, "sd isoc irq"); + gspca_dbg(gspca_dev, D_PACK, "sd isoc irq\n"); if (!gspca_dev->streaming) return; diff --git a/drivers/media/usb/gspca/m5602/m5602_core.c b/drivers/media/usb/gspca/m5602/m5602_core.c index 4aab17efa4cc5..b83ec4285a0b5 100644 --- a/drivers/media/usb/gspca/m5602/m5602_core.c +++ b/drivers/media/usb/gspca/m5602/m5602_core.c @@ -66,8 +66,8 @@ int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data) 1, M5602_URB_MSG_TIMEOUT); *i2c_data = buf[0]; - PDEBUG(D_CONF, "Reading bridge register 0x%x containing 0x%x", - address, *i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Reading bridge register 0x%x containing 0x%x\n", + address, *i2c_data); /* usb_control_msg(...) returns the number of bytes sent upon success, mask that and return zero instead*/ @@ -82,8 +82,8 @@ int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data) struct usb_device *udev = sd->gspca_dev.dev; __u8 *buf = sd->gspca_dev.usb_buf; - PDEBUG(D_CONF, "Writing bridge register 0x%x with 0x%x", - address, i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Writing bridge register 0x%x with 0x%x\n", + address, i2c_data); memcpy(buf, bridge_urb_skeleton, sizeof(bridge_urb_skeleton)); @@ -154,8 +154,8 @@ int m5602_read_sensor(struct sd *sd, const u8 address, err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); - PDEBUG(D_CONF, "Reading sensor register 0x%x containing 0x%x ", - address, *i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Reading sensor register 0x%x containing 0x%x\n", + address, *i2c_data); } return err; } @@ -187,8 +187,8 @@ int m5602_write_sensor(struct sd *sd, const u8 address, memcpy(p, sensor_urb_skeleton + 16, 4); p[3] = i2c_data[i]; p += 4; - PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", - address, i2c_data[i]); + gspca_dbg(gspca_dev, D_CONF, "Writing sensor register 0x%x with 0x%x\n", + address, i2c_data[i]); } /* Copy the tailer */ @@ -264,7 +264,7 @@ static int m5602_init(struct gspca_dev *gspca_dev) struct sd *sd = (struct sd *) gspca_dev; int err; - PDEBUG(D_CONF, "Initializing ALi m5602 webcam"); + gspca_dbg(gspca_dev, D_CONF, "Initializing ALi m5602 webcam\n"); /* Run the init sequence */ err = sd->sensor->init(sd); @@ -299,7 +299,7 @@ static int m5602_start_transfer(struct gspca_dev *gspca_dev) 0x04, 0x40, 0x19, 0x0000, buf, sizeof(buffer), M5602_URB_MSG_TIMEOUT); - PDEBUG(D_STREAM, "Transfer started"); + gspca_dbg(gspca_dev, D_STREAM, "Transfer started\n"); return (err < 0) ? err : 0; } @@ -309,14 +309,14 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, struct sd *sd = (struct sd *) gspca_dev; if (len < 6) { - PDEBUG(D_PACK, "Packet is less than 6 bytes"); + gspca_dbg(gspca_dev, D_PACK, "Packet is less than 6 bytes\n"); return; } /* Frame delimiter: ff xx xx xx ff ff */ if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && data[2] != sd->frame_id) { - PDEBUG(D_FRAM, "Frame delimiter detected"); + gspca_dbg(gspca_dev, D_FRAM, "Frame delimiter detected\n"); sd->frame_id = data[2]; /* Remove the extra fluff appended on each header */ @@ -331,8 +331,8 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, /* Create a new frame */ gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); - PDEBUG(D_FRAM, "Starting new frame %d", - sd->frame_count); + gspca_dbg(gspca_dev, D_FRAM, "Starting new frame %d\n", + sd->frame_count); } else { int cur_frame_len; @@ -343,8 +343,8 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, len -= 4; if (cur_frame_len + len <= gspca_dev->frsz) { - PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes", - sd->frame_count, len); + gspca_dbg(gspca_dev, D_FRAM, "Continuing frame %d copying %d bytes\n", + sd->frame_count, len); gspca_frame_add(gspca_dev, INTER_PACKET, data, len); diff --git a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c index 7d01ddd7ed014..c9947c4a0f63a 100644 --- a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c +++ b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c @@ -212,7 +212,7 @@ int mt9m111_probe(struct sd *sd) return -ENODEV; } - PDEBUG(D_PROBE, "Probing for a mt9m111 sensor"); + gspca_dbg(gspca_dev, D_PROBE, "Probing for a mt9m111 sensor\n"); /* Do the preinit */ for (i = 0; i < ARRAY_SIZE(preinit_mt9m111); i++) { @@ -375,11 +375,11 @@ int mt9m111_start(struct sd *sd) switch (width) { case 640: - PDEBUG(D_CONF, "Configuring camera for VGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for VGA mode\n"); break; case 320: - PDEBUG(D_CONF, "Configuring camera for QVGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for QVGA mode\n"); break; } return err; @@ -398,7 +398,8 @@ static int mt9m111_set_hvflip(struct gspca_dev *gspca_dev) int hflip; int vflip; - PDEBUG(D_CONF, "Set hvflip to %d %d", sd->hflip->val, sd->vflip->val); + gspca_dbg(gspca_dev, D_CONF, "Set hvflip to %d %d\n", + sd->hflip->val, sd->vflip->val); /* The mt9m111 is flipped by default */ hflip = !sd->hflip->val; @@ -439,7 +440,7 @@ static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev, err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2); - PDEBUG(D_CONF, "Set auto white balance %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto white balance %d\n", val); return err; } @@ -472,8 +473,8 @@ static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val) data[1] = (tmp & 0xff); data[0] = (tmp & 0xff00) >> 8; - PDEBUG(D_CONF, "tmp=%d, data[1]=%d, data[0]=%d", tmp, - data[1], data[0]); + gspca_dbg(gspca_dev, D_CONF, "tmp=%d, data[1]=%d, data[0]=%d\n", tmp, + data[1], data[0]); err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, data, 2); @@ -490,7 +491,7 @@ static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val) data[1] = (val & 0xff); data[0] = (val & 0xff00) >> 8; - PDEBUG(D_CONF, "Set green balance %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set green balance %d\n", val); err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN, data, 2); if (err < 0) @@ -508,7 +509,7 @@ static int mt9m111_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) data[1] = (val & 0xff); data[0] = (val & 0xff00) >> 8; - PDEBUG(D_CONF, "Set blue balance %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set blue balance %d\n", val); return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN, data, 2); @@ -522,7 +523,7 @@ static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) data[1] = (val & 0xff); data[0] = (val & 0xff00) >> 8; - PDEBUG(D_CONF, "Set red balance %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set red balance %d\n", val); return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN, data, 2); diff --git a/drivers/media/usb/gspca/m5602/m5602_ov7660.c b/drivers/media/usb/gspca/m5602/m5602_ov7660.c index 672b7a520695e..aa1f569c82fd3 100644 --- a/drivers/media/usb/gspca/m5602/m5602_ov7660.c +++ b/drivers/media/usb/gspca/m5602/m5602_ov7660.c @@ -330,7 +330,7 @@ static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data = val; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Setting gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Setting gain to %d\n", val); err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1); return err; @@ -343,7 +343,7 @@ static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto white balance to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto white balance to %d\n", val); err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); if (err < 0) @@ -361,7 +361,7 @@ static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto gain control to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto gain control to %d\n", val); err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); if (err < 0) @@ -379,7 +379,7 @@ static int ov7660_set_auto_exposure(struct gspca_dev *gspca_dev, u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto exposure control to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto exposure control to %d\n", val); err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); if (err < 0) @@ -397,7 +397,8 @@ static int ov7660_set_hvflip(struct gspca_dev *gspca_dev) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set hvflip to %d, %d", sd->hflip->val, sd->vflip->val); + gspca_dbg(gspca_dev, D_CONF, "Set hvflip to %d, %d\n", + sd->hflip->val, sd->vflip->val); i2c_data = (sd->hflip->val << 5) | (sd->vflip->val << 4); diff --git a/drivers/media/usb/gspca/m5602/m5602_ov9650.c b/drivers/media/usb/gspca/m5602/m5602_ov9650.c index 4544d3a1ad589..2ffbb54e89f91 100644 --- a/drivers/media/usb/gspca/m5602/m5602_ov9650.c +++ b/drivers/media/usb/gspca/m5602/m5602_ov9650.c @@ -311,7 +311,7 @@ int ov9650_probe(struct sd *sd) return -ENODEV; } - PDEBUG(D_PROBE, "Probing for an ov9650 sensor"); + gspca_dbg(gspca_dev, D_PROBE, "Probing for an ov9650 sensor\n"); /* Run the pre-init before probing the sensor */ for (i = 0; i < ARRAY_SIZE(preinit_ov9650) && !err; i++) { @@ -505,7 +505,7 @@ int ov9650_start(struct sd *sd) switch (width) { case 640: - PDEBUG(D_CONF, "Configuring camera for VGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for VGA mode\n"); data = OV9650_VGA_SELECT | OV9650_RGB_SELECT | OV9650_RAW_RGB_SELECT; @@ -513,7 +513,7 @@ int ov9650_start(struct sd *sd) break; case 352: - PDEBUG(D_CONF, "Configuring camera for CIF mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for CIF mode\n"); data = OV9650_CIF_SELECT | OV9650_RGB_SELECT | OV9650_RAW_RGB_SELECT; @@ -521,7 +521,7 @@ int ov9650_start(struct sd *sd) break; case 320: - PDEBUG(D_CONF, "Configuring camera for QVGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for QVGA mode\n"); data = OV9650_QVGA_SELECT | OV9650_RGB_SELECT | OV9650_RAW_RGB_SELECT; @@ -529,7 +529,7 @@ int ov9650_start(struct sd *sd) break; case 176: - PDEBUG(D_CONF, "Configuring camera for QCIF mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for QCIF mode\n"); data = OV9650_QCIF_SELECT | OV9650_RGB_SELECT | OV9650_RAW_RGB_SELECT; @@ -558,7 +558,7 @@ static int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; int err; - PDEBUG(D_CONF, "Set exposure to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to %d\n", val); /* The 6 MSBs */ i2c_data = (val >> 10) & 0x3f; @@ -586,7 +586,7 @@ static int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Setting gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Setting gain to %d\n", val); /* The 2 MSB */ /* Read the OV9650_VREF register first to avoid @@ -614,7 +614,7 @@ static int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set red gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set red gain to %d\n", val); i2c_data = val & 0xff; err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1); @@ -627,7 +627,7 @@ static int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set blue gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set blue gain to %d\n", val); i2c_data = val & 0xff; err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); @@ -642,7 +642,7 @@ static int ov9650_set_hvflip(struct gspca_dev *gspca_dev) int hflip = sd->hflip->val; int vflip = sd->vflip->val; - PDEBUG(D_CONF, "Set hvflip to %d %d", hflip, vflip); + gspca_dbg(gspca_dev, D_CONF, "Set hvflip to %d %d\n", hflip, vflip); if (dmi_check_system(ov9650_flip_dmi_table)) vflip = !vflip; @@ -666,7 +666,7 @@ static int ov9650_set_auto_exposure(struct gspca_dev *gspca_dev, u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto exposure control to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto exposure control to %d\n", val); err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); if (err < 0) @@ -685,7 +685,7 @@ static int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto white balance to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto white balance to %d\n", val); err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); if (err < 0) @@ -703,7 +703,7 @@ static int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set auto gain control to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto gain control to %d\n", val); err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); if (err < 0) diff --git a/drivers/media/usb/gspca/m5602/m5602_po1030.c b/drivers/media/usb/gspca/m5602/m5602_po1030.c index a0a90dd34ca83..37d2891e5f5b6 100644 --- a/drivers/media/usb/gspca/m5602/m5602_po1030.c +++ b/drivers/media/usb/gspca/m5602/m5602_po1030.c @@ -171,7 +171,7 @@ int po1030_probe(struct sd *sd) return -ENODEV; } - PDEBUG(D_PROBE, "Probing for a po1030 sensor"); + gspca_dbg(gspca_dev, D_PROBE, "Probing for a po1030 sensor\n"); /* Run the pre-init to actually probe the unit */ for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) { @@ -410,11 +410,11 @@ static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) u8 i2c_data; int err; - PDEBUG(D_CONF, "Set exposure to %d", val & 0xffff); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to %d\n", val & 0xffff); i2c_data = ((val & 0xff00) >> 8); - PDEBUG(D_CONF, "Set exposure to high byte to 0x%x", - i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to high byte to 0x%x\n", + i2c_data); err = m5602_write_sensor(sd, PO1030_INTEGLINES_H, &i2c_data, 1); @@ -422,8 +422,8 @@ static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) return err; i2c_data = (val & 0xff); - PDEBUG(D_CONF, "Set exposure to low byte to 0x%x", - i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to low byte to 0x%x\n", + i2c_data); err = m5602_write_sensor(sd, PO1030_INTEGLINES_M, &i2c_data, 1); @@ -437,7 +437,7 @@ static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val) int err; i2c_data = val & 0xff; - PDEBUG(D_CONF, "Set global gain to %d", i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set global gain to %d\n", i2c_data); err = m5602_write_sensor(sd, PO1030_GLOBALGAIN, &i2c_data, 1); return err; @@ -449,7 +449,8 @@ static int po1030_set_hvflip(struct gspca_dev *gspca_dev) u8 i2c_data; int err; - PDEBUG(D_CONF, "Set hvflip %d %d", sd->hflip->val, sd->vflip->val); + gspca_dbg(gspca_dev, D_CONF, "Set hvflip %d %d\n", + sd->hflip->val, sd->vflip->val); err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); if (err < 0) return err; @@ -470,7 +471,7 @@ static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) int err; i2c_data = val & 0xff; - PDEBUG(D_CONF, "Set red gain to %d", i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set red gain to %d\n", i2c_data); err = m5602_write_sensor(sd, PO1030_RED_GAIN, &i2c_data, 1); return err; @@ -483,7 +484,7 @@ static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) int err; i2c_data = val & 0xff; - PDEBUG(D_CONF, "Set blue gain to %d", i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set blue gain to %d\n", i2c_data); err = m5602_write_sensor(sd, PO1030_BLUE_GAIN, &i2c_data, 1); @@ -497,7 +498,7 @@ static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val) int err; i2c_data = val & 0xff; - PDEBUG(D_CONF, "Set green gain to %d", i2c_data); + gspca_dbg(gspca_dev, D_CONF, "Set green gain to %d\n", i2c_data); err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN, &i2c_data, 1); @@ -519,7 +520,7 @@ static int po1030_set_auto_white_balance(struct gspca_dev *gspca_dev, if (err < 0) return err; - PDEBUG(D_CONF, "Set auto white balance to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto white balance to %d\n", val); i2c_data = (i2c_data & 0xfe) | (val & 0x01); err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); return err; @@ -536,7 +537,7 @@ static int po1030_set_auto_exposure(struct gspca_dev *gspca_dev, if (err < 0) return err; - PDEBUG(D_CONF, "Set auto exposure to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set auto exposure to %d\n", val); val = (val == V4L2_EXPOSURE_AUTO); i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1); return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c index 8447b9c5f8e02..cec4a5838aeca 100644 --- a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c @@ -357,7 +357,7 @@ int s5k4aa_probe(struct sd *sd) return -ENODEV; } - PDEBUG(D_PROBE, "Probing for a s5k4aa sensor"); + gspca_dbg(gspca_dev, D_PROBE, "Probing for a s5k4aa sensor\n"); /* Preinit the sensor */ for (i = 0; i < ARRAY_SIZE(preinit_s5k4aa) && !err; i++) { @@ -419,7 +419,7 @@ int s5k4aa_start(struct sd *sd) switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) { case 1280: - PDEBUG(D_CONF, "Configuring camera for SXGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for SXGA mode\n"); for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) { switch (SXGA_s5k4aa[i][0]) { @@ -452,7 +452,7 @@ int s5k4aa_start(struct sd *sd) break; case 640: - PDEBUG(D_CONF, "Configuring camera for VGA mode"); + gspca_dbg(gspca_dev, D_CONF, "Configuring camera for VGA mode\n"); for (i = 0; i < ARRAY_SIZE(VGA_s5k4aa); i++) { switch (VGA_s5k4aa[i][0]) { @@ -568,7 +568,7 @@ static int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val) u8 data = S5K4AA_PAGE_MAP_2; int err; - PDEBUG(D_CONF, "Set exposure to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to %d\n", val); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); if (err < 0) return err; @@ -590,7 +590,7 @@ static int s5k4aa_set_hvflip(struct gspca_dev *gspca_dev) int hflip = sd->hflip->val; int vflip = sd->vflip->val; - PDEBUG(D_CONF, "Set hvflip %d %d", hflip, vflip); + gspca_dbg(gspca_dev, D_CONF, "Set hvflip %d %d\n", hflip, vflip); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); if (err < 0) return err; @@ -640,7 +640,7 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) u8 data = S5K4AA_PAGE_MAP_2; int err; - PDEBUG(D_CONF, "Set gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set gain to %d\n", val); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); if (err < 0) return err; @@ -657,7 +657,7 @@ static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val) u8 data = S5K4AA_PAGE_MAP_2; int err; - PDEBUG(D_CONF, "Set brightness to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set brightness to %d\n", val); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); if (err < 0) return err; @@ -672,7 +672,7 @@ static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val) u8 data = S5K4AA_PAGE_MAP_2; int err; - PDEBUG(D_CONF, "Set noise to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set noise to %d\n", val); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); if (err < 0) return err; diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c index 6ad8d48496804..3d8ab18138aab 100644 --- a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c +++ b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c @@ -187,7 +187,7 @@ int s5k83a_probe(struct sd *sd) return -ENODEV; } - PDEBUG(D_PROBE, "Probing for a s5k83a sensor"); + gspca_dbg(gspca_dev, D_PROBE, "Probing for a s5k83a sensor\n"); /* Preinit the sensor */ for (i = 0; i < ARRAY_SIZE(preinit_s5k83a) && !err; i++) { diff --git a/drivers/media/usb/gspca/mars.c b/drivers/media/usb/gspca/mars.c index 25df55e840c73..a537cb195c463 100644 --- a/drivers/media/usb/gspca/mars.c +++ b/drivers/media/usb/gspca/mars.c @@ -378,8 +378,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, || data[5 + p] == 0x65 || data[5 + p] == 0x66 || data[5 + p] == 0x67) { - PDEBUG(D_PACK, "sof offset: %d len: %d", - p, len); + gspca_dbg(gspca_dev, D_PACK, "sof offset: %d len: %d\n", + p, len); gspca_frame_add(gspca_dev, LAST_PACKET, data, p); diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c index 34aacaee44534..bea1963612155 100644 --- a/drivers/media/usb/gspca/mr97310a.c +++ b/drivers/media/usb/gspca/mr97310a.c @@ -221,10 +221,11 @@ static int cam_get_response16(struct gspca_dev *gspca_dev, u8 reg, int verbose) return err_code; if (verbose) - PDEBUG(D_PROBE, "Register: %02x reads %02x%02x%02x", reg, - gspca_dev->usb_buf[0], - gspca_dev->usb_buf[1], - gspca_dev->usb_buf[2]); + gspca_dbg(gspca_dev, D_PROBE, "Register: %02x reads %02x%02x%02x\n", + reg, + gspca_dev->usb_buf[0], + gspca_dev->usb_buf[1], + gspca_dev->usb_buf[2]); return 0; } @@ -413,8 +414,8 @@ static int sd_config(struct gspca_dev *gspca_dev, gspca_dev->usb_buf[1]); return -ENODEV; } - PDEBUG(D_PROBE, "MR97310A CIF camera detected, sensor: %d", - sd->sensor_type); + gspca_dbg(gspca_dev, D_PROBE, "MR97310A CIF camera detected, sensor: %d\n", + sd->sensor_type); } else { sd->cam_type = CAM_TYPE_VGA; @@ -458,7 +459,7 @@ static int sd_config(struct gspca_dev *gspca_dev, switch (gspca_dev->usb_buf[1]) { case 0x50: sd->sensor_type = 0; - PDEBUG(D_PROBE, "sensor_type corrected to 0"); + gspca_dbg(gspca_dev, D_PROBE, "sensor_type corrected to 0\n"); break; case 0x20: /* Nothing to do here. */ @@ -470,16 +471,16 @@ static int sd_config(struct gspca_dev *gspca_dev, pr_err("Please report this\n"); } } - PDEBUG(D_PROBE, "MR97310A VGA camera detected, sensor: %d", - sd->sensor_type); + gspca_dbg(gspca_dev, D_PROBE, "MR97310A VGA camera detected, sensor: %d\n", + sd->sensor_type); } /* Stop streaming as we've started it only to probe the sensor type. */ sd_stopN(gspca_dev); if (force_sensor_type != -1) { sd->sensor_type = !!force_sensor_type; - PDEBUG(D_PROBE, "Forcing sensor type to: %d", - sd->sensor_type); + gspca_dbg(gspca_dev, D_PROBE, "Forcing sensor type to: %d\n", + sd->sensor_type); } return 0; diff --git a/drivers/media/usb/gspca/nw80x.c b/drivers/media/usb/gspca/nw80x.c index 5d2d0bcb038d3..bedc04a72e97e 100644 --- a/drivers/media/usb/gspca/nw80x.c +++ b/drivers/media/usb/gspca/nw80x.c @@ -1543,10 +1543,11 @@ static void reg_w(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; if (len == 1) - PDEBUG(D_USBO, "SET 00 0000 %04x %02x", index, *data); + gspca_dbg(gspca_dev, D_USBO, "SET 00 0000 %04x %02x\n", + index, *data); else - PDEBUG(D_USBO, "SET 00 0000 %04x %02x %02x ...", - index, *data, data[1]); + gspca_dbg(gspca_dev, D_USBO, "SET 00 0000 %04x %02x %02x ...\n", + index, *data, data[1]); memcpy(gspca_dev->usb_buf, data, len); ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0x00, @@ -1583,12 +1584,12 @@ static void reg_r(struct gspca_dev *gspca_dev, return; } if (len == 1) - PDEBUG(D_USBI, "GET 00 0000 %04x %02x", - index, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "GET 00 0000 %04x %02x\n", + index, gspca_dev->usb_buf[0]); else - PDEBUG(D_USBI, "GET 00 0000 %04x %02x %02x ..", - index, gspca_dev->usb_buf[0], - gspca_dev->usb_buf[1]); + gspca_dbg(gspca_dev, D_USBI, "GET 00 0000 %04x %02x %02x ..\n", + index, gspca_dev->usb_buf[0], + gspca_dev->usb_buf[1]); } static void i2c_w(struct gspca_dev *gspca_dev, @@ -1762,8 +1763,8 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->webcam = P35u; } else if (id->idVendor == 0x06a5 && id->idProduct == 0xd800) { reg_r(gspca_dev, 0x0403, 1); /* GPIO */ - PDEBUG(D_PROBE, "et31x110 sensor type %02x", - gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_PROBE, "et31x110 sensor type %02x\n", + gspca_dev->usb_buf[0]); switch (gspca_dev->usb_buf[0] >> 1) { case 0x00: /* ?? */ if (sd->webcam == Generic800) @@ -1785,7 +1786,8 @@ static int sd_config(struct gspca_dev *gspca_dev, gspca_dev->usb_err = -ENODEV; return gspca_dev->usb_err; } - PDEBUG(D_PROBE, "Bridge nw80%d - type: %d", sd->bridge, sd->webcam); + gspca_dbg(gspca_dev, D_PROBE, "Bridge nw80%d - type: %d\n", + sd->bridge, sd->webcam); if (sd->bridge == BRIDGE_NW800) { switch (sd->webcam) { diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c index 14ffefbb5ac1b..10fcbe9e8614b 100644 --- a/drivers/media/usb/gspca/ov519.c +++ b/drivers/media/usb/gspca/ov519.c @@ -2016,8 +2016,8 @@ static void reg_w(struct sd *sd, u16 index, u16 value) req = 0x0a; /* fall through */ case BRIDGE_W9968CF: - PDEBUG(D_USBO, "SET %02x %04x %04x", - req, value, index); + gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n", + req, value, index); ret = usb_control_msg(sd->gspca_dev.dev, usb_sndctrlpipe(sd->gspca_dev.dev, 0), req, @@ -2028,8 +2028,8 @@ static void reg_w(struct sd *sd, u16 index, u16 value) req = 1; } - PDEBUG(D_USBO, "SET %02x 0000 %04x %02x", - req, index, value); + gspca_dbg(gspca_dev, D_USBO, "SET %02x 0000 %04x %02x\n", + req, index, value); sd->gspca_dev.usb_buf[0] = value; ret = usb_control_msg(sd->gspca_dev.dev, usb_sndctrlpipe(sd->gspca_dev.dev, 0), @@ -2078,8 +2078,8 @@ static int reg_r(struct sd *sd, u16 index) if (ret >= 0) { ret = sd->gspca_dev.usb_buf[0]; - PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", - req, index, ret); + gspca_dbg(gspca_dev, D_USBI, "GET %02x 0000 %04x %02x\n", + req, index, ret); } else { gspca_err(gspca_dev, "reg_r %02x failed %d\n", index, ret); sd->gspca_dev.usb_err = ret; @@ -2175,7 +2175,7 @@ static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int rc, retries; - PDEBUG(D_USBO, "ov511_i2c_w %02x %02x", reg, value); + gspca_dbg(gspca_dev, D_USBO, "ov511_i2c_w %02x %02x\n", reg, value); /* Three byte write cycle */ for (retries = 6; ; ) { @@ -2198,7 +2198,7 @@ static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) if ((rc & 2) == 0) /* Ack? */ break; if (--retries < 0) { - PDEBUG(D_USBO, "i2c write retries exhausted"); + gspca_dbg(gspca_dev, D_USBO, "i2c write retries exhausted\n"); return; } } @@ -2231,7 +2231,7 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) reg_w(sd, R511_I2C_CTL, 0x10); if (--retries < 0) { - PDEBUG(D_USBI, "i2c write retries exhausted"); + gspca_dbg(gspca_dev, D_USBI, "i2c write retries exhausted\n"); return -1; } } @@ -2255,14 +2255,14 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) reg_w(sd, R511_I2C_CTL, 0x10); if (--retries < 0) { - PDEBUG(D_USBI, "i2c read retries exhausted"); + gspca_dbg(gspca_dev, D_USBI, "i2c read retries exhausted\n"); return -1; } } value = reg_r(sd, R51x_I2C_DATA); - PDEBUG(D_USBI, "ov511_i2c_r %02x %02x", reg, value); + gspca_dbg(gspca_dev, D_USBI, "ov511_i2c_r %02x %02x\n", reg, value); /* This is needed to make i2c_w() work */ reg_w(sd, R511_I2C_CTL, 0x05); @@ -2281,7 +2281,7 @@ static void ov518_i2c_w(struct sd *sd, { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value); + gspca_dbg(gspca_dev, D_USBO, "ov518_i2c_w %02x %02x\n", reg, value); /* Select camera register */ reg_w(sd, R51x_I2C_SADDR_3, reg); @@ -2321,7 +2321,7 @@ static int ov518_i2c_r(struct sd *sd, u8 reg) reg_r8(sd, R518_I2C_CTL); value = reg_r(sd, R51x_I2C_DATA); - PDEBUG(D_USBI, "ov518_i2c_r %02x %02x", reg, value); + gspca_dbg(gspca_dev, D_USBI, "ov518_i2c_r %02x %02x\n", reg, value); return value; } @@ -2344,7 +2344,7 @@ static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) sd->gspca_dev.usb_err = ret; } - PDEBUG(D_USBO, "ovfx2_i2c_w %02x %02x", reg, value); + gspca_dbg(gspca_dev, D_USBO, "ovfx2_i2c_w %02x %02x\n", reg, value); } static int ovfx2_i2c_r(struct sd *sd, u8 reg) @@ -2363,7 +2363,8 @@ static int ovfx2_i2c_r(struct sd *sd, u8 reg) if (ret >= 0) { ret = sd->gspca_dev.usb_buf[0]; - PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret); + gspca_dbg(gspca_dev, D_USBI, "ovfx2_i2c_r %02x %02x\n", + reg, ret); } else { gspca_err(gspca_dev, "ovfx2_i2c_r %02x failed %d\n", reg, ret); sd->gspca_dev.usb_err = ret; @@ -2464,7 +2465,7 @@ static inline void ov51x_stop(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_STREAM, "stopping"); + gspca_dbg(gspca_dev, D_STREAM, "stopping\n"); sd->stopped = 1; switch (sd->bridge) { case BRIDGE_OV511: @@ -2495,7 +2496,7 @@ static inline void ov51x_restart(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_STREAM, "restarting"); + gspca_dbg(gspca_dev, D_STREAM, "restarting\n"); if (!sd->stopped) return; sd->stopped = 0; @@ -2546,7 +2547,8 @@ static int init_ov_sensor(struct sd *sd, u8 slave) for (i = 0; i < i2c_detect_tries; i++) { if (i2c_r(sd, OV7610_REG_ID_HIGH) == 0x7f && i2c_r(sd, OV7610_REG_ID_LOW) == 0xa2) { - PDEBUG(D_PROBE, "I2C synced in %d attempt(s)", i); + gspca_dbg(gspca_dev, D_PROBE, "I2C synced in %d attempt(s)\n", + i); return 0; } @@ -2621,7 +2623,7 @@ static void ov_hires_configure(struct sd *sd) return; } - PDEBUG(D_PROBE, "starting ov hires configuration"); + gspca_dbg(gspca_dev, D_PROBE, "starting ov hires configuration\n"); /* Detect sensor (sub)type */ high = i2c_r(sd, 0x0a); @@ -2631,22 +2633,22 @@ static void ov_hires_configure(struct sd *sd) case 0x96: switch (low) { case 0x40: - PDEBUG(D_PROBE, "Sensor is a OV2610"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV2610\n"); sd->sensor = SEN_OV2610; return; case 0x41: - PDEBUG(D_PROBE, "Sensor is a OV2610AE"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV2610AE\n"); sd->sensor = SEN_OV2610AE; return; case 0xb1: - PDEBUG(D_PROBE, "Sensor is a OV9600"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV9600\n"); sd->sensor = SEN_OV9600; return; } break; case 0x36: if ((low & 0x0f) == 0x00) { - PDEBUG(D_PROBE, "Sensor is a OV3610"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV3610\n"); sd->sensor = SEN_OV3610; return; } @@ -2664,7 +2666,7 @@ static void ov8xx0_configure(struct sd *sd) struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int rc; - PDEBUG(D_PROBE, "starting ov8xx0 configuration"); + gspca_dbg(gspca_dev, D_PROBE, "starting ov8xx0 configuration\n"); /* Detect sensor (sub)type */ rc = i2c_r(sd, OV7610_REG_COM_I); @@ -2687,7 +2689,7 @@ static void ov7xx0_configure(struct sd *sd) struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int rc, high, low; - PDEBUG(D_PROBE, "starting OV7xx0 configuration"); + gspca_dbg(gspca_dev, D_PROBE, "starting OV7xx0 configuration\n"); /* Detect sensor (sub)type */ rc = i2c_r(sd, OV7610_REG_COM_I); @@ -2704,19 +2706,20 @@ static void ov7xx0_configure(struct sd *sd) low = i2c_r(sd, 0x0b); /* info("%x, %x", high, low); */ if (high == 0x76 && (low & 0xf0) == 0x70) { - PDEBUG(D_PROBE, "Sensor is an OV76%02x", low); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV76%02x\n", + low); sd->sensor = SEN_OV7670; } else { - PDEBUG(D_PROBE, "Sensor is an OV7610"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7610\n"); sd->sensor = SEN_OV7610; } } else if ((rc & 3) == 1) { /* I don't know what's different about the 76BE yet. */ if (i2c_r(sd, 0x15) & 1) { - PDEBUG(D_PROBE, "Sensor is an OV7620AE"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7620AE\n"); sd->sensor = SEN_OV7620AE; } else { - PDEBUG(D_PROBE, "Sensor is an OV76BE"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV76BE\n"); sd->sensor = SEN_OV76BE; } } else if ((rc & 3) == 0) { @@ -2738,19 +2741,19 @@ static void ov7xx0_configure(struct sd *sd) gspca_err(gspca_dev, "7630 is not supported by this driver\n"); return; case 0x40: - PDEBUG(D_PROBE, "Sensor is an OV7645"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7645\n"); sd->sensor = SEN_OV7640; /* FIXME */ break; case 0x45: - PDEBUG(D_PROBE, "Sensor is an OV7645B"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7645B\n"); sd->sensor = SEN_OV7640; /* FIXME */ break; case 0x48: - PDEBUG(D_PROBE, "Sensor is an OV7648"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7648\n"); sd->sensor = SEN_OV7648; break; case 0x60: - PDEBUG(D_PROBE, "Sensor is a OV7660"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV7660\n"); sd->sensor = SEN_OV7660; break; default: @@ -2759,7 +2762,7 @@ static void ov7xx0_configure(struct sd *sd) return; } } else { - PDEBUG(D_PROBE, "Sensor is an OV7620"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7620\n"); sd->sensor = SEN_OV7620; } } else { @@ -2774,7 +2777,7 @@ static void ov6xx0_configure(struct sd *sd) struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; int rc; - PDEBUG(D_PROBE, "starting OV6xx0 configuration"); + gspca_dbg(gspca_dev, D_PROBE, "starting OV6xx0 configuration\n"); /* Detect sensor (sub)type */ rc = i2c_r(sd, OV7610_REG_COM_I); @@ -2793,15 +2796,15 @@ static void ov6xx0_configure(struct sd *sd) break; case 0x01: sd->sensor = SEN_OV6620; - PDEBUG(D_PROBE, "Sensor is an OV6620"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV6620\n"); break; case 0x02: sd->sensor = SEN_OV6630; - PDEBUG(D_PROBE, "Sensor is an OV66308AE"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV66308AE\n"); break; case 0x03: sd->sensor = SEN_OV66308AF; - PDEBUG(D_PROBE, "Sensor is an OV66308AF"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV66308AF\n"); break; case 0x90: sd->sensor = SEN_OV6630; @@ -2911,7 +2914,7 @@ static void ov51x_upload_quan_tables(struct sd *sd) unsigned char val0, val1; int i, size, reg = R51x_COMP_LUT_BEGIN; - PDEBUG(D_PROBE, "Uploading quantization tables"); + gspca_dbg(gspca_dev, D_PROBE, "Uploading quantization tables\n"); if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { pYTable = yQuanTable511; @@ -2989,7 +2992,8 @@ static void ov511_configure(struct gspca_dev *gspca_dev) { 0x77, 0x04 }, }; - PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); + gspca_dbg(gspca_dev, D_PROBE, "Device custom id %x\n", + reg_r(sd, R51x_SYS_CUST_ID)); write_regvals(sd, init_511, ARRAY_SIZE(init_511)); @@ -3059,7 +3063,7 @@ static void ov518_configure(struct gspca_dev *gspca_dev) /* First 5 bits of custom ID reg are a revision ID on OV518 */ sd->revision = reg_r(sd, R51x_SYS_CUST_ID) & 0x1f; - PDEBUG(D_PROBE, "Device revision %d", sd->revision); + gspca_dbg(gspca_dev, D_PROBE, "Device revision %d\n", sd->revision); write_regvals(sd, init_518, ARRAY_SIZE(init_518)); @@ -3866,8 +3870,8 @@ static void ov519_mode_init_regs(struct sd *sd) } break; case SEN_OV7670: /* guesses, based on 7640 */ - PDEBUG(D_STREAM, "Setting framerate to %d fps", - (sd->frame_rate == 0) ? 15 : sd->frame_rate); + gspca_dbg(gspca_dev, D_STREAM, "Setting framerate to %d fps\n", + (sd->frame_rate == 0) ? 15 : sd->frame_rate); reg_w(sd, 0xa4, 0x10); switch (sd->frame_rate) { case 30: diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c index bba2c5ce331c9..f293921a1f2b6 100644 --- a/drivers/media/usb/gspca/ov534.c +++ b/drivers/media/usb/gspca/ov534.c @@ -612,7 +612,7 @@ static void ov534_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val) if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "SET 01 0000 %04x %02x", reg, val); + gspca_dbg(gspca_dev, D_USBO, "SET 01 0000 %04x %02x\n", reg, val); gspca_dev->usb_buf[0] = val; ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -637,7 +637,8 @@ static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) 0x01, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); - PDEBUG(D_USBI, "GET 01 0000 %04x %02x", reg, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "GET 01 0000 %04x %02x\n", + reg, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("read failed %d\n", ret); gspca_dev->usb_err = ret; @@ -651,7 +652,7 @@ static void ov534_set_led(struct gspca_dev *gspca_dev, int status) { u8 data; - PDEBUG(D_CONF, "led status: %d", status); + gspca_dbg(gspca_dev, D_CONF, "led status: %d\n", status); data = ov534_reg_read(gspca_dev, 0x21); data |= 0x80; @@ -698,7 +699,7 @@ static int sccb_check_status(struct gspca_dev *gspca_dev) static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) { - PDEBUG(D_USBO, "sccb write: %02x %02x", reg, val); + gspca_dbg(gspca_dev, D_USBO, "sccb write: %02x %02x\n", reg, val); ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); @@ -800,7 +801,7 @@ static void set_frame_rate(struct gspca_dev *gspca_dev) sccb_reg_write(gspca_dev, 0x0d, r->r0d); ov534_reg_write(gspca_dev, 0xe5, r->re5); - PDEBUG(D_PROBE, "frame_rate: %d", r->fps); + gspca_dbg(gspca_dev, D_PROBE, "frame_rate: %d\n", r->fps); } static void sethue(struct gspca_dev *gspca_dev, s32 val) @@ -1283,7 +1284,7 @@ static int sd_init(struct gspca_dev *gspca_dev) sensor_id = sccb_reg_read(gspca_dev, 0x0a) << 8; sccb_reg_read(gspca_dev, 0x0b); sensor_id |= sccb_reg_read(gspca_dev, 0x0b); - PDEBUG(D_PROBE, "Sensor ID: %04x", sensor_id); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ID: %04x\n", sensor_id); if ((sensor_id & 0xfff0) == 0x7670) { sd->sensor = SENSOR_OV767x; @@ -1407,19 +1408,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, /* Verify UVC header. Header length is always 12 */ if (data[0] != 12 || len < 12) { - PDEBUG(D_PACK, "bad header"); + gspca_dbg(gspca_dev, D_PACK, "bad header\n"); goto discard; } /* Check errors */ if (data[1] & UVC_STREAM_ERR) { - PDEBUG(D_PACK, "payload error"); + gspca_dbg(gspca_dev, D_PACK, "payload error\n"); goto discard; } /* Extract PTS and FID */ if (!(data[1] & UVC_STREAM_PTS)) { - PDEBUG(D_PACK, "PTS not present"); + gspca_dbg(gspca_dev, D_PACK, "PTS not present\n"); goto discard; } this_pts = (data[5] << 24) | (data[4] << 16) @@ -1442,7 +1443,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, && gspca_dev->image_len + len - 12 != gspca_dev->pixfmt.width * gspca_dev->pixfmt.height * 2) { - PDEBUG(D_PACK, "wrong sized frame"); + gspca_dbg(gspca_dev, D_PACK, "wrong sized frame\n"); goto discard; } gspca_frame_add(gspca_dev, LAST_PACKET, diff --git a/drivers/media/usb/gspca/ov534_9.c b/drivers/media/usb/gspca/ov534_9.c index b2a92e518118f..3d1364d2f83e6 100644 --- a/drivers/media/usb/gspca/ov534_9.c +++ b/drivers/media/usb/gspca/ov534_9.c @@ -1133,7 +1133,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev, u16 reg, u8 val) static void reg_w(struct gspca_dev *gspca_dev, u16 reg, u8 val) { - PDEBUG(D_USBO, "reg_w [%04x] = %02x", reg, val); + gspca_dbg(gspca_dev, D_USBO, "reg_w [%04x] = %02x\n", reg, val); reg_w_i(gspca_dev, reg, val); } @@ -1149,7 +1149,8 @@ static u8 reg_r(struct gspca_dev *gspca_dev, u16 reg) 0x01, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); - PDEBUG(D_USBI, "reg_r [%04x] -> %02x", reg, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg_r [%04x] -> %02x\n", + reg, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_r err %d\n", ret); gspca_dev->usb_err = ret; @@ -1174,9 +1175,9 @@ static int sccb_check_status(struct gspca_dev *gspca_dev) case 0x03: break; default: - PDEBUG(D_USBI|D_USBO, - "sccb status 0x%02x, attempt %d/5", - data, i + 1); + gspca_dbg(gspca_dev, D_USBI|D_USBO, + "sccb status 0x%02x, attempt %d/5\n", + data, i + 1); } } return 0; @@ -1184,7 +1185,7 @@ static int sccb_check_status(struct gspca_dev *gspca_dev) static void sccb_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) { - PDEBUG(D_USBO, "sccb_write [%02x] = %02x", reg, val); + gspca_dbg(gspca_dev, D_USBO, "sccb_write [%02x] = %02x\n", reg, val); reg_w_i(gspca_dev, OV534_REG_SUBADDR, reg); reg_w_i(gspca_dev, OV534_REG_WRITE, val); reg_w_i(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); @@ -1238,7 +1239,7 @@ static void set_led(struct gspca_dev *gspca_dev, int status) { u8 data; - PDEBUG(D_CONF, "led status: %d", status); + gspca_dbg(gspca_dev, D_CONF, "led status: %d\n", status); data = reg_r(gspca_dev, 0x21); data |= 0x80; @@ -1423,7 +1424,7 @@ static int sd_init(struct gspca_dev *gspca_dev) sensor_id = sccb_read(gspca_dev, 0x0a) << 8; sccb_read(gspca_dev, 0x0b); sensor_id |= sccb_read(gspca_dev, 0x0b); - PDEBUG(D_PROBE, "Sensor ID: %04x", sensor_id); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ID: %04x\n", sensor_id); /* initialize */ if ((sensor_id & 0xfff0) == 0x9650) { @@ -1651,19 +1652,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, /* Verify UVC header. Header length is always 12 */ if (data[0] != 12 || len < 12) { - PDEBUG(D_PACK, "bad header"); + gspca_dbg(gspca_dev, D_PACK, "bad header\n"); goto discard; } /* Check errors */ if (data[1] & UVC_STREAM_ERR) { - PDEBUG(D_PACK, "payload error"); + gspca_dbg(gspca_dev, D_PACK, "payload error\n"); goto discard; } /* Extract PTS and FID */ if (!(data[1] & UVC_STREAM_PTS)) { - PDEBUG(D_PACK, "PTS not present"); + gspca_dbg(gspca_dev, D_PACK, "PTS not present\n"); goto discard; } this_pts = (data[5] << 24) | (data[4] << 16) diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c index 01c185d367e5d..a1df7af8fef5d 100644 --- a/drivers/media/usb/gspca/pac207.c +++ b/drivers/media/usb/gspca/pac207.c @@ -166,17 +166,17 @@ static int sd_config(struct gspca_dev *gspca_dev, idreg[1] = pac207_read_reg(gspca_dev, 0x0001); idreg[0] = ((idreg[0] & 0x0f) << 4) | ((idreg[1] & 0xf0) >> 4); idreg[1] = idreg[1] & 0x0f; - PDEBUG(D_PROBE, "Pixart Sensor ID 0x%02X Chips ID 0x%02X", - idreg[0], idreg[1]); + gspca_dbg(gspca_dev, D_PROBE, "Pixart Sensor ID 0x%02X Chips ID 0x%02X\n", + idreg[0], idreg[1]); if (idreg[0] != 0x27) { - PDEBUG(D_PROBE, "Error invalid sensor ID!"); + gspca_dbg(gspca_dev, D_PROBE, "Error invalid sensor ID!\n"); return -ENODEV; } - PDEBUG(D_PROBE, - "Pixart PAC207BCA Image Processor and Control Chip detected (vid/pid 0x%04X:0x%04X)", - id->idVendor, id->idProduct); + gspca_dbg(gspca_dev, D_PROBE, + "Pixart PAC207BCA Image Processor and Control Chip detected (vid/pid 0x%04X:0x%04X)\n", + id->idVendor, id->idProduct); cam = &gspca_dev->cam; cam->cam_mode = sif_mode; @@ -315,9 +315,9 @@ static int sd_start(struct gspca_dev *gspca_dev) mode = 0x02; if (gspca_dev->pixfmt.width == 176) { /* 176x144 */ mode |= 0x01; - PDEBUG(D_STREAM, "pac207_start mode 176x144"); + gspca_dbg(gspca_dev, D_STREAM, "pac207_start mode 176x144\n"); } else { /* 352x288 */ - PDEBUG(D_STREAM, "pac207_start mode 352x288"); + gspca_dbg(gspca_dev, D_STREAM, "pac207_start mode 352x288\n"); } pac207_write_reg(gspca_dev, 0x41, mode); diff --git a/drivers/media/usb/gspca/pac_common.h b/drivers/media/usb/gspca/pac_common.h index 4047bcb6c2b55..31f2a42af4dd4 100644 --- a/drivers/media/usb/gspca/pac_common.h +++ b/drivers/media/usb/gspca/pac_common.h @@ -107,10 +107,9 @@ static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, u8 *sof_read, switch (m[i]) { case 0x96: /* Pattern found */ - PDEBUG(D_FRAM, - "SOF found, bytes to analyze: %u." - " Frame starts at byte #%u", - len, i + 1); + gspca_dbg(gspca_dev, D_FRAM, + "SOF found, bytes to analyze: %u - Frame starts at byte #%u\n", + len, i + 1); *sof_read = 0; return m + i + 1; break; diff --git a/drivers/media/usb/gspca/sn9c2028.c b/drivers/media/usb/gspca/sn9c2028.c index 469bc2ced1a3d..a1f7189545e18 100644 --- a/drivers/media/usb/gspca/sn9c2028.c +++ b/drivers/media/usb/gspca/sn9c2028.c @@ -69,8 +69,9 @@ static int sn9c2028_command(struct gspca_dev *gspca_dev, u8 *command) { int rc; - PDEBUG(D_USBO, "sending command %02x%02x%02x%02x%02x%02x", command[0], - command[1], command[2], command[3], command[4], command[5]); + gspca_dbg(gspca_dev, D_USBO, "sending command %02x%02x%02x%02x%02x%02x\n", + command[0], command[1], command[2], + command[3], command[4], command[5]); memcpy(gspca_dev->usb_buf, command, 6); rc = usb_control_msg(gspca_dev->dev, @@ -100,7 +101,8 @@ static int sn9c2028_read1(struct gspca_dev *gspca_dev) pr_err("read1 error %d\n", rc); return (rc < 0) ? rc : -EIO; } - PDEBUG(D_USBI, "read1 response %02x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "read1 response %02x\n", + gspca_dev->usb_buf[0]); return gspca_dev->usb_buf[0]; } @@ -117,8 +119,8 @@ static int sn9c2028_read4(struct gspca_dev *gspca_dev, u8 *reading) return (rc < 0) ? rc : -EIO; } memcpy(reading, gspca_dev->usb_buf, 4); - PDEBUG(D_USBI, "read4 response %02x%02x%02x%02x", reading[0], - reading[1], reading[2], reading[3]); + gspca_dbg(gspca_dev, D_USBI, "read4 response %02x%02x%02x%02x\n", + reading[0], reading[1], reading[2], reading[3]); return rc; } @@ -175,32 +177,32 @@ static int sd_config(struct gspca_dev *gspca_dev, struct sd *sd = (struct sd *) gspca_dev; struct cam *cam = &gspca_dev->cam; - PDEBUG(D_PROBE, "SN9C2028 camera detected (vid/pid 0x%04X:0x%04X)", - id->idVendor, id->idProduct); + gspca_dbg(gspca_dev, D_PROBE, "SN9C2028 camera detected (vid/pid 0x%04X:0x%04X)\n", + id->idVendor, id->idProduct); sd->model = id->idProduct; switch (sd->model) { case 0x7005: - PDEBUG(D_PROBE, "Genius Smart 300 camera"); + gspca_dbg(gspca_dev, D_PROBE, "Genius Smart 300 camera\n"); break; case 0x7003: - PDEBUG(D_PROBE, "Genius Videocam Live v2"); + gspca_dbg(gspca_dev, D_PROBE, "Genius Videocam Live v2\n"); break; case 0x8000: - PDEBUG(D_PROBE, "DC31VC"); + gspca_dbg(gspca_dev, D_PROBE, "DC31VC\n"); break; case 0x8001: - PDEBUG(D_PROBE, "Spy camera"); + gspca_dbg(gspca_dev, D_PROBE, "Spy camera\n"); break; case 0x8003: - PDEBUG(D_PROBE, "CIF camera"); + gspca_dbg(gspca_dev, D_PROBE, "CIF camera\n"); break; case 0x8008: - PDEBUG(D_PROBE, "Mini-Shotz ms-350 camera"); + gspca_dbg(gspca_dev, D_PROBE, "Mini-Shotz ms-350 camera\n"); break; case 0x800a: - PDEBUG(D_PROBE, "Vivitar 3350b type camera"); + gspca_dbg(gspca_dev, D_PROBE, "Vivitar 3350b type camera\n"); cam->input_flags = V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP; break; } diff --git a/drivers/media/usb/gspca/sn9c2028.h b/drivers/media/usb/gspca/sn9c2028.h index 85761aa7c8b24..29f1571f9242f 100644 --- a/drivers/media/usb/gspca/sn9c2028.h +++ b/drivers/media/usb/gspca/sn9c2028.h @@ -43,10 +43,9 @@ static unsigned char *sn9c2028_find_sof(struct gspca_dev *gspca_dev, if (sd->sof_read == 12) sd->avg_lum = (m[i] << 8) + sd->avg_lum_l; if (sd->sof_read == sizeof(sn9c2028_sof_marker)) { - PDEBUG(D_FRAM, - "SOF found, bytes to analyze: %u." - " Frame starts at byte #%u", - len, i + 1); + gspca_dbg(gspca_dev, D_FRAM, + "SOF found, bytes to analyze: %u - Frame starts at byte #%u\n", + len, i + 1); sd->sof_read = 0; return m + i + 1; } diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c index c605f78d61867..cfa2a04d9f3f6 100644 --- a/drivers/media/usb/gspca/sn9c20x.c +++ b/drivers/media/usb/gspca/sn9c20x.c @@ -2153,7 +2153,7 @@ static void qual_upd(struct work_struct *work) /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */ mutex_lock(&gspca_dev->usb_lock); - PDEBUG(D_STREAM, "qual_upd %d%%", qual); + gspca_dbg(gspca_dev, D_STREAM, "qual_upd %d%%\n", qual); gspca_dev->usb_err = 0; set_quality(gspca_dev, qual); mutex_unlock(&gspca_dev->usb_lock); diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c index 9d7c3d8c226fe..df8d8482b7959 100644 --- a/drivers/media/usb/gspca/sonixj.c +++ b/drivers/media/usb/gspca/sonixj.c @@ -1166,7 +1166,8 @@ static void reg_r(struct gspca_dev *gspca_dev, value, 0, gspca_dev->usb_buf, len, 500); - PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg_r [%02x] -> %02x\n", + value, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_r err %d\n", ret); gspca_dev->usb_err = ret; @@ -1181,7 +1182,7 @@ static void reg_w1(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); + gspca_dbg(gspca_dev, D_USBO, "reg_w1 [%04x] = %02x\n", value, data); gspca_dev->usb_buf[0] = data; ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), @@ -1205,8 +1206,8 @@ static void reg_w(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", - value, buffer[0], buffer[1]); + gspca_dbg(gspca_dev, D_USBO, "reg_w [%04x] = %02x %02x ..\n", + value, buffer[0], buffer[1]); if (len > USB_BUF_SZ) { gspca_err(gspca_dev, "reg_w: buffer overflow\n"); @@ -1235,7 +1236,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); + gspca_dbg(gspca_dev, D_USBO, "i2c_w1 [%02x] = %02x\n", reg, val); switch (sd->sensor) { case SENSOR_ADCM1700: case SENSOR_OM6802: @@ -1276,8 +1277,8 @@ static void i2c_w8(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", - buffer[2], buffer[3]); + gspca_dbg(gspca_dev, D_USBO, "i2c_w8 [%02x] = %02x ..\n", + buffer[2], buffer[3]); memcpy(gspca_dev->usb_buf, buffer, 8); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), @@ -1349,7 +1350,7 @@ static void hv7131r_probe(struct gspca_dev *gspca_dev) if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */ && gspca_dev->usb_buf[1] == 0x09 && gspca_dev->usb_buf[2] == 0x01) { - PDEBUG(D_PROBE, "Sensor HV7131R found"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor HV7131R found\n"); return; } pr_warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x\n", @@ -1396,18 +1397,19 @@ static void mi0360_probe(struct gspca_dev *gspca_dev) return; switch (val) { case 0x8221: - PDEBUG(D_PROBE, "Sensor mi0360b"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor mi0360b\n"); sd->sensor = SENSOR_MI0360B; break; case 0x823a: - PDEBUG(D_PROBE, "Sensor mt9v111"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor mt9v111\n"); sd->sensor = SENSOR_MT9V111; break; case 0x8243: - PDEBUG(D_PROBE, "Sensor mi0360"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor mi0360\n"); break; default: - PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val); + gspca_dbg(gspca_dev, D_PROBE, "Unknown sensor %04x - forced to mi0360\n", + val); break; } } @@ -1432,10 +1434,10 @@ static void ov7630_probe(struct gspca_dev *gspca_dev) /*fixme: only valid for 0c45:613e?*/ gspca_dev->cam.input_flags = V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP; - PDEBUG(D_PROBE, "Sensor soi768"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor soi768\n"); return; } - PDEBUG(D_PROBE, "Sensor ov%04x", val); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ov%04x\n", val); } static void ov7648_probe(struct gspca_dev *gspca_dev) @@ -1452,7 +1454,7 @@ static void ov7648_probe(struct gspca_dev *gspca_dev) reg_w1(gspca_dev, 0x01, 0x29); reg_w1(gspca_dev, 0x17, 0x42); if ((val & 0xff00) == 0x7600) { /* ov76xx */ - PDEBUG(D_PROBE, "Sensor ov%04x", val); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ov%04x\n", val); return; } @@ -1467,7 +1469,7 @@ static void ov7648_probe(struct gspca_dev *gspca_dev) if (gspca_dev->usb_err < 0) return; if (val == 0x1030) { /* po1030 */ - PDEBUG(D_PROBE, "Sensor po1030"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor po1030\n"); sd->sensor = SENSOR_PO1030; return; } @@ -1490,7 +1492,7 @@ static void po2030n_probe(struct gspca_dev *gspca_dev) reg_w1(gspca_dev, 0x01, 0x29); /* reset */ reg_w1(gspca_dev, 0x17, 0x42); if (val == 0x99) { /* gc0307 (?) */ - PDEBUG(D_PROBE, "Sensor gc0307"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor gc0307\n"); sd->sensor = SENSOR_GC0307; return; } @@ -1506,7 +1508,7 @@ static void po2030n_probe(struct gspca_dev *gspca_dev) if (gspca_dev->usb_err < 0) return; if (val == 0x2030) { - PDEBUG(D_PROBE, "Sensor po2030n"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor po2030n\n"); /* sd->sensor = SENSOR_PO2030N; */ } else { pr_err("Unknown sensor ID %04x\n", val); @@ -1558,7 +1560,7 @@ static int sd_init(struct gspca_dev *gspca_dev) regF1 = gspca_dev->usb_buf[0]; if (gspca_dev->usb_err < 0) return gspca_dev->usb_err; - PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); + gspca_dbg(gspca_dev, D_PROBE, "Sonix chip id: %02x\n", regF1); if (gspca_dev->audio) regGpio[1] |= 0x04; /* with audio */ switch (sd->bridge) { @@ -1758,10 +1760,10 @@ static u32 expo_adjust(struct gspca_dev *gspca_dev, | ((expo & 0x0003) << 4); i2c_w8(gspca_dev, expoMo10); i2c_w8(gspca_dev, gainMo); - PDEBUG(D_FRAM, "set exposure %d", - ((expoMo10[3] & 0x07) << 10) - | (expoMof[3] << 2) - | ((expoMo10[3] & 0x30) >> 4)); + gspca_dbg(gspca_dev, D_FRAM, "set exposure %d\n", + ((expoMo10[3] & 0x07) << 10) + | (expoMof[3] << 2) + | ((expoMo10[3] & 0x30) >> 4)); break; } case SENSOR_MT9V111: { @@ -1789,7 +1791,7 @@ static u32 expo_adjust(struct gspca_dev *gspca_dev, gainOm[3] = expo >> 2; i2c_w8(gspca_dev, gainOm); reg_w1(gspca_dev, 0x96, expo >> 5); - PDEBUG(D_FRAM, "set exposure %d", gainOm[3]); + gspca_dbg(gspca_dev, D_FRAM, "set exposure %d\n", gainOm[3]); break; } } @@ -2162,7 +2164,7 @@ static void qual_upd(struct work_struct *work) /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */ mutex_lock(&gspca_dev->usb_lock); - PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality); + gspca_dbg(gspca_dev, D_STREAM, "qual_upd %d%%\n", sd->quality); gspca_dev->usb_err = 0; setjpegqual(gspca_dev); mutex_unlock(&gspca_dev->usb_lock); @@ -2584,7 +2586,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) sd->ag_cnt = AG_CNT_START; delta = atomic_read(&sd->avg_lum); - PDEBUG(D_FRAM, "mean lum %d", delta); + gspca_dbg(gspca_dev, D_FRAM, "mean lum %d\n", delta); if (sd->sensor == SENSOR_PO2030N) { gspca_expo_autogain(gspca_dev, delta, luma_mean, luma_delta, diff --git a/drivers/media/usb/gspca/spca1528.c b/drivers/media/usb/gspca/spca1528.c index e53dd3c7066cc..d25924e430f37 100644 --- a/drivers/media/usb/gspca/spca1528.c +++ b/drivers/media/usb/gspca/spca1528.c @@ -75,8 +75,8 @@ static void reg_r(struct gspca_dev *gspca_dev, index, gspca_dev->usb_buf, len, 500); - PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", req, index, - gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "GET %02x 0000 %04x %02x\n", req, index, + gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_r err %d\n", ret); gspca_dev->usb_err = ret; @@ -93,7 +93,7 @@ static void reg_w(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "SET %02x %04x %04x", req, value, index); + gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n", req, value, index); ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), req, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -116,7 +116,8 @@ static void reg_wb(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "SET %02x %04x %04x %02x", req, value, index, byte); + gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x %02x\n", + req, value, index, byte); gspca_dev->usb_buf[0] = byte; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), req, @@ -216,8 +217,8 @@ static int sd_init(struct gspca_dev *gspca_dev) reg_r(gspca_dev, 0x20, 0x0000, 1); reg_r(gspca_dev, 0x20, 0x0000, 5); reg_r(gspca_dev, 0x23, 0x0000, 64); - PDEBUG(D_PROBE, "%s%s", &gspca_dev->usb_buf[0x1c], - &gspca_dev->usb_buf[0x30]); + gspca_dbg(gspca_dev, D_PROBE, "%s%s\n", &gspca_dev->usb_buf[0x1c], + &gspca_dev->usb_buf[0x30]); reg_r(gspca_dev, 0x23, 0x0001, 64); return gspca_dev->usb_err; } diff --git a/drivers/media/usb/gspca/spca500.c b/drivers/media/usb/gspca/spca500.c index b25960643f7b2..e90d2f3b4a67f 100644 --- a/drivers/media/usb/gspca/spca500.c +++ b/drivers/media/usb/gspca/spca500.c @@ -328,7 +328,8 @@ static int reg_w(struct gspca_dev *gspca_dev, { int ret; - PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value); + gspca_dbg(gspca_dev, D_USBO, "reg write: [0x%02x] = 0x%02x\n", + index, value); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), req, @@ -423,15 +424,15 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, static void spca500_ping310(struct gspca_dev *gspca_dev) { reg_r(gspca_dev, 0x0d04, 2); - PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); + gspca_dbg(gspca_dev, D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x\n", + gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); } static void spca500_clksmart310_init(struct gspca_dev *gspca_dev) { reg_r(gspca_dev, 0x0d05, 2); - PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); + gspca_dbg(gspca_dev, D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x\n", + gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); reg_w(gspca_dev, 0x00, 0x8167, 0x5a); spca500_ping310(gspca_dev); @@ -509,7 +510,8 @@ static int spca500_synch310(struct gspca_dev *gspca_dev) reg_r(gspca_dev, 0x0d00, 1); /* need alt setting here */ - PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt); + gspca_dbg(gspca_dev, D_PACK, "ClickSmart310 sync alt: %d\n", + gspca_dev->alt); /* Windoze use pipe with altsetting 6 why 7 here */ if (usb_set_interface(gspca_dev->dev, @@ -587,12 +589,12 @@ static int sd_init(struct gspca_dev *gspca_dev) struct sd *sd = (struct sd *) gspca_dev; /* initialisation of spca500 based cameras is deferred */ - PDEBUG(D_STREAM, "SPCA500 init"); + gspca_dbg(gspca_dev, D_STREAM, "SPCA500 init\n"); if (sd->subtype == LogitechClickSmart310) spca500_clksmart310_init(gspca_dev); /* else spca500_initialise(gspca_dev); */ - PDEBUG(D_STREAM, "SPCA500 init done"); + gspca_dbg(gspca_dev, D_STREAM, "SPCA500 init done\n"); return 0; } @@ -619,10 +621,10 @@ static int sd_start(struct gspca_dev *gspca_dev) /* is there a sensor here ? */ reg_r(gspca_dev, 0x8a04, 1); - PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02x", - gspca_dev->usb_buf[0]); - PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02x, Ymult: 0x%02x", - gspca_dev->curr_mode, xmult, ymult); + gspca_dbg(gspca_dev, D_STREAM, "Spca500 Sensor Address 0x%02x\n", + gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02x, Ymult: 0x%02x", + gspca_dev->curr_mode, xmult, ymult); /* setup qtable */ switch (sd->subtype) { @@ -820,8 +822,8 @@ static void sd_stopN(struct gspca_dev *gspca_dev) /* switch to video camera mode */ reg_w(gspca_dev, 0x00, 0x8000, 0x0004); reg_r(gspca_dev, 0x8000, 1); - PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", - gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_STREAM, "stop SPCA500 done reg8000: 0x%2x\n", + gspca_dev->usb_buf[0]); } static void sd_pkt_scan(struct gspca_dev *gspca_dev, diff --git a/drivers/media/usb/gspca/spca501.c b/drivers/media/usb/gspca/spca501.c index 29861588302f8..2cce74b166d82 100644 --- a/drivers/media/usb/gspca/spca501.c +++ b/drivers/media/usb/gspca/spca501.c @@ -1763,8 +1763,8 @@ static int reg_write(struct gspca_dev *gspca_dev, req, USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, NULL, 0, 500); - PDEBUG(D_USBO, "reg write: 0x%02x 0x%02x 0x%02x", - req, index, value); + gspca_dbg(gspca_dev, D_USBO, "reg write: 0x%02x 0x%02x 0x%02x\n", + req, index, value); if (ret < 0) pr_err("reg write: error %d\n", ret); return ret; @@ -1852,7 +1852,7 @@ static int sd_init(struct gspca_dev *gspca_dev) goto error; break; } - PDEBUG(D_STREAM, "Initializing SPCA501 finished"); + gspca_dbg(gspca_dev, D_STREAM, "Initializing SPCA501 finished\n"); return 0; error: return -EINVAL; diff --git a/drivers/media/usb/gspca/spca505.c b/drivers/media/usb/gspca/spca505.c index 02b5e2d81c643..07aae9cd5a30c 100644 --- a/drivers/media/usb/gspca/spca505.c +++ b/drivers/media/usb/gspca/spca505.c @@ -551,8 +551,8 @@ static int reg_write(struct gspca_dev *gspca_dev, req, USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, NULL, 0, 500); - PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", - req, index, value, ret); + gspca_dbg(gspca_dev, D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d\n", + req, index, value, ret); if (ret < 0) pr_err("reg write: error %d\n", ret); return ret; diff --git a/drivers/media/usb/gspca/spca506.c b/drivers/media/usb/gspca/spca506.c index 843c93f5acf3a..6332b3f0b918f 100644 --- a/drivers/media/usb/gspca/spca506.c +++ b/drivers/media/usb/gspca/spca506.c @@ -126,7 +126,7 @@ static void spca506_SetNormeInput(struct gspca_dev *gspca_dev, __u8 setbit1 = 0x00; __u8 videomask = 0x00; - PDEBUG(D_STREAM, "** Open Set Norme **"); + gspca_dbg(gspca_dev, D_STREAM, "** Open Set Norme **\n"); spca506_Initi2c(gspca_dev); /* NTSC bit0 -> 1(525 l) PAL SECAM bit0 -> 0 (625 l) */ /* Composite channel bit1 -> 1 S-video bit 1 -> 0 */ @@ -153,8 +153,9 @@ static void spca506_SetNormeInput(struct gspca_dev *gspca_dev, sd->norme = norme; sd->channel = channel; - PDEBUG(D_STREAM, "Set Video Byte to 0x%2x", videomask); - PDEBUG(D_STREAM, "Set Norme: %08x Channel %d", norme, channel); + gspca_dbg(gspca_dev, D_STREAM, "Set Video Byte to 0x%2x\n", videomask); + gspca_dbg(gspca_dev, D_STREAM, "Set Norme: %08x Channel %d", + norme, channel); } static void spca506_GetNormeInput(struct gspca_dev *gspca_dev, @@ -166,7 +167,8 @@ static void spca506_GetNormeInput(struct gspca_dev *gspca_dev, we use your own copy in spca50x struct */ *norme = sd->norme; *channel = sd->channel; - PDEBUG(D_STREAM, "Get Norme: %d Channel %d", *norme, *channel); + gspca_dbg(gspca_dev, D_STREAM, "Get Norme: %d Channel %d\n", + *norme, *channel); } static void spca506_Setsize(struct gspca_dev *gspca_dev, __u16 code, @@ -174,7 +176,7 @@ static void spca506_Setsize(struct gspca_dev *gspca_dev, __u16 code, { struct usb_device *dev = gspca_dev->dev; - PDEBUG(D_STREAM, "** SetSize **"); + gspca_dbg(gspca_dev, D_STREAM, "** SetSize **\n"); reg_w(dev, 0x04, (0x18 | (code & 0x07)), 0x0000); /* Soft snap 0x40 Hard 0x41 */ reg_w(dev, 0x04, 0x41, 0x0001); @@ -317,7 +319,7 @@ static int sd_init(struct gspca_dev *gspca_dev) spca506_WriteI2c(gspca_dev, 0x00, 0x60); spca506_WriteI2c(gspca_dev, 0x05, 0x61); spca506_WriteI2c(gspca_dev, 0x9f, 0x62); - PDEBUG(D_STREAM, "** Close Init *"); + gspca_dbg(gspca_dev, D_STREAM, "** Close Init *\n"); return 0; } @@ -445,7 +447,7 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w(dev, 0x02, 0x01, 0x0000); reg_w(dev, 0x03, 0x12, 0x0000); reg_r(gspca_dev, 0x04, 0x0001, 2); - PDEBUG(D_STREAM, "webcam started"); + gspca_dbg(gspca_dev, D_STREAM, "webcam started\n"); spca506_GetNormeInput(gspca_dev, &norme, &channel); spca506_SetNormeInput(gspca_dev, norme, channel); return 0; diff --git a/drivers/media/usb/gspca/spca508.c b/drivers/media/usb/gspca/spca508.c index aafffaf1d2b52..d80fd397eaf23 100644 --- a/drivers/media/usb/gspca/spca508.c +++ b/drivers/media/usb/gspca/spca508.c @@ -1247,8 +1247,8 @@ static int reg_write(struct gspca_dev *gspca_dev, u16 index, u16 value) 0, /* request */ USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, NULL, 0, 500); - PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x", - index, value); + gspca_dbg(gspca_dev, D_USBO, "reg write i:0x%04x = 0x%02x\n", + index, value); if (ret < 0) pr_err("reg write: error %d\n", ret); return ret; @@ -1269,8 +1269,8 @@ static int reg_read(struct gspca_dev *gspca_dev, index, gspca_dev->usb_buf, 1, 500); /* timeout */ - PDEBUG(D_USBI, "reg read i:%04x --> %02x", - index, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg read i:%04x --> %02x\n", + index, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_read err %d\n", ret); return ret; @@ -1366,14 +1366,17 @@ static int sd_config(struct gspca_dev *gspca_dev, * is a 508. */ data1 = reg_read(gspca_dev, 0x8104); data2 = reg_read(gspca_dev, 0x8105); - PDEBUG(D_PROBE, "Webcam Vendor ID: 0x%02x%02x", data2, data1); + gspca_dbg(gspca_dev, D_PROBE, "Webcam Vendor ID: 0x%02x%02x\n", + data2, data1); data1 = reg_read(gspca_dev, 0x8106); data2 = reg_read(gspca_dev, 0x8107); - PDEBUG(D_PROBE, "Webcam Product ID: 0x%02x%02x", data2, data1); + gspca_dbg(gspca_dev, D_PROBE, "Webcam Product ID: 0x%02x%02x\n", + data2, data1); data1 = reg_read(gspca_dev, 0x8621); - PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); + gspca_dbg(gspca_dev, D_PROBE, "Window 1 average luminance: %d\n", + data1); cam = &gspca_dev->cam; cam->cam_mode = sif_mode; diff --git a/drivers/media/usb/gspca/spca561.c b/drivers/media/usb/gspca/spca561.c index a75bd90bd9e3e..f389a8d0937d8 100644 --- a/drivers/media/usb/gspca/spca561.c +++ b/drivers/media/usb/gspca/spca561.c @@ -290,7 +290,8 @@ static void reg_w_val(struct gspca_dev *gspca_dev, __u16 index, __u8 value) 0, /* request */ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, NULL, 0, 500); - PDEBUG(D_USBO, "reg write: 0x%02x:0x%02x", index, value); + gspca_dbg(gspca_dev, D_USBO, "reg write: 0x%02x:0x%02x\n", + index, value); if (ret < 0) pr_err("reg write: error %d\n", ret); } @@ -420,7 +421,7 @@ static int sd_config(struct gspca_dev *gspca_dev, data2 = gspca_dev->usb_buf[0]; product = (data2 << 8) | data1; if (vendor != id->idVendor || product != id->idProduct) { - PDEBUG(D_PROBE, "Bad vendor / product from device"); + gspca_dbg(gspca_dev, D_PROBE, "Bad vendor / product from device\n"); return -EINVAL; } @@ -442,13 +443,13 @@ static int sd_config(struct gspca_dev *gspca_dev, /* this function is called at probe and resume time */ static int sd_init_12a(struct gspca_dev *gspca_dev) { - PDEBUG(D_STREAM, "Chip revision: 012a"); + gspca_dbg(gspca_dev, D_STREAM, "Chip revision: 012a\n"); init_161rev12A(gspca_dev); return 0; } static int sd_init_72a(struct gspca_dev *gspca_dev) { - PDEBUG(D_STREAM, "Chip revision: 072a"); + gspca_dbg(gspca_dev, D_STREAM, "Chip revision: 072a\n"); write_vector(gspca_dev, rev72a_reset); msleep(200); write_vector(gspca_dev, rev72a_init_data1); @@ -679,25 +680,16 @@ static void do_autogain(struct gspca_dev *gspca_dev) y = (77 * R + 75 * (Gr + Gb) + 29 * B) >> 8; /* u= (128*B-(43*(Gr+Gb+R))) >> 8; */ /* v= (128*R-(53*(Gr+Gb))-21*B) >> 8; */ - /* PDEBUG(D_CONF,"reading Y %d U %d V %d ",y,u,v); */ if (y < luma_mean - luma_delta || y > luma_mean + luma_delta) { expotimes = i2c_read(gspca_dev, 0x09, 0x10); pixelclk = 0x0800; expotimes = expotimes & 0x07ff; - /* PDEBUG(D_PACK, - "Exposition Times 0x%03X Clock 0x%04X ", - expotimes,pixelclk); */ gainG = i2c_read(gspca_dev, 0x35, 0x10); - /* PDEBUG(D_PACK, - "reading Gain register %d", gainG); */ expotimes += (luma_mean - y) >> spring; gainG += (luma_mean - y) / 50; - /* PDEBUG(D_PACK, - "compute expotimes %d gain %d", - expotimes,gainG); */ if (gainG > 0x3f) gainG = 0x3f; @@ -728,7 +720,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, /* This should never happen */ if (len < 2) { - gspca_err(gspca_dev, "Short SOF packet, ignoring\n"); + gspca_err(gspca_dev, "Short SOF packet, ignoring\n\n\n\n\n"); gspca_dev->last_packet_type = DISCARD_PACKET; return; } diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c index 948808305a6af..cc8ff41b8ab3a 100644 --- a/drivers/media/usb/gspca/sq905.c +++ b/drivers/media/usb/gspca/sq905.c @@ -246,9 +246,9 @@ static void sq905_dostream(struct work_struct *work) ret = sq905_read_data(gspca_dev, buffer, data_len, 1); if (ret < 0) goto quit_stream; - PDEBUG(D_PACK, - "Got %d bytes out of %d for frame", - data_len, bytes_left); + gspca_dbg(gspca_dev, D_PACK, + "Got %d bytes out of %d for frame\n", + data_len, bytes_left); bytes_left -= data_len; data = buffer; if (!header_read) { @@ -345,7 +345,7 @@ static int sd_init(struct gspca_dev *gspca_dev) ret = sq905_command(gspca_dev, SQ905_CLEAR); if (ret < 0) return ret; - PDEBUG(D_CONF, "SQ905 camera ID %08x detected", ident); + gspca_dbg(gspca_dev, D_CONF, "SQ905 camera ID %08x detected\n", ident); gspca_dev->cam.cam_mode = sq905_mode; gspca_dev->cam.nmodes = ARRAY_SIZE(sq905_mode); if (!(ident & SQ905_HIRES_MASK)) @@ -369,15 +369,15 @@ static int sd_start(struct gspca_dev *gspca_dev) switch (gspca_dev->curr_mode) { default: /* case 2: */ - PDEBUG(D_STREAM, "Start streaming at high resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at high resolution\n"); ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH); break; case 1: - PDEBUG(D_STREAM, "Start streaming at medium resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at medium resolution\n"); ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED); break; case 0: - PDEBUG(D_STREAM, "Start streaming at low resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at low resolution\n"); ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW); } diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c index 4fbfcf366f71c..5e1269eb7c50f 100644 --- a/drivers/media/usb/gspca/sq905c.c +++ b/drivers/media/usb/gspca/sq905c.c @@ -154,15 +154,16 @@ static void sq905c_dostream(struct work_struct *work) usb_rcvbulkpipe(gspca_dev->dev, 0x81), buffer, FRAME_HEADER_LEN, &act_len, SQ905C_DATA_TIMEOUT); - PDEBUG(D_STREAM, - "Got %d bytes out of %d for header", - act_len, FRAME_HEADER_LEN); + gspca_dbg(gspca_dev, D_STREAM, + "Got %d bytes out of %d for header\n", + act_len, FRAME_HEADER_LEN); if (ret < 0 || act_len < FRAME_HEADER_LEN) goto quit_stream; /* size is read from 4 bytes starting 0x40, little endian */ bytes_left = buffer[0x40]|(buffer[0x41]<<8)|(buffer[0x42]<<16) |(buffer[0x43]<<24); - PDEBUG(D_STREAM, "bytes_left = 0x%x", bytes_left); + gspca_dbg(gspca_dev, D_STREAM, "bytes_left = 0x%x\n", + bytes_left); /* We keep the header. It has other information, too. */ packet_type = FIRST_PACKET; gspca_frame_add(gspca_dev, packet_type, @@ -176,9 +177,9 @@ static void sq905c_dostream(struct work_struct *work) SQ905C_DATA_TIMEOUT); if (ret < 0 || act_len < data_len) goto quit_stream; - PDEBUG(D_STREAM, - "Got %d bytes out of %d for frame", - data_len, bytes_left); + gspca_dbg(gspca_dev, D_STREAM, + "Got %d bytes out of %d for frame\n", + data_len, bytes_left); bytes_left -= data_len; if (bytes_left == 0) packet_type = LAST_PACKET; @@ -205,9 +206,9 @@ static int sd_config(struct gspca_dev *gspca_dev, struct sd *dev = (struct sd *) gspca_dev; int ret; - PDEBUG(D_PROBE, - "SQ9050 camera detected (vid/pid 0x%04X:0x%04X)", - id->idVendor, id->idProduct); + gspca_dbg(gspca_dev, D_PROBE, + "SQ9050 camera detected (vid/pid 0x%04X:0x%04X)\n", + id->idVendor, id->idProduct); ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0); if (ret < 0) { @@ -221,9 +222,9 @@ static int sd_config(struct gspca_dev *gspca_dev, return ret; } /* Note we leave out the usb id and the manufacturing date */ - PDEBUG(D_PROBE, - "SQ9050 ID string: %02x - %*ph", - gspca_dev->usb_buf[3], 6, gspca_dev->usb_buf + 14); + gspca_dbg(gspca_dev, D_PROBE, + "SQ9050 ID string: %02x - %*ph\n", + gspca_dev->usb_buf[3], 6, gspca_dev->usb_buf + 14); cam->cam_mode = sq905c_mode; cam->nmodes = 2; @@ -267,13 +268,13 @@ static int sd_start(struct gspca_dev *gspca_dev) /* "Open the shutter" and set size, to start capture */ switch (gspca_dev->pixfmt.width) { case 640: - PDEBUG(D_STREAM, "Start streaming at high resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at high resolution\n"); dev->cap_mode++; ret = sq905c_command(gspca_dev, SQ905C_CAPTURE_HI, SQ905C_CAPTURE_INDEX); break; default: /* 320 */ - PDEBUG(D_STREAM, "Start streaming at medium resolution"); + gspca_dbg(gspca_dev, D_STREAM, "Start streaming at medium resolution\n"); ret = sq905c_command(gspca_dev, SQ905C_CAPTURE_MED, SQ905C_CAPTURE_INDEX); } diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c index af48bd6dbe8cd..d7cbcf2b39479 100644 --- a/drivers/media/usb/gspca/sq930x.c +++ b/drivers/media/usb/gspca/sq930x.c @@ -443,7 +443,7 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "reg_w v: %04x i: %04x", value, index); + gspca_dbg(gspca_dev, D_USBO, "reg_w v: %04x i: %04x\n", value, index); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x0c, /* request */ @@ -464,8 +464,8 @@ static void reg_wb(struct gspca_dev *gspca_dev, u16 value, u16 index, if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "reg_wb v: %04x i: %04x %02x...%02x", - value, index, *data, data[len - 1]); + gspca_dbg(gspca_dev, D_USBO, "reg_wb v: %04x i: %04x %02x...%02x\n", + value, index, *data, data[len - 1]); memcpy(gspca_dev->usb_buf, data, len); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), @@ -510,8 +510,8 @@ static void i2c_write(struct sd *sd, *buf++ = cmd->val; } - PDEBUG(D_USBO, "i2c_w v: %04x i: %04x %02x...%02x", - val, idx, gspca_dev->usb_buf[0], buf[-1]); + gspca_dbg(gspca_dev, D_USBO, "i2c_w v: %04x i: %04x %02x...%02x\n", + val, idx, gspca_dev->usb_buf[0], buf[-1]); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x0c, /* request */ @@ -560,12 +560,12 @@ static void ucbus_write(struct gspca_dev *gspca_dev, *buf++ = cmd->bw_data; } if (buf != gspca_dev->usb_buf) - PDEBUG(D_USBO, "ucbus v: %04x i: %04x %02x...%02x", - val, idx, - gspca_dev->usb_buf[0], buf[-1]); + gspca_dbg(gspca_dev, D_USBO, "ucbus v: %04x i: %04x %02x...%02x\n", + val, idx, + gspca_dev->usb_buf[0], buf[-1]); else - PDEBUG(D_USBO, "ucbus v: %04x i: %04x", - val, idx); + gspca_dbg(gspca_dev, D_USBO, "ucbus v: %04x i: %04x\n", + val, idx); ret = usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 0x0c, /* request */ @@ -691,7 +691,7 @@ static void mt9v111_init(struct gspca_dev *gspca_dev) || gspca_dev->usb_err != 0) break; if (--nwait < 0) { - PDEBUG(D_PROBE, "mt9v111_init timeout"); + gspca_dbg(gspca_dev, D_PROBE, "mt9v111_init timeout\n"); gspca_dev->usb_err = -ETIME; return; } @@ -857,7 +857,7 @@ static int sd_init(struct gspca_dev *gspca_dev) * 6: c8 / c9 / ca / cf = mode webcam?, sensor? webcam? * 7: 00 */ - PDEBUG(D_PROBE, "info: %*ph", 8, gspca_dev->usb_buf); + gspca_dbg(gspca_dev, D_PROBE, "info: %*ph\n", 8, gspca_dev->usb_buf); bridge_init(sd); @@ -870,7 +870,8 @@ static int sd_init(struct gspca_dev *gspca_dev) cmos_probe(gspca_dev); } if (gspca_dev->usb_err >= 0) { - PDEBUG(D_PROBE, "Sensor %s", sensor_tb[sd->sensor].name); + gspca_dbg(gspca_dev, D_PROBE, "Sensor %s\n", + sensor_tb[sd->sensor].name); global_init(sd, 1); } return gspca_dev->usb_err; diff --git a/drivers/media/usb/gspca/stk014.c b/drivers/media/usb/gspca/stk014.c index daf45db6c4047..0d8f489ddef27 100644 --- a/drivers/media/usb/gspca/stk014.c +++ b/drivers/media/usb/gspca/stk014.c @@ -290,8 +290,8 @@ static int sd_start(struct gspca_dev *gspca_dev) set_par(gspca_dev, 0x01000000); set_par(gspca_dev, 0x01000000); if (gspca_dev->usb_err >= 0) - PDEBUG(D_STREAM, "camera started alt: 0x%02x", - gspca_dev->alt); + gspca_dbg(gspca_dev, D_STREAM, "camera started alt: 0x%02x\n", + gspca_dev->alt); out: return gspca_dev->usb_err; } @@ -312,7 +312,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x0640, 0); reg_w(gspca_dev, 0x0650, 0); reg_w(gspca_dev, 0x0660, 0); - PDEBUG(D_STREAM, "camera stopped"); + gspca_dbg(gspca_dev, D_STREAM, "camera stopped\n"); } static void sd_pkt_scan(struct gspca_dev *gspca_dev, diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c index 3ab5ec2ca4bd7..6f52a480c2d85 100644 --- a/drivers/media/usb/gspca/stk1135.c +++ b/drivers/media/usb/gspca/stk1135.c @@ -67,7 +67,8 @@ static u8 reg_r(struct gspca_dev *gspca_dev, u16 index) gspca_dev->usb_buf, 1, 500); - PDEBUG(D_USBI, "reg_r 0x%x=0x%02x", index, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "reg_r 0x%x=0x%02x\n", + index, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_r 0x%x err %d\n", index, ret); gspca_dev->usb_err = ret; @@ -93,7 +94,7 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 index, u8 val) NULL, 0, 500); - PDEBUG(D_USBO, "reg_w 0x%x:=0x%02x", index, val); + gspca_dbg(gspca_dev, D_USBO, "reg_w 0x%x:=0x%02x\n", index, val); if (ret < 0) { pr_err("reg_w 0x%x err %d\n", index, ret); gspca_dev->usb_err = ret; @@ -468,8 +469,8 @@ static int sd_start(struct gspca_dev *gspca_dev) reg_w_mask(gspca_dev, STK1135_REG_SCTRL, 0x80, 0x80); if (gspca_dev->usb_err >= 0) - PDEBUG(D_STREAM, "camera started alt: 0x%02x", - gspca_dev->alt); + gspca_dbg(gspca_dev, D_STREAM, "camera started alt: 0x%02x\n", + gspca_dev->alt); sd->pkt_seq = 0; @@ -484,7 +485,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) stk1135_camera_disable(gspca_dev); - PDEBUG(D_STREAM, "camera stopped"); + gspca_dbg(gspca_dev, D_STREAM, "camera stopped\n"); } static void sd_pkt_scan(struct gspca_dev *gspca_dev, @@ -499,7 +500,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, u8 seq; if (len < 4) { - PDEBUG(D_PACK, "received short packet (less than 4 bytes)"); + gspca_dbg(gspca_dev, D_PACK, "received short packet (less than 4 bytes)\n"); return; } @@ -515,7 +516,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, if (!(hdr->flags & STK1135_HDR_FRAME_START)) { seq = hdr->seq & STK1135_HDR_SEQ_MASK; if (seq != sd->pkt_seq) { - PDEBUG(D_PACK, "received out-of-sequence packet"); + gspca_dbg(gspca_dev, D_PACK, "received out-of-sequence packet\n"); /* resync sequence and discard packet */ sd->pkt_seq = seq; gspca_dev->last_packet_type = DISCARD_PACKET; diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c index 4ff6ae18d8dd2..3ff5ed74bd9f2 100644 --- a/drivers/media/usb/gspca/stv0680.c +++ b/drivers/media/usb/gspca/stv0680.c @@ -167,13 +167,13 @@ static int sd_config(struct gspca_dev *gspca_dev, return -ENODEV; } if (gspca_dev->usb_buf[7] & 0x01) - PDEBUG(D_PROBE, "Camera supports CIF mode"); + gspca_dbg(gspca_dev, D_PROBE, "Camera supports CIF mode\n"); if (gspca_dev->usb_buf[7] & 0x02) - PDEBUG(D_PROBE, "Camera supports VGA mode"); + gspca_dbg(gspca_dev, D_PROBE, "Camera supports VGA mode\n"); if (gspca_dev->usb_buf[7] & 0x04) - PDEBUG(D_PROBE, "Camera supports QCIF mode"); + gspca_dbg(gspca_dev, D_PROBE, "Camera supports QCIF mode\n"); if (gspca_dev->usb_buf[7] & 0x08) - PDEBUG(D_PROBE, "Camera supports QVGA mode"); + gspca_dbg(gspca_dev, D_PROBE, "Camera supports QVGA mode\n"); if (gspca_dev->usb_buf[7] & 0x01) sd->video_mode = 0x00; /* CIF */ @@ -181,12 +181,12 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->video_mode = 0x03; /* QVGA */ /* FW rev, ASIC rev, sensor ID */ - PDEBUG(D_PROBE, "Firmware rev is %i.%i", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); - PDEBUG(D_PROBE, "ASIC rev is %i.%i", - gspca_dev->usb_buf[2], gspca_dev->usb_buf[3]); - PDEBUG(D_PROBE, "Sensor ID is %i", - (gspca_dev->usb_buf[4]*16) + (gspca_dev->usb_buf[5]>>4)); + gspca_dbg(gspca_dev, D_PROBE, "Firmware rev is %i.%i\n", + gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); + gspca_dbg(gspca_dev, D_PROBE, "ASIC rev is %i.%i", + gspca_dev->usb_buf[2], gspca_dev->usb_buf[3]); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ID is %i", + (gspca_dev->usb_buf[4]*16) + (gspca_dev->usb_buf[5]>>4)); ret = stv0680_get_video_mode(gspca_dev); diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c index 3db1c24b3d6d7..2715218fe4365 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c @@ -51,8 +51,8 @@ int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data) 0x04, 0x40, address, 0, buf, len, STV06XX_URB_MSG_TIMEOUT); - PDEBUG(D_CONF, "Written 0x%x to address 0x%x, status: %d", - i2c_data, address, err); + gspca_dbg(gspca_dev, D_CONF, "Written 0x%x to address 0x%x, status: %d\n", + i2c_data, address, err); return (err < 0) ? err : 0; } @@ -70,8 +70,8 @@ int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data) *i2c_data = buf[0]; - PDEBUG(D_CONF, "Reading 0x%x from address 0x%x, status %d", - *i2c_data, address, err); + gspca_dbg(gspca_dev, D_CONF, "Reading 0x%x from address 0x%x, status %d\n", + *i2c_data, address, err); return (err < 0) ? err : 0; } @@ -113,15 +113,16 @@ int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len) struct usb_device *udev = sd->gspca_dev.dev; __u8 *buf = sd->gspca_dev.usb_buf; - PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len); + gspca_dbg(gspca_dev, D_CONF, "I2C: Command buffer contains %d entries\n", + len); for (i = 0; i < len;) { /* Build the command buffer */ memset(buf, 0, I2C_BUFFER_LENGTH); for (j = 0; j < I2C_MAX_BYTES && i < len; j++, i++) { buf[j] = data[2*i]; buf[0x10 + j] = data[2*i+1]; - PDEBUG(D_CONF, "I2C: Writing 0x%02x to reg 0x%02x", - data[2*i+1], data[2*i]); + gspca_dbg(gspca_dev, D_CONF, "I2C: Writing 0x%02x to reg 0x%02x\n", + data[2*i+1], data[2*i]); } buf[0x20] = sd->sensor->i2c_addr; buf[0x21] = j - 1; /* Number of commands to send - 1 */ @@ -143,7 +144,8 @@ int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len) struct usb_device *udev = sd->gspca_dev.dev; __u8 *buf = sd->gspca_dev.usb_buf; - PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len); + gspca_dbg(gspca_dev, D_CONF, "I2C: Command buffer contains %d entries\n", + len); for (i = 0; i < len;) { /* Build the command buffer */ @@ -152,8 +154,8 @@ int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len) buf[j] = data[2*i]; buf[0x10 + j * 2] = data[2*i+1]; buf[0x10 + j * 2 + 1] = data[2*i+1] >> 8; - PDEBUG(D_CONF, "I2C: Writing 0x%04x to reg 0x%02x", - data[2*i+1], data[2*i]); + gspca_dbg(gspca_dev, D_CONF, "I2C: Writing 0x%04x to reg 0x%02x\n", + data[2*i+1], data[2*i]); } buf[0x20] = sd->sensor->i2c_addr; buf[0x21] = j - 1; /* Number of commands to send - 1 */ @@ -205,8 +207,8 @@ int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value) else *value = buf[0]; - PDEBUG(D_CONF, "I2C: Read 0x%x from address 0x%x, status: %d", - *value, address, err); + gspca_dbg(gspca_dev, D_CONF, "I2C: Read 0x%x from address 0x%x, status: %d\n", + *value, address, err); return (err < 0) ? err : 0; } @@ -249,7 +251,7 @@ static int stv06xx_init(struct gspca_dev *gspca_dev) struct sd *sd = (struct sd *) gspca_dev; int err; - PDEBUG(D_PROBE, "Initializing camera"); + gspca_dbg(gspca_dev, D_PROBE, "Initializing camera\n"); /* Let the usb init settle for a bit before performing the initialization */ @@ -268,7 +270,7 @@ static int stv06xx_init_controls(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_PROBE, "Initializing controls"); + gspca_dbg(gspca_dev, D_PROBE, "Initializing controls\n"); gspca_dev->vdev.ctrl_handler = &gspca_dev->ctrl_handler; return sd->sensor->init_controls(sd); @@ -304,9 +306,9 @@ static int stv06xx_start(struct gspca_dev *gspca_dev) out: if (err < 0) - PDEBUG(D_STREAM, "Starting stream failed"); + gspca_dbg(gspca_dev, D_STREAM, "Starting stream failed\n"); else - PDEBUG(D_STREAM, "Started streaming"); + gspca_dbg(gspca_dev, D_STREAM, "Started streaming\n"); return (err < 0) ? err : 0; } @@ -362,9 +364,9 @@ static void stv06xx_stopN(struct gspca_dev *gspca_dev) out: if (err < 0) - PDEBUG(D_STREAM, "Failed to stop stream"); + gspca_dbg(gspca_dev, D_STREAM, "Failed to stop stream\n"); else - PDEBUG(D_STREAM, "Stopped streaming"); + gspca_dbg(gspca_dev, D_STREAM, "Stopped streaming\n"); } /* @@ -385,7 +387,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, { struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_PACK, "Packet of length %d arrived", len); + gspca_dbg(gspca_dev, D_PACK, "Packet of length %d arrived\n", len); /* A packet may contain several frames loop until the whole packet is reached */ @@ -393,7 +395,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, int id, chunk_len; if (len < 4) { - PDEBUG(D_PACK, "Packet is smaller than 4 bytes"); + gspca_dbg(gspca_dev, D_PACK, "Packet is smaller than 4 bytes\n"); return; } @@ -402,7 +404,8 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, /* Capture the chunk length */ chunk_len = (data[2] << 8) | data[3]; - PDEBUG(D_PACK, "Chunk id: %x, length: %d", id, chunk_len); + gspca_dbg(gspca_dev, D_PACK, "Chunk id: %x, length: %d\n", + id, chunk_len); data += 4; len -= 4; @@ -421,7 +424,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, case 0x0200: case 0x4200: frame_data: - PDEBUG(D_PACK, "Frame data packet detected"); + gspca_dbg(gspca_dev, D_PACK, "Frame data packet detected\n"); if (sd->to_skip) { int skip = (sd->to_skip < chunk_len) ? @@ -440,7 +443,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, case 0x8005: case 0xc001: case 0xc005: - PDEBUG(D_PACK, "Starting new frame"); + gspca_dbg(gspca_dev, D_PACK, "Starting new frame\n"); /* Create a new frame, chunk length should be zero */ gspca_frame_add(gspca_dev, FIRST_PACKET, @@ -456,7 +459,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, case 0x8002: case 0x8006: case 0xc002: - PDEBUG(D_PACK, "End of frame detected"); + gspca_dbg(gspca_dev, D_PACK, "End of frame detected\n"); /* Complete the last frame (if any) */ gspca_frame_add(gspca_dev, LAST_PACKET, @@ -467,23 +470,24 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, break; case 0x0005: - PDEBUG(D_PACK, "Chunk 0x005 detected"); + gspca_dbg(gspca_dev, D_PACK, "Chunk 0x005 detected\n"); /* Unknown chunk with 11 bytes of data, occurs just before end of each frame in compressed mode */ break; case 0x0100: - PDEBUG(D_PACK, "Chunk 0x0100 detected"); + gspca_dbg(gspca_dev, D_PACK, "Chunk 0x0100 detected\n"); /* Unknown chunk with 2 bytes of data, occurs 2-3 times per USB interrupt */ break; case 0x42ff: - PDEBUG(D_PACK, "Chunk 0x42ff detected"); + gspca_dbg(gspca_dev, D_PACK, "Chunk 0x42ff detected\n"); /* Special chunk seen sometimes on the ST6422 */ break; default: - PDEBUG(D_PACK, "Unknown chunk 0x%04x detected", id); + gspca_dbg(gspca_dev, D_PACK, "Unknown chunk 0x%04x detected\n", + id); /* Unknown chunk */ } data += chunk_len; @@ -539,7 +543,7 @@ static int stv06xx_config(struct gspca_dev *gspca_dev, { struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_PROBE, "Configuring camera"); + gspca_dbg(gspca_dev, D_PROBE, "Configuring camera\n"); sd->bridge = id->driver_info; gspca_dev->sd_desc = &sd_desc; @@ -598,7 +602,7 @@ static void sd_disconnect(struct usb_interface *intf) struct gspca_dev *gspca_dev = usb_get_intfdata(intf); struct sd *sd = (struct sd *) gspca_dev; void *priv = sd->sensor_priv; - PDEBUG(D_PROBE, "Disconnecting the stv06xx device"); + gspca_dbg(gspca_dev, D_PROBE, "Disconnecting the stv06xx device\n"); sd->sensor = NULL; gspca_disconnect(intf); diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c index 28252f6c4afd8..d8db2c89718f8 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c @@ -251,8 +251,8 @@ static int hdcs_set_exposure(struct gspca_dev *gspca_dev, __s32 val) if (err < 0) return err; } - PDEBUG(D_CONF, "Writing exposure %d, rowexp %d, srowexp %d", - val, rowexp, srowexp); + gspca_dbg(gspca_dev, D_CONF, "Writing exposure %d, rowexp %d, srowexp %d\n", + val, rowexp, srowexp); return err; } @@ -276,7 +276,7 @@ static int hdcs_set_gains(struct sd *sd, u8 g) static int hdcs_set_gain(struct gspca_dev *gspca_dev, __s32 val) { - PDEBUG(D_CONF, "Writing gain %d", val); + gspca_dbg(gspca_dev, D_CONF, "Writing gain %d\n", val); return hdcs_set_gains((struct sd *) gspca_dev, val & 0xff); } @@ -465,7 +465,7 @@ static int hdcs_start(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_STREAM, "Starting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Starting stream\n"); return hdcs_set_state(sd, HDCS_STATE_RUN); } @@ -474,7 +474,7 @@ static int hdcs_stop(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_STREAM, "Halting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Halting stream\n"); return hdcs_set_state(sd, HDCS_STATE_SLEEP); } diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c index e1ce96e9405f5..7374aeb0a67a9 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c @@ -229,7 +229,7 @@ static int pb0100_start(struct sd *sd) } err = stv06xx_write_sensor(sd, PB_CONTROL, BIT(5)|BIT(3)|BIT(1)); - PDEBUG(D_STREAM, "Started stream, status: %d", err); + gspca_dbg(gspca_dev, D_STREAM, "Started stream, status: %d\n", err); return (err < 0) ? err : 0; } @@ -247,7 +247,7 @@ static int pb0100_stop(struct sd *sd) /* Set bit 1 to zero */ err = stv06xx_write_sensor(sd, PB_CONTROL, BIT(5)|BIT(3)); - PDEBUG(D_STREAM, "Halting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Halting stream\n"); out: return (err < 0) ? err : 0; } @@ -332,7 +332,8 @@ static int pb0100_set_gain(struct gspca_dev *gspca_dev, __s32 val) err = stv06xx_write_sensor(sd, PB_G1GAIN, val); if (!err) err = stv06xx_write_sensor(sd, PB_G2GAIN, val); - PDEBUG(D_CONF, "Set green gain to %d, status: %d", val, err); + gspca_dbg(gspca_dev, D_CONF, "Set green gain to %d, status: %d\n", + val, err); if (!err) err = pb0100_set_red_balance(gspca_dev, ctrls->red->val); @@ -355,7 +356,8 @@ static int pb0100_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) val = 255; err = stv06xx_write_sensor(sd, PB_RGAIN, val); - PDEBUG(D_CONF, "Set red gain to %d, status: %d", val, err); + gspca_dbg(gspca_dev, D_CONF, "Set red gain to %d, status: %d\n", + val, err); return err; } @@ -373,7 +375,8 @@ static int pb0100_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) val = 255; err = stv06xx_write_sensor(sd, PB_BGAIN, val); - PDEBUG(D_CONF, "Set blue gain to %d, status: %d", val, err); + gspca_dbg(gspca_dev, D_CONF, "Set blue gain to %d, status: %d\n", + val, err); return err; } @@ -384,7 +387,8 @@ static int pb0100_set_exposure(struct gspca_dev *gspca_dev, __s32 val) int err; err = stv06xx_write_sensor(sd, PB_RINTTIME, val); - PDEBUG(D_CONF, "Set exposure to %d, status: %d", val, err); + gspca_dbg(gspca_dev, D_CONF, "Set exposure to %d, status: %d\n", + val, err); return err; } @@ -404,8 +408,8 @@ static int pb0100_set_autogain(struct gspca_dev *gspca_dev, __s32 val) val = 0; err = stv06xx_write_sensor(sd, PB_EXPGAIN, val); - PDEBUG(D_CONF, "Set autogain to %d (natural: %d), status: %d", - val, ctrls->natural->val, err); + gspca_dbg(gspca_dev, D_CONF, "Set autogain to %d (natural: %d), status: %d\n", + val, ctrls->natural->val, err); return err; } @@ -426,7 +430,8 @@ static int pb0100_set_autogain_target(struct gspca_dev *gspca_dev, __s32 val) if (!err) err = stv06xx_write_sensor(sd, PB_R22, darkpixels); - PDEBUG(D_CONF, "Set autogain target to %d, status: %d", val, err); + gspca_dbg(gspca_dev, D_CONF, "Set autogain target to %d, status: %d\n", + val, err); return err; } diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c index 4b76070515b5e..51a135c2f9f73 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c @@ -277,7 +277,7 @@ static int st6422_stop(struct sd *sd) { struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; - PDEBUG(D_STREAM, "Halting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Halting stream\n"); return 0; } diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c index d265e6b009947..b2f16c2754fb9 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c @@ -129,7 +129,7 @@ static int vv6410_start(struct sd *sd) u32 priv = cam->cam_mode[sd->gspca_dev.curr_mode].priv; if (priv & VV6410_SUBSAMPLE) { - PDEBUG(D_CONF, "Enabling subsampling"); + gspca_dbg(gspca_dev, D_CONF, "Enabling subsampling\n"); stv06xx_write_bridge(sd, STV_Y_CTRL, 0x02); stv06xx_write_bridge(sd, STV_X_CTRL, 0x06); @@ -150,7 +150,7 @@ static int vv6410_start(struct sd *sd) if (err < 0) return err; - PDEBUG(D_STREAM, "Starting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Starting stream\n"); return 0; } @@ -169,7 +169,7 @@ static int vv6410_stop(struct sd *sd) if (err < 0) return err; - PDEBUG(D_STREAM, "Halting stream"); + gspca_dbg(gspca_dev, D_STREAM, "Halting stream\n"); return 0; } @@ -203,7 +203,7 @@ static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val) else i2c_data &= ~VV6410_HFLIP; - PDEBUG(D_CONF, "Set horizontal flip to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set horizontal flip to %d\n", val); err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data); return (err < 0) ? err : 0; @@ -224,7 +224,7 @@ static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val) else i2c_data &= ~VV6410_VFLIP; - PDEBUG(D_CONF, "Set vertical flip to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set vertical flip to %d\n", val); err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data); return (err < 0) ? err : 0; @@ -235,7 +235,7 @@ static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val) int err; struct sd *sd = (struct sd *) gspca_dev; - PDEBUG(D_CONF, "Set analog gain to %d", val); + gspca_dbg(gspca_dev, D_CONF, "Set analog gain to %d\n", val); err = stv06xx_write_sensor(sd, VV6410_ANALOGGAIN, 0xf0 | (val & 0xf)); return (err < 0) ? err : 0; @@ -252,8 +252,8 @@ static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val) fine = val % VV6410_CIF_LINELENGTH; coarse = min(512, val / VV6410_CIF_LINELENGTH); - PDEBUG(D_CONF, "Set coarse exposure to %d, fine exposure to %d", - coarse, fine); + gspca_dbg(gspca_dev, D_CONF, "Set coarse exposure to %d, fine exposure to %d\n", + coarse, fine); err = stv06xx_write_sensor(sd, VV6410_FINEH, fine >> 8); if (err < 0) diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c index 44b07344f0f72..437a3367ab974 100644 --- a/drivers/media/usb/gspca/sunplus.c +++ b/drivers/media/usb/gspca/sunplus.c @@ -311,8 +311,8 @@ static void reg_w_riv(struct gspca_dev *gspca_dev, gspca_dev->usb_err = ret; return; } - PDEBUG(D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x", - req, index, value); + gspca_dbg(gspca_dev, D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x\n", + req, index, value); } static void write_vector(struct gspca_dev *gspca_dev, @@ -343,12 +343,14 @@ static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, { reg_w_riv(gspca_dev, req, idx, val); reg_r(gspca_dev, 0x01, 0x0001, 1); - PDEBUG(D_FRAM, "before wait 0x%04x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_FRAM, "before wait 0x%04x\n", + gspca_dev->usb_buf[0]); reg_w_riv(gspca_dev, req, idx, val); msleep(200); reg_r(gspca_dev, 0x01, 0x0001, 1); - PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_FRAM, "after wait 0x%04x\n", + gspca_dev->usb_buf[0]); } static void spca504_read_info(struct gspca_dev *gspca_dev) @@ -363,10 +365,10 @@ static void spca504_read_info(struct gspca_dev *gspca_dev) reg_r(gspca_dev, 0, i, 1); info[i] = gspca_dev->usb_buf[0]; } - PDEBUG(D_STREAM, - "Read info: %d %d %d %d %d %d. Should be 1,0,2,2,0,0", - info[0], info[1], info[2], - info[3], info[4], info[5]); + gspca_dbg(gspca_dev, D_STREAM, + "Read info: %d %d %d %d %d %d. Should be 1,0,2,2,0,0\n", + info[0], info[1], info[2], + info[3], info[4], info[5]); } static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, @@ -379,8 +381,8 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, reg_r(gspca_dev, 0x01, 0x0001, 1); if (gspca_dev->usb_err < 0) return; - PDEBUG(D_FRAM, "Status 0x%02x Need 0x%02x", - gspca_dev->usb_buf[0], endcode); + gspca_dbg(gspca_dev, D_FRAM, "Status 0x%02x Need 0x%02x\n", + gspca_dev->usb_buf[0], endcode); if (!count) return; count = 200; @@ -391,8 +393,8 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, reg_r(gspca_dev, 0x01, 0x0001, 1); status = gspca_dev->usb_buf[0]; if (status == endcode) { - PDEBUG(D_FRAM, "status 0x%04x after wait %d", - status, 200 - count); + gspca_dbg(gspca_dev, D_FRAM, "status 0x%04x after wait %d\n", + status, 200 - count); break; } } @@ -435,8 +437,8 @@ static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) data = gspca_dev->usb_buf; reg_r(gspca_dev, 0x20, 0, 5); - PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d", - data[0], data[1], data[2], data[3], data[4]); + gspca_dbg(gspca_dev, D_STREAM, "FirmWare: %d %d %d %d %d\n", + data[0], data[1], data[2], data[3], data[4]); reg_r(gspca_dev, 0x23, 0, 64); reg_r(gspca_dev, 0x23, 1, 64); } @@ -651,7 +653,7 @@ static int sd_init(struct gspca_dev *gspca_dev) spca504B_WaitCmdStatus(gspca_dev); break; case BRIDGE_SPCA504C: /* pccam600 */ - PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)"); + gspca_dbg(gspca_dev, D_STREAM, "Opening SPCA504 (PC-CAM 600)\n"); reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000); reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */ spca504_wait_status(gspca_dev); @@ -666,7 +668,7 @@ static int sd_init(struct gspca_dev *gspca_dev) break; default: /* case BRIDGE_SPCA504: */ - PDEBUG(D_STREAM, "Opening SPCA504"); + gspca_dbg(gspca_dev, D_STREAM, "Opening SPCA504\n"); if (sd->subtype == AiptekMiniPenCam13) { spca504_read_info(gspca_dev); diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c index 46fb76349000a..0ae557cd15efb 100644 --- a/drivers/media/usb/gspca/t613.c +++ b/drivers/media/usb/gspca/t613.c @@ -490,7 +490,7 @@ static void setcolors(struct gspca_dev *gspca_dev, s32 val) static void setgamma(struct gspca_dev *gspca_dev, s32 val) { - PDEBUG(D_CONF, "Gamma: %d", val); + gspca_dbg(gspca_dev, D_CONF, "Gamma: %d\n", val); reg_w_ixbuf(gspca_dev, 0x90, gamma_table[val], sizeof gamma_table[0]); } @@ -592,19 +592,19 @@ static int sd_init(struct gspca_dev *gspca_dev) | reg_r(gspca_dev, 0x07); switch (sensor_id & 0xff0f) { case 0x0801: - PDEBUG(D_PROBE, "sensor tas5130a"); + gspca_dbg(gspca_dev, D_PROBE, "sensor tas5130a\n"); sd->sensor = SENSOR_TAS5130A; break; case 0x0802: - PDEBUG(D_PROBE, "sensor lt168g"); + gspca_dbg(gspca_dev, D_PROBE, "sensor lt168g\n"); sd->sensor = SENSOR_LT168G; break; case 0x0803: - PDEBUG(D_PROBE, "sensor 'other'"); + gspca_dbg(gspca_dev, D_PROBE, "sensor 'other'\n"); sd->sensor = SENSOR_OTHER; break; case 0x0807: - PDEBUG(D_PROBE, "sensor om6802"); + gspca_dbg(gspca_dev, D_PROBE, "sensor om6802\n"); sd->sensor = SENSOR_OM6802; break; default: @@ -632,8 +632,8 @@ static int sd_init(struct gspca_dev *gspca_dev) i = 0; while (read_indexs[i] != 0x00) { test_byte = reg_r(gspca_dev, read_indexs[i]); - PDEBUG(D_STREAM, "Reg 0x%02x = 0x%02x", read_indexs[i], - test_byte); + gspca_dbg(gspca_dev, D_STREAM, "Reg 0x%02x = 0x%02x\n", + read_indexs[i], test_byte); i++; } @@ -643,8 +643,8 @@ static int sd_init(struct gspca_dev *gspca_dev) if (sd->sensor == SENSOR_LT168G) { test_byte = reg_r(gspca_dev, 0x80); - PDEBUG(D_STREAM, "Reg 0x%02x = 0x%02x", 0x80, - test_byte); + gspca_dbg(gspca_dev, D_STREAM, "Reg 0x%02x = 0x%02x\n", 0x80, + test_byte); reg_w(gspca_dev, 0x6c80); } @@ -665,8 +665,8 @@ static int sd_init(struct gspca_dev *gspca_dev) if (sd->sensor == SENSOR_LT168G) { test_byte = reg_r(gspca_dev, 0x80); - PDEBUG(D_STREAM, "Reg 0x%02x = 0x%02x", 0x80, - test_byte); + gspca_dbg(gspca_dev, D_STREAM, "Reg 0x%02x = 0x%02x\n", 0x80, + test_byte); reg_w(gspca_dev, 0x6c80); } @@ -737,7 +737,7 @@ static void poll_sensor(struct gspca_dev *gspca_dev) 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c, 0xc2, 0x80, 0xc3, 0x10}; - PDEBUG(D_STREAM, "[Sensor requires polling]"); + gspca_dbg(gspca_dev, D_STREAM, "[Sensor requires polling]\n"); reg_w_buf(gspca_dev, poll1, sizeof poll1); reg_w_buf(gspca_dev, poll2, sizeof poll2); reg_w_buf(gspca_dev, noise03, sizeof noise03); diff --git a/drivers/media/usb/gspca/topro.c b/drivers/media/usb/gspca/topro.c index 983fc6b500af0..82e2be14cad8b 100644 --- a/drivers/media/usb/gspca/topro.c +++ b/drivers/media/usb/gspca/topro.c @@ -1453,7 +1453,7 @@ static void set_dqt(struct gspca_dev *gspca_dev, u8 q) struct sd *sd = (struct sd *) gspca_dev; /* update the jpeg quantization tables */ - PDEBUG(D_STREAM, "q %d -> %d", sd->quality, q); + gspca_dbg(gspca_dev, D_STREAM, "q %d -> %d\n", sd->quality, q); sd->quality = q; if (q > 16) q = 16; @@ -4053,7 +4053,7 @@ static int sd_init(struct gspca_dev *gspca_dev) ARRAY_SIZE(tp6810_preinit)); msleep(15); reg_r(gspca_dev, TP6800_R18_GPIO_DATA); - PDEBUG(D_PROBE, "gpio: %02x", gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_PROBE, "gpio: %02x\n", gspca_dev->usb_buf[0]); /* values: * 0x80: snapshot button * 0x40: LED @@ -4627,7 +4627,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, if (*data == 0xaa || *data == 0x00) return; if (*data > 0xc0) { - PDEBUG(D_FRAM, "bad frame"); + gspca_dbg(gspca_dev, D_FRAM, "bad frame\n"); gspca_dev->last_packet_type = DISCARD_PACKET; return; } diff --git a/drivers/media/usb/gspca/touptek.c b/drivers/media/usb/gspca/touptek.c index a1bb1704d3394..d1b9032d7863f 100644 --- a/drivers/media/usb/gspca/touptek.c +++ b/drivers/media/usb/gspca/touptek.c @@ -214,12 +214,12 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) char *buff = gspca_dev->usb_buf; int rc; - PDEBUG(D_USBO, - "reg_w bReq=0x0B, bReqT=0xC0, wVal=0x%04X, wInd=0x%04X\n", - value, index); + gspca_dbg(gspca_dev, D_USBO, + "reg_w bReq=0x0B, bReqT=0xC0, wVal=0x%04X, wInd=0x%04X\n\n", + value, index); rc = usb_control_msg(gspca_dev->dev, usb_rcvctrlpipe(gspca_dev->dev, 0), 0x0B, 0xC0, value, index, buff, 1, 500); - PDEBUG(D_USBO, "rc=%d, ret={0x%02x}", rc, (int)buff[0]); + gspca_dbg(gspca_dev, D_USBO, "rc=%d, ret={0x%02x}\n", rc, (int)buff[0]); if (rc < 0) { gspca_err(gspca_dev, "Failed reg_w(0x0B, 0xC0, 0x%04X, 0x%04X) w/ rc %d\n", value, index, rc); @@ -258,7 +258,7 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 val) gspca_dev->usb_err = -EINVAL; return; } - PDEBUG(D_STREAM, "exposure: 0x%04X ms\n", value); + gspca_dbg(gspca_dev, D_STREAM, "exposure: 0x%04X ms\n\n", value); /* Wonder if theres a good reason for sending it twice */ /* probably not but leave it in because...why not */ reg_w(gspca_dev, value, REG_COARSE_INTEGRATION_TIME_); @@ -286,9 +286,9 @@ static void setggain(struct gspca_dev *gspca_dev, u16 global_gain) u16 normalized; normalized = gainify(global_gain); - PDEBUG(D_STREAM, "gain G1/G2 (0x%04X): 0x%04X (src 0x%04X)\n", - REG_GREEN1_GAIN, - normalized, global_gain); + gspca_dbg(gspca_dev, D_STREAM, "gain G1/G2 (0x%04X): 0x%04X (src 0x%04X)\n\n", + REG_GREEN1_GAIN, + normalized, global_gain); reg_w(gspca_dev, normalized, REG_GREEN1_GAIN); reg_w(gspca_dev, normalized, REG_GREEN2_GAIN); @@ -302,13 +302,13 @@ static void setbgain(struct gspca_dev *gspca_dev, normalized = global_gain + ((u32)global_gain) * gain / GAIN_MAX; if (normalized > GAIN_MAX) { - PDEBUG(D_STREAM, "Truncating blue 0x%04X w/ value 0x%04X\n", - GAIN_MAX, normalized); + gspca_dbg(gspca_dev, D_STREAM, "Truncating blue 0x%04X w/ value 0x%04X\n\n", + GAIN_MAX, normalized); normalized = GAIN_MAX; } normalized = gainify(normalized); - PDEBUG(D_STREAM, "gain B (0x%04X): 0x%04X w/ source 0x%04X\n", - REG_BLUE_GAIN, normalized, gain); + gspca_dbg(gspca_dev, D_STREAM, "gain B (0x%04X): 0x%04X w/ source 0x%04X\n\n", + REG_BLUE_GAIN, normalized, gain); reg_w(gspca_dev, normalized, REG_BLUE_GAIN); } @@ -321,13 +321,13 @@ static void setrgain(struct gspca_dev *gspca_dev, normalized = global_gain + ((u32)global_gain) * gain / GAIN_MAX; if (normalized > GAIN_MAX) { - PDEBUG(D_STREAM, "Truncating gain 0x%04X w/ value 0x%04X\n", - GAIN_MAX, normalized); + gspca_dbg(gspca_dev, D_STREAM, "Truncating gain 0x%04X w/ value 0x%04X\n\n", + GAIN_MAX, normalized); normalized = GAIN_MAX; } normalized = gainify(normalized); - PDEBUG(D_STREAM, "gain R (0x%04X): 0x%04X w / source 0x%04X\n", - REG_RED_GAIN, normalized, gain); + gspca_dbg(gspca_dev, D_STREAM, "gain R (0x%04X): 0x%04X w / source 0x%04X\n\n", + REG_RED_GAIN, normalized, gain); reg_w(gspca_dev, normalized, REG_RED_GAIN); } @@ -336,7 +336,7 @@ static void configure_wh(struct gspca_dev *gspca_dev) { unsigned int w = gspca_dev->pixfmt.width; - PDEBUG(D_STREAM, "configure_wh\n"); + gspca_dbg(gspca_dev, D_STREAM, "configure_wh\n\n"); if (w == 800) { static const struct cmd reg_init_res[] = { @@ -425,14 +425,15 @@ static void configure_encrypted(struct gspca_dev *gspca_dev) {0x0100, REG_MODE_SELECT}, }; - PDEBUG(D_STREAM, "Encrypted begin, w = %u\n", gspca_dev->pixfmt.width); + gspca_dbg(gspca_dev, D_STREAM, "Encrypted begin, w = %u\n\n", + gspca_dev->pixfmt.width); reg_w_buf(gspca_dev, reg_init_begin, ARRAY_SIZE(reg_init_begin)); configure_wh(gspca_dev); reg_w_buf(gspca_dev, reg_init_end, ARRAY_SIZE(reg_init_end)); reg_w(gspca_dev, 0x0100, REG_GROUPED_PARAMETER_HOLD); reg_w(gspca_dev, 0x0000, REG_GROUPED_PARAMETER_HOLD); - PDEBUG(D_STREAM, "Encrypted end\n"); + gspca_dbg(gspca_dev, D_STREAM, "Encrypted end\n\n"); } static int configure(struct gspca_dev *gspca_dev) @@ -440,7 +441,7 @@ static int configure(struct gspca_dev *gspca_dev) int rc; char *buff = gspca_dev->usb_buf; - PDEBUG(D_STREAM, "configure()\n"); + gspca_dbg(gspca_dev, D_STREAM, "configure()\n\n"); /* * First driver sets a sort of encryption key @@ -519,7 +520,7 @@ static int configure(struct gspca_dev *gspca_dev) return rc; } - PDEBUG(D_STREAM, "Configure complete\n"); + gspca_dbg(gspca_dev, D_STREAM, "Configure complete\n\n"); return 0; } @@ -567,13 +568,13 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, /* can we finish a frame? */ if (sd->this_f + len == gspca_dev->pixfmt.sizeimage) { gspca_frame_add(gspca_dev, LAST_PACKET, data, len); - PDEBUG(D_FRAM, "finish frame sz %u/%u w/ len %u\n", - sd->this_f, gspca_dev->pixfmt.sizeimage, len); + gspca_dbg(gspca_dev, D_FRAM, "finish frame sz %u/%u w/ len %u\n\n", + sd->this_f, gspca_dev->pixfmt.sizeimage, len); /* lost some data, discard the frame */ } else { gspca_frame_add(gspca_dev, DISCARD_PACKET, NULL, 0); - PDEBUG(D_FRAM, "abort frame sz %u/%u w/ len %u\n", - sd->this_f, gspca_dev->pixfmt.sizeimage, len); + gspca_dbg(gspca_dev, D_FRAM, "abort frame sz %u/%u w/ len %u\n\n", + sd->this_f, gspca_dev->pixfmt.sizeimage, len); } sd->this_f = 0; } else { diff --git a/drivers/media/usb/gspca/vc032x.c b/drivers/media/usb/gspca/vc032x.c index b935febf71468..6b11597977c9d 100644 --- a/drivers/media/usb/gspca/vc032x.c +++ b/drivers/media/usb/gspca/vc032x.c @@ -2926,11 +2926,12 @@ static void reg_r(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; if (len == 1) - PDEBUG(D_USBI, "GET %02x 0001 %04x %02x", req, index, - gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_USBI, "GET %02x 0001 %04x %02x\n", + req, index, + gspca_dev->usb_buf[0]); else - PDEBUG(D_USBI, "GET %02x 0001 %04x %*ph", - req, index, 3, gspca_dev->usb_buf); + gspca_dbg(gspca_dev, D_USBI, "GET %02x 0001 %04x %*ph\n", + req, index, 3, gspca_dev->usb_buf); } static void reg_w_i(struct gspca_dev *gspca_dev, @@ -2960,7 +2961,7 @@ static void reg_w(struct gspca_dev *gspca_dev, { if (gspca_dev->usb_err < 0) return; - PDEBUG(D_USBO, "SET %02x %04x %04x", req, value, index); + gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n", req, value, index); reg_w_i(gspca_dev, req, value, index); } @@ -2992,8 +2993,8 @@ static u16 read_sensor_register(struct gspca_dev *gspca_dev, reg_r(gspca_dev, 0xa1, 0xb33c, 1); hdata = gspca_dev->usb_buf[0]; if (hdata != 0 && mdata != 0 && ldata != 0) - PDEBUG(D_PROBE, "Read Sensor %02x%02x %02x", - hdata, mdata, ldata); + gspca_dbg(gspca_dev, D_PROBE, "Read Sensor %02x%02x %02x\n", + hdata, mdata, ldata); reg_r(gspca_dev, 0xa1, 0xb334, 1); if (gspca_dev->usb_buf[0] == 0x02) return (hdata << 8) + mdata; @@ -3015,8 +3016,8 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev) } reg_r(gspca_dev, 0xa1, 0xbfcf, 1); - PDEBUG(D_PROBE, "vc032%d check sensor header %02x", - sd->bridge == BRIDGE_VC0321 ? 1 : 3, gspca_dev->usb_buf[0]); + gspca_dbg(gspca_dev, D_PROBE, "vc032%d check sensor header %02x\n", + sd->bridge == BRIDGE_VC0321 ? 1 : 3, gspca_dev->usb_buf[0]); if (sd->bridge == BRIDGE_VC0321) { ptsensor_info = vc0321_probe_data; n = ARRAY_SIZE(vc0321_probe_data); @@ -3036,7 +3037,8 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev) if (value == 0 && ptsensor_info->IdAdd == 0x82) value = read_sensor_register(gspca_dev, 0x83); if (value != 0) { - PDEBUG(D_PROBE, "Sensor ID %04x (%d)", value, i); + gspca_dbg(gspca_dev, D_PROBE, "Sensor ID %04x (%d)\n", + value, i); if (value == ptsensor_info->VpId) return ptsensor_info->sensorId; @@ -3063,9 +3065,10 @@ static void i2c_write(struct gspca_dev *gspca_dev, if (gspca_dev->usb_err < 0) return; if (size == 1) - PDEBUG(D_USBO, "i2c_w %02x %02x", reg, *val); + gspca_dbg(gspca_dev, D_USBO, "i2c_w %02x %02x\n", reg, *val); else - PDEBUG(D_USBO, "i2c_w %02x %02x%02x", reg, *val, val[1]); + gspca_dbg(gspca_dev, D_USBO, "i2c_w %02x %02x%02x\n", + reg, *val, val[1]); reg_r_i(gspca_dev, 0xa1, 0xb33f, 1); /*fixme:should check if (!(gspca_dev->usb_buf[0] & 0x02)) error*/ reg_w_i(gspca_dev, 0xa0, size, 0xb334); @@ -3170,35 +3173,35 @@ static int sd_init(struct gspca_dev *gspca_dev) pr_err("Unknown sensor...\n"); return -EINVAL; case SENSOR_HV7131R: - PDEBUG(D_PROBE, "Find Sensor HV7131R"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); break; case SENSOR_MI0360: - PDEBUG(D_PROBE, "Find Sensor MI0360"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI0360\n"); sd->bridge = BRIDGE_VC0323; break; case SENSOR_MI1310_SOC: - PDEBUG(D_PROBE, "Find Sensor MI1310_SOC"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1310_SOC\n"); break; case SENSOR_MI1320: - PDEBUG(D_PROBE, "Find Sensor MI1320"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1320\n"); break; case SENSOR_MI1320_SOC: - PDEBUG(D_PROBE, "Find Sensor MI1320_SOC"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1320_SOC\n"); break; case SENSOR_OV7660: - PDEBUG(D_PROBE, "Find Sensor OV7660"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7660\n"); break; case SENSOR_OV7670: - PDEBUG(D_PROBE, "Find Sensor OV7670"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7670\n"); break; case SENSOR_PO1200: - PDEBUG(D_PROBE, "Find Sensor PO1200"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO1200\n"); break; case SENSOR_PO3130NC: - PDEBUG(D_PROBE, "Find Sensor PO3130NC"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO3130NC\n"); break; case SENSOR_POxxxx: - PDEBUG(D_PROBE, "Sensor POxxxx"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor POxxxx\n"); break; } sd->sensor = sensor; @@ -3624,8 +3627,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct sd *sd = (struct sd *) gspca_dev; if (data[0] == 0xff && data[1] == 0xd8) { - PDEBUG(D_PACK, - "vc032x header packet found len %d", len); + gspca_dbg(gspca_dev, D_PACK, + "vc032x header packet found len %d\n", len); gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); data += sd->image_offset; len -= sd->image_offset; diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c index d149cb7f00190..abfab3de18662 100644 --- a/drivers/media/usb/gspca/w996Xcf.c +++ b/drivers/media/usb/gspca/w996Xcf.c @@ -245,7 +245,7 @@ static void w9968cf_smbus_read_ack(struct sd *sd) sda = w9968cf_read_sb(sd); w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ if (sda >= 0 && (sda & 0x08)) { - PDEBUG(D_USBI, "Did not receive i2c ACK"); + gspca_dbg(gspca_dev, D_USBI, "Did not receive i2c ACK\n"); sd->gspca_dev.usb_err = -EIO; } } @@ -297,7 +297,7 @@ static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) w9968cf_write_fsb(sd, data); - PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); + gspca_dbg(gspca_dev, D_USBO, "i2c 0x%02x -> [0x%02x]\n", value, reg); } /* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ @@ -331,7 +331,8 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) if (sd->gspca_dev.usb_err >= 0) { ret = value; - PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); + gspca_dbg(gspca_dev, D_USBI, "i2c [0x%02X] -> 0x%02X\n", + reg, value); } else gspca_err(gspca_dev, "i2c read [0x%02x] failed\n", reg); diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c index 68656e7986c75..58deb0c388267 100644 --- a/drivers/media/usb/gspca/xirlink_cit.c +++ b/drivers/media/usb/gspca/xirlink_cit.c @@ -704,7 +704,8 @@ static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index, int verbose) } if (verbose) - PDEBUG(D_PROBE, "Register %04x value: %02x", index, buf[0]); + gspca_dbg(gspca_dev, D_PROBE, "Register %04x value: %02x\n", + index, buf[0]); return 0; } @@ -1471,10 +1472,11 @@ static int cit_get_clock_div(struct gspca_dev *gspca_dev) fps[clock_div - 1] * 3 / 2) clock_div--; - PDEBUG(D_PROBE, - "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)", - packet_size, gspca_dev->pixfmt.width, gspca_dev->pixfmt.height, - clock_div, fps[clock_div]); + gspca_dbg(gspca_dev, D_PROBE, + "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)\n", + packet_size, + gspca_dev->pixfmt.width, gspca_dev->pixfmt.height, + clock_div, fps[clock_div]); return clock_div; } @@ -2865,17 +2867,17 @@ static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) sd->sof_read = 0; if (data[i] == 0xff) { if (i >= 4) - PDEBUG(D_FRAM, - "header found at offset: %d: %02x %02x 00 %3ph\n", - i - 1, - data[i - 4], - data[i - 3], - &data[i]); + gspca_dbg(gspca_dev, D_FRAM, + "header found at offset: %d: %02x %02x 00 %3ph\n\n", + i - 1, + data[i - 4], + data[i - 3], + &data[i]); else - PDEBUG(D_FRAM, - "header found at offset: %d: 00 %3ph\n", - i - 1, - &data[i]); + gspca_dbg(gspca_dev, D_FRAM, + "header found at offset: %d: 00 %3ph\n\n", + i - 1, + &data[i]); return data + i + (sd->sof_len - 1); } break; diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c index e2d486bd8c280..25b4dbe8e049a 100644 --- a/drivers/media/usb/gspca/zc3xx.c +++ b/drivers/media/usb/gspca/zc3xx.c @@ -6041,7 +6041,7 @@ static int sif_probe(struct gspca_dev *gspca_dev) msleep(150); checkword = ((i2c_read(gspca_dev, 0x00) & 0x0f) << 4) | ((i2c_read(gspca_dev, 0x01) & 0xf0) >> 4); - PDEBUG(D_PROBE, "probe sif 0x%04x", checkword); + gspca_dbg(gspca_dev, D_PROBE, "probe sif 0x%04x\n", checkword); if (checkword == 0x0007) { send_unknown(gspca_dev, SENSOR_PAS106); return 0x0f; /* PAS106 */ @@ -6129,7 +6129,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev) i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ retword = i2c_read(gspca_dev, 0x0a) << 8; retword |= i2c_read(gspca_dev, 0x0b); - PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 2wr ov vga 0x%04x\n", retword); switch (retword) { case 0x7631: /* OV7630C */ reg_w(gspca_dev, 0x06, 0x0010); @@ -6186,7 +6186,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x02, 0x0010); retword = reg_r(gspca_dev, 0x000b) << 8; retword |= reg_r(gspca_dev, 0x000a); - PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga 1 0x%04x\n", retword); reg_r(gspca_dev, 0x0010); if ((retword & 0xff00) == 0x6400) return 0x02; /* TAS5130C */ @@ -6206,7 +6206,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x01, 0x0012); retword = i2c_read(gspca_dev, 0x00); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type 0a"); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type 0a\n"); return 0x0a; /* PB0330 */ } @@ -6220,7 +6220,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x01, 0x0012); retword = i2c_read(gspca_dev, 0x00); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type %02x\n", + retword); if (retword == 0x0011) /* gc0303 */ return 0x0303; if (retword == 0x0029) /* gc0305 */ @@ -6251,12 +6252,13 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x05, 0x0012); retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */ retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ - PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga 2 0x%04x\n", retword); if (retword == 0x2030) { u8 retbyte; retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ - PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); + gspca_dbg(gspca_dev, D_PROBE, "sensor PO2030 rev 0x%02x\n", + retbyte); send_unknown(gspca_dev, SENSOR_PO2030); return retword; @@ -6272,7 +6274,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0xd3, 0x008b); retword = i2c_read(gspca_dev, 0x01); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type 0a ? ret: %04x\n", + retword); return 0x16; /* adcm2700 (6100/6200) */ } return -1; @@ -6490,19 +6493,20 @@ static int sd_init(struct gspca_dev *gspca_dev) sensor = zcxx_probeSensor(gspca_dev); if (sensor >= 0) - PDEBUG(D_PROBE, "probe sensor -> %04x", sensor); + gspca_dbg(gspca_dev, D_PROBE, "probe sensor -> %04x\n", sensor); if ((unsigned) force_sensor < SENSOR_MAX) { sd->sensor = force_sensor; - PDEBUG(D_PROBE, "sensor forced to %d", force_sensor); + gspca_dbg(gspca_dev, D_PROBE, "sensor forced to %d\n", + force_sensor); } else { switch (sensor) { case -1: switch (sd->sensor) { case SENSOR_MC501CB: - PDEBUG(D_PROBE, "Sensor MC501CB"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor MC501CB\n"); break; case SENSOR_GC0303: - PDEBUG(D_PROBE, "Sensor GC0303"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor GC0303\n"); break; default: pr_warn("Unknown sensor - set to TAS5130C\n"); @@ -6512,100 +6516,101 @@ static int sd_init(struct gspca_dev *gspca_dev) case 0: /* check the sensor type */ sensor = i2c_read(gspca_dev, 0x00); - PDEBUG(D_PROBE, "Sensor hv7131 type %d", sensor); + gspca_dbg(gspca_dev, D_PROBE, "Sensor hv7131 type %d\n", + sensor); switch (sensor) { case 0: /* hv7131b */ case 1: /* hv7131e */ - PDEBUG(D_PROBE, "Find Sensor HV7131B"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131B\n"); sd->sensor = SENSOR_HV7131B; break; default: /* case 2: * hv7131r */ - PDEBUG(D_PROBE, "Find Sensor HV7131R"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); sd->sensor = SENSOR_HV7131R; break; } break; case 0x02: - PDEBUG(D_PROBE, "Sensor TAS5130C"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor TAS5130C\n"); sd->sensor = SENSOR_TAS5130C; break; case 0x04: - PDEBUG(D_PROBE, "Find Sensor CS2102"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor CS2102\n"); sd->sensor = SENSOR_CS2102; break; case 0x08: - PDEBUG(D_PROBE, "Find Sensor HDCS2020"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HDCS2020\n"); sd->sensor = SENSOR_HDCS2020; break; case 0x0a: - PDEBUG(D_PROBE, - "Find Sensor PB0330. Chip revision %x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Find Sensor PB0330. Chip revision %x\n", + sd->chip_revision); sd->sensor = SENSOR_PB0330; break; case 0x0c: - PDEBUG(D_PROBE, "Find Sensor ICM105A"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor ICM105A\n"); sd->sensor = SENSOR_ICM105A; break; case 0x0e: - PDEBUG(D_PROBE, "Find Sensor PAS202B"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PAS202B\n"); sd->sensor = SENSOR_PAS202B; break; case 0x0f: - PDEBUG(D_PROBE, "Find Sensor PAS106"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PAS106\n"); sd->sensor = SENSOR_PAS106; break; case 0x10: case 0x12: - PDEBUG(D_PROBE, "Find Sensor TAS5130C"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor TAS5130C\n"); sd->sensor = SENSOR_TAS5130C; break; case 0x11: - PDEBUG(D_PROBE, "Find Sensor HV7131R"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); sd->sensor = SENSOR_HV7131R; break; case 0x13: case 0x15: - PDEBUG(D_PROBE, - "Sensor MT9V111. Chip revision %04x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Sensor MT9V111. Chip revision %04x\n", + sd->chip_revision); sd->sensor = sd->bridge == BRIDGE_ZC301 ? SENSOR_MT9V111_1 : SENSOR_MT9V111_3; break; case 0x14: - PDEBUG(D_PROBE, - "Find Sensor CS2102K?. Chip revision %x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Find Sensor CS2102K?. Chip revision %x\n", + sd->chip_revision); sd->sensor = SENSOR_CS2102K; break; case 0x16: - PDEBUG(D_PROBE, "Find Sensor ADCM2700"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor ADCM2700\n"); sd->sensor = SENSOR_ADCM2700; break; case 0x29: - PDEBUG(D_PROBE, "Find Sensor GC0305"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor GC0305\n"); sd->sensor = SENSOR_GC0305; break; case 0x0303: - PDEBUG(D_PROBE, "Sensor GC0303"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor GC0303\n"); sd->sensor = SENSOR_GC0303; break; case 0x2030: - PDEBUG(D_PROBE, "Find Sensor PO2030"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO2030\n"); sd->sensor = SENSOR_PO2030; break; case 0x7620: - PDEBUG(D_PROBE, "Find Sensor OV7620"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7620\n"); sd->sensor = SENSOR_OV7620; break; case 0x7631: - PDEBUG(D_PROBE, "Find Sensor OV7630C"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7630C\n"); sd->sensor = SENSOR_OV7630C; break; case 0x7648: - PDEBUG(D_PROBE, "Find Sensor OV7648"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7648\n"); sd->sensor = SENSOR_OV7620; /* same sensor (?) */ break; default: -- GitLab From e40d14a89760632238f67c1f96c852652a137f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= Date: Sun, 1 Oct 2017 15:30:41 -0400 Subject: [PATCH 0033/1190] media: use ARRAY_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the ARRAY_SIZE macro improves the readability of the code. Also, it is not always useful to use a variable to store this constant calculated at compile time. Found with Coccinelle with the following semantic patch: @r depends on (org || report)@ type T; T[] E; position p; @@ ( (sizeof(E)@p /sizeof(*E)) | (sizeof(E)@p /sizeof(E[...])) | (sizeof(E)@p /sizeof(T)) ) Signed-off-by: Jérémy Lefaure Reviewed-by: Michael Ira Krufky Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/saa7146/saa7146_video.c | 9 ++++----- drivers/media/dvb-frontends/cxd2841er.c | 7 +++---- drivers/media/pci/saa7146/hexium_gemini.c | 3 ++- drivers/media/pci/saa7146/hexium_orion.c | 3 ++- drivers/media/pci/saa7146/mxb.c | 3 ++- drivers/media/usb/dvb-usb/cxusb.c | 3 ++- drivers/media/usb/dvb-usb/friio-fe.c | 5 ++--- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 2b631eaa65b3d..5dfc1f27d1cf7 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -4,6 +4,7 @@ #include #include #include +#include static int max_memory = 32; @@ -86,13 +87,11 @@ static struct saa7146_format formats[] = { due to this, it's impossible to provide additional *packed* formats, which are simply byte swapped (like V4L2_PIX_FMT_YUYV) ... 8-( */ -static int NUM_FORMATS = sizeof(formats)/sizeof(struct saa7146_format); - struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc) { - int i, j = NUM_FORMATS; + int i; - for (i = 0; i < j; i++) { + for (i = 0; i < ARRAY_SIZE(formats); i++) { if (formats[i].pixelformat == fourcc) { return formats+i; } @@ -524,7 +523,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, const struct v4l2_framebuf static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { - if (f->index >= NUM_FORMATS) + if (f->index >= ARRAY_SIZE(formats)) return -EINVAL; strlcpy((char *)f->description, formats[f->index].name, sizeof(f->description)); diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 48ee9bc00c069..2cb97a3130be7 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "dvb_math.h" #include "dvb_frontend.h" @@ -1696,12 +1697,10 @@ static u32 cxd2841er_dvbs_read_snr(struct cxd2841er_priv *priv, min_index = 0; if (delsys == SYS_DVBS) { cn_data = s_cn_data; - max_index = sizeof(s_cn_data) / - sizeof(s_cn_data[0]) - 1; + max_index = ARRAY_SIZE(s_cn_data) - 1; } else { cn_data = s2_cn_data; - max_index = sizeof(s2_cn_data) / - sizeof(s2_cn_data[0]) - 1; + max_index = ARRAY_SIZE(s2_cn_data) - 1; } if (value >= cn_data[min_index].value) { res = cn_data[min_index].cnr_x1000; diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c index d31a2d4494d1a..39357eddee32a 100644 --- a/drivers/media/pci/saa7146/hexium_gemini.c +++ b/drivers/media/pci/saa7146/hexium_gemini.c @@ -27,6 +27,7 @@ #include #include +#include static int debug; module_param(debug, int, 0); @@ -388,7 +389,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = HEXIUM_INPUTS, .capabilities = 0, .stds = &hexium_standards[0], - .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(hexium_standards), .std_callback = &std_callback, }; diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c index 043318aa19e2e..461e421080f38 100644 --- a/drivers/media/pci/saa7146/hexium_orion.c +++ b/drivers/media/pci/saa7146/hexium_orion.c @@ -27,6 +27,7 @@ #include #include +#include static int debug; module_param(debug, int, 0); @@ -460,7 +461,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = HEXIUM_INPUTS, .capabilities = 0, .stds = &hexium_standards[0], - .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(hexium_standards), .std_callback = &std_callback, }; diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 930218cc2de19..0144f305ea246 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "tea6415c.h" #include "tea6420.h" @@ -837,7 +838,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = MXB_INPUTS, .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_AUDIO, .stds = &standard[0], - .num_stds = sizeof(standard)/sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(standard), .std_callback = &std_callback, }; diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 247dc164dd638..7109fc7ab74dc 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "cxusb.h" @@ -304,7 +305,7 @@ static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff) 0x0e, 0x2, 0x47, 0x88, }; msleep(20); - for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) { + for (i = 0; i < ARRAY_SIZE(bufs); i += 4 / sizeof(u8)) { ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE, bufs+i, 4, &buf, 1); if (ret) diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c index b6046e0e07f68..b2830c1575485 100644 --- a/drivers/media/usb/dvb-usb/friio-fe.c +++ b/drivers/media/usb/dvb-usb/friio-fe.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "friio.h" @@ -340,8 +341,6 @@ static u8 init_code[][2] = { {0x76, 0x0C}, }; -static const int init_code_len = sizeof(init_code) / sizeof(u8[2]); - static int jdvbt90502_init(struct dvb_frontend *fe) { int i = -1; @@ -355,7 +354,7 @@ static int jdvbt90502_init(struct dvb_frontend *fe) msg.addr = state->config.demod_address; msg.flags = 0; msg.len = 2; - for (i = 0; i < init_code_len; i++) { + for (i = 0; i < ARRAY_SIZE(init_code); i++) { msg.buf = init_code[i]; ret = i2c_transfer(state->i2c, &msg, 1); if (ret != 1) -- GitLab From 60a881862c69d211701d9bba81203a2f44d38367 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 31 Oct 2017 06:19:42 -0400 Subject: [PATCH 0034/1190] media: pt3: remove redundant assignment to mask Variable mask is being set to 0x80 and then set to this value again in the following for-loop. Remove the extraneous first setting of mask. Cleans up clang warning: drivers/media/pci/pt3/pt3_i2c.c:88:2: warning: Value stored to 'mask' is never read Signed-off-by: Colin Ian King Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/pt3/pt3_i2c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/pci/pt3/pt3_i2c.c b/drivers/media/pci/pt3/pt3_i2c.c index ec6a8a2e47447..b66138c7b3649 100644 --- a/drivers/media/pci/pt3/pt3_i2c.c +++ b/drivers/media/pci/pt3/pt3_i2c.c @@ -85,7 +85,6 @@ static void put_byte_write(struct pt3_i2cbuf *cbuf, u8 val) { u8 mask; - mask = 0x80; for (mask = 0x80; mask > 0; mask >>= 1) cmdbuf_add(cbuf, (val & mask) ? I_DATA_H_NOP : I_DATA_L_NOP); cmdbuf_add(cbuf, I_DATA_H_ACK0); -- GitLab From 85f42985af385f726152fd01836589f0a5a8090e Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 31 Oct 2017 07:31:42 -0400 Subject: [PATCH 0035/1190] media: drivers/media/pci/zoran: remove redundant assignment to pointer h The pointer h is already initialized to codeclist_top so the second identical assignment is redundant and can be removed. Cleans up clang warning: drivers/media/pci/zoran/videocodec.c:322:21: warning: Value stored to 'h' during its initialization is never read Signed-off-by: Colin Ian King Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/zoran/videocodec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/pci/zoran/videocodec.c b/drivers/media/pci/zoran/videocodec.c index 303289a7fd3f6..5ff23ef892154 100644 --- a/drivers/media/pci/zoran/videocodec.c +++ b/drivers/media/pci/zoran/videocodec.c @@ -325,7 +325,6 @@ static int proc_videocodecs_show(struct seq_file *m, void *v) seq_printf(m, "lave or attached aster name type flags magic "); seq_printf(m, "(connected as)\n"); - h = codeclist_top; while (h) { seq_printf(m, "S %32s %04x %08lx %08lx (TEMPLATE)\n", h->codec->name, h->codec->type, -- GitLab From 297aca189fdfdf12037e4eebc749aa6ebaa84e0e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 31 Oct 2017 10:21:48 -0400 Subject: [PATCH 0036/1190] media: adv7180: Remove duplicate checks Since i2c_unregister_device() became NULL-aware we may remove duplicate checks. Cc: Lars-Peter Clausen Signed-off-by: Andy Shevchenko Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7180.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 6fb818a775db2..25d24a3f10a7c 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1366,11 +1366,9 @@ static int adv7180_probe(struct i2c_client *client, err_free_ctrl: adv7180_exit_controls(state); err_unregister_vpp_client: - if (state->chip_info->flags & ADV7180_FLAG_I2P) - i2c_unregister_device(state->vpp_client); + i2c_unregister_device(state->vpp_client); err_unregister_csi_client: - if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) - i2c_unregister_device(state->csi_client); + i2c_unregister_device(state->csi_client); mutex_destroy(&state->mutex); return ret; } @@ -1388,10 +1386,8 @@ static int adv7180_remove(struct i2c_client *client) media_entity_cleanup(&sd->entity); adv7180_exit_controls(state); - if (state->chip_info->flags & ADV7180_FLAG_I2P) - i2c_unregister_device(state->vpp_client); - if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) - i2c_unregister_device(state->csi_client); + i2c_unregister_device(state->vpp_client); + i2c_unregister_device(state->csi_client); adv7180_set_power_pin(state, false); -- GitLab From 5195978fcbc4be6c16b99498aab56c27e71b2410 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 31 Oct 2017 10:21:49 -0400 Subject: [PATCH 0037/1190] media: i2c: adv748x: Remove duplicate NULL check Since i2c_unregister_device() became NULL-aware we may remove duplicate NULL check. Signed-off-by: Andy Shevchenko Acked-by: Kieran Bingham Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv748x/adv748x-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c index 5ee14f2c27478..10c3d469175c4 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -225,10 +225,8 @@ static void adv748x_unregister_clients(struct adv748x_state *state) { unsigned int i; - for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) { - if (state->i2c_clients[i]) - i2c_unregister_device(state->i2c_clients[i]); - } + for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) + i2c_unregister_device(state->i2c_clients[i]); } static int adv748x_initialise_clients(struct adv748x_state *state) -- GitLab From fdda01090cc22312d83cba78def3668ec7ac6715 Mon Sep 17 00:00:00 2001 From: Romain Reignier Date: Sun, 19 Nov 2017 12:25:10 -0500 Subject: [PATCH 0038/1190] media: cx231xx: Add support for The Imaging Source DFG/USB2pro Note that the inputs for the Composite and S-Video are inverted in regard to most of the other boards using a cx231xx chip. Signed-off-by: Romain Reignier Signed-off-by: Hans Verkuil --- drivers/media/usb/cx231xx/cx231xx-cards.c | 28 +++++++++++++++++++++++ drivers/media/usb/cx231xx/cx231xx.h | 1 + 2 files changed, 29 insertions(+) diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 54d9d0cb326fc..99c8b1a47a0c4 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -896,6 +896,32 @@ struct cx231xx_board cx231xx_boards[] = { }, }, }, + [CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO] = { + .name = "The Imaging Source DFG/USB2pro", + .tuner_type = TUNER_ABSENT, + .decoder = CX231XX_AVDECODER, + .output_mode = OUT_MODE_VIP11, + .demod_xfer_mode = 0, + .ctl_pin_status_mask = 0xFFFFFFC4, + .agc_analog_digital_select_gpio = 0x0c, + .gpio_pin_status_mask = 0x4001000, + .norm = V4L2_STD_PAL, + .no_alt_vanc = 1, + .external_av = 1, + .input = {{ + .type = CX231XX_VMUX_COMPOSITE1, + .vmux = CX231XX_VIN_1_1, + .amux = CX231XX_AMUX_LINE_IN, + .gpio = NULL, + }, { + .type = CX231XX_VMUX_SVIDEO, + .vmux = CX231XX_VIN_2_1 | + (CX231XX_VIN_2_2 << 8) | + CX25840_SVIDEO_ON, + .amux = CX231XX_AMUX_LINE_IN, + .gpio = NULL, + } }, + }, }; const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); @@ -967,6 +993,8 @@ struct usb_device_id cx231xx_id_table[] = { .driver_info = CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD}, {USB_DEVICE(0x15f4, 0x0135), .driver_info = CX231XX_BOARD_ASTROMETA_T2HYBRID}, + {USB_DEVICE(0x199e, 0x8002), + .driver_info = CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO}, {}, }; diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h index 72d5937a087ec..65b039cf80bee 100644 --- a/drivers/media/usb/cx231xx/cx231xx.h +++ b/drivers/media/usb/cx231xx/cx231xx.h @@ -80,6 +80,7 @@ #define CX231XX_BOARD_TERRATEC_GRABBY 22 #define CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD 23 #define CX231XX_BOARD_ASTROMETA_T2HYBRID 24 +#define CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO 25 /* Limits minimum and default number of buffers */ #define CX231XX_MIN_BUF 4 -- GitLab From 8fc58186bb41ff8789ad9e993c03a23d67698709 Mon Sep 17 00:00:00 2001 From: Stanimir Varbanov Date: Fri, 1 Dec 2017 10:08:01 -0500 Subject: [PATCH 0039/1190] media: venus: venc: set correctly GOP size and number of B-frames This change fixes the calculation of B-frames and GOP size by adopt v4l2 controls with the firmware interface expectations. Signed-off-by: Stanimir Varbanov Signed-off-by: Hans Verkuil [hans.verkuil@cisco.com: fixed two small checkpatch comments] Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/qcom/venus/venc.c | 15 +++-- .../media/platform/qcom/venus/venc_ctrls.c | 59 ++++++++++++++++++- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 3fcf0e9b7b291..8cfc866b07e5d 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -652,8 +652,13 @@ static int venc_set_properties(struct venus_inst *inst) return ret; } + /* IDR periodicity, n: + * n = 0 - only the first I-frame is IDR frame + * n = 1 - all I-frames will be IDR frames + * n > 1 - every n-th I-frame will be IDR frame + */ ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; - idrp.idr_period = ctr->gop_size; + idrp.idr_period = 0; ret = hfi_session_set_property(inst, ptype, &idrp); if (ret) return ret; @@ -667,10 +672,6 @@ static int venc_set_properties(struct venus_inst *inst) return ret; } - /* intra_period = pframes + bframes + 1 */ - if (!ctr->num_p_frames) - ctr->num_p_frames = 2 * 15 - 1, - ptype = HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD; intra_period.pframes = ctr->num_p_frames; intra_period.bframes = ctr->num_b_frames; @@ -767,6 +768,10 @@ static int venc_init_session(struct venus_inst *inst) if (ret) goto deinit; + ret = venc_set_properties(inst); + if (ret) + goto deinit; + return 0; deinit: hfi_session_deinit(inst); diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index ab0fe51ff0f7f..21e938a28662b 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -30,10 +30,57 @@ #define AT_SLICE_BOUNDARY \ V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY +static int venc_calc_bpframes(u32 gop_size, u32 conseq_b, u32 *bf, u32 *pf) +{ + u32 half = (gop_size - 1) >> 1; + u32 b, p, ratio; + bool found = false; + + if (!gop_size) + return -EINVAL; + + *bf = *pf = 0; + + if (!conseq_b) { + *pf = gop_size - 1; + return 0; + } + + b = p = half; + + for (; b <= gop_size - 1; b++, p--) { + if (b % p) + continue; + + ratio = b / p; + + if (ratio == conseq_b) { + found = true; + break; + } + + if (ratio > conseq_b) + break; + } + + if (!found) + return -EINVAL; + + if (b + p + 1 != gop_size) + return -EINVAL; + + *bf = b; + *pf = p; + + return 0; +} + static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) { struct venus_inst *inst = ctrl_to_inst(ctrl); struct venc_controls *ctr = &inst->controls.enc; + u32 bframes; + int ret; switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: @@ -102,6 +149,11 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: break; case V4L2_CID_MPEG_VIDEO_GOP_SIZE: + ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes, + &ctr->num_p_frames); + if (ret) + return ret; + ctr->gop_size = ctrl->val; break; case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD: @@ -114,7 +166,12 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ctr->vp8_max_qp = ctrl->val; break; case V4L2_CID_MPEG_VIDEO_B_FRAMES: - ctr->num_b_frames = ctrl->val; + ret = venc_calc_bpframes(ctr->gop_size, ctrl->val, &bframes, + &ctr->num_p_frames); + if (ret) + return ret; + + ctr->num_b_frames = bframes; break; default: return -EINVAL; -- GitLab From 678856299c0db53c47bfcbedda7921d878a78be5 Mon Sep 17 00:00:00 2001 From: Ian Jamison Date: Fri, 1 Dec 2017 13:53:50 -0500 Subject: [PATCH 0040/1190] media: imx: Remove incorrect check for queue state in start/stop_streaming It is possible to call STREAMON without the minimum number of buffers queued. In this case the vb2_queue state will be set to streaming but the start_streaming vb2_op will not be called. Later when enough buffers are queued, start_streaming will be called but vb2_is_streaming will already return true. Also removed the queue state check in stop_streaming since it's not valid there either. Signed-off-by: Ian Jamison Reviewed-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-capture.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index ea145bafb880a..7b6763802db82 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -449,9 +449,6 @@ static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) unsigned long flags; int ret; - if (vb2_is_streaming(vq)) - return 0; - ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity, true); if (ret) { @@ -480,9 +477,6 @@ static void capture_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - if (!vb2_is_streaming(vq)) - return; - spin_lock_irqsave(&priv->q_lock, flags); priv->stop = true; spin_unlock_irqrestore(&priv->q_lock, flags); -- GitLab From 979d33d3a7ea6ae76e6fecd457fd6be8c57052c7 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Dec 2017 10:03:11 -0500 Subject: [PATCH 0041/1190] media: adv7604.c: add missing return A 'return' was missing when detecting Arbitration Lost and calling transmit_done. With the return transmit_done could be called a second time, confusing the CEC framework. Luckily the Arbitration Lost condition is very rare. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7604.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index c786cd1254176..1544920ec52dc 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -1982,6 +1982,7 @@ static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status) __func__); cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST, 1, 0, 0, 0); + return; } if (tx_raw_status & 0x04) { u8 status; -- GitLab From 2c21ac0ae457310ec0044e4ff806e677af8253ab Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 4 Dec 2017 03:56:52 -0500 Subject: [PATCH 0042/1190] media: cec-adap: add '0x' prefix when printing status It's not clear if the transmit status that is printed when debugging is enabled is hex or decimal. Add 0x prefix to make this explicit. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/cec/cec-adap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 98f88c43f62cb..91d72805ee598 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -540,7 +540,7 @@ void cec_transmit_done_ts(struct cec_adapter *adap, u8 status, unsigned int attempts_made = arb_lost_cnt + nack_cnt + low_drive_cnt + error_cnt; - dprintk(2, "%s: status %02x\n", __func__, status); + dprintk(2, "%s: status 0x%02x\n", __func__, status); if (attempts_made < 1) attempts_made = 1; -- GitLab From a17d2d6cd9985ca09a9e384f1bc71d710f7e5203 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 4 Dec 2017 06:01:11 -0500 Subject: [PATCH 0043/1190] media: vsp1: Prevent suspending and resuming DRM pipelines When used as part of a display pipeline, the VSP is stopped and restarted explicitly by the DU from its suspend and resume handlers. There is thus no need to stop or restart pipelines in the VSP suspend and resume handlers, and doing so would cause the hardware to be left in a misconfigured state. Ensure that the VSP suspend and resume handlers do not affect DRM-based pipelines. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 962e4c3040768..eed9516e25e1d 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -571,7 +571,13 @@ static int __maybe_unused vsp1_pm_suspend(struct device *dev) { struct vsp1_device *vsp1 = dev_get_drvdata(dev); - vsp1_pipelines_suspend(vsp1); + /* + * When used as part of a display pipeline, the VSP is stopped and + * restarted explicitly by the DU. + */ + if (!vsp1->drm) + vsp1_pipelines_suspend(vsp1); + pm_runtime_force_suspend(vsp1->dev); return 0; @@ -582,7 +588,13 @@ static int __maybe_unused vsp1_pm_resume(struct device *dev) struct vsp1_device *vsp1 = dev_get_drvdata(dev); pm_runtime_force_resume(vsp1->dev); - vsp1_pipelines_resume(vsp1); + + /* + * When used as part of a display pipeline, the VSP is stopped and + * restarted explicitly by the DU. + */ + if (!vsp1->drm) + vsp1_pipelines_resume(vsp1); return 0; } -- GitLab From 1ee332acc6b5d1b4773bb5314b07938da5406e1e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 20 Sep 2017 03:37:13 -0400 Subject: [PATCH 0044/1190] media: cx23885: Handle return value of kasprintf kasprintf() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx23885/cx23885-input.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c index 944b70831f129..0f4e54294bb7b 100644 --- a/drivers/media/pci/cx23885/cx23885-input.c +++ b/drivers/media/pci/cx23885/cx23885-input.c @@ -340,14 +340,23 @@ int cx23885_input_init(struct cx23885_dev *dev) kernel_ir->cx = dev; kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)", cx23885_boards[dev->board].name); + if (!kernel_ir->name) { + ret = -ENOMEM; + goto err_out_free; + } + kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0", pci_name(dev->pci)); + if (!kernel_ir->phys) { + ret = -ENOMEM; + goto err_out_free_name; + } /* input device */ rc = rc_allocate_device(RC_DRIVER_IR_RAW); if (!rc) { ret = -ENOMEM; - goto err_out_free; + goto err_out_free_phys; } kernel_ir->rc = rc; @@ -382,9 +391,11 @@ int cx23885_input_init(struct cx23885_dev *dev) cx23885_input_ir_stop(dev); dev->kernel_ir = NULL; rc_free_device(rc); -err_out_free: +err_out_free_phys: kfree(kernel_ir->phys); +err_out_free_name: kfree(kernel_ir->name); +err_out_free: kfree(kernel_ir); return ret; } -- GitLab From e2a067048d6263613cee8c5c36aa6f2d755ef425 Mon Sep 17 00:00:00 2001 From: Dean A Date: Fri, 3 Nov 2017 16:11:03 -0400 Subject: [PATCH 0045/1190] media: s2255drv: update firmware load fixes intermittent soft reboot issue with firmware load increases wait time of reset, as required by HW Signed-off-by: Dean Anderson Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/s2255/s2255drv.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 7fee5766587a7..8c2a86d71e8a8 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -350,7 +350,7 @@ static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf, int jpgsize); static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode); static int s2255_board_shutdown(struct s2255_dev *dev); -static void s2255_fwload_start(struct s2255_dev *dev, int reset); +static void s2255_fwload_start(struct s2255_dev *dev); static void s2255_destroy(struct s2255_dev *dev); static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req, u16 index, u16 value, void *buf, @@ -476,7 +476,7 @@ static void planar422p_to_yuv_packed(const unsigned char *in, static void s2255_reset_dsppower(struct s2255_dev *dev) { s2255_vendor_req(dev, 0x40, 0x0000, 0x0001, NULL, 0, 1); - msleep(20); + msleep(50); s2255_vendor_req(dev, 0x50, 0x0000, 0x0000, NULL, 0, 1); msleep(600); s2255_vendor_req(dev, 0x10, 0x0000, 0x0000, NULL, 0, 1); @@ -1450,7 +1450,7 @@ static int s2255_open(struct file *file) case S2255_FW_FAILED: s2255_dev_err(&dev->udev->dev, "firmware load failed. retrying.\n"); - s2255_fwload_start(dev, 1); + s2255_fwload_start(dev); wait_event_timeout(dev->fw_data->wait_fw, ((atomic_read(&dev->fw_data->fw_state) == S2255_FW_SUCCESS) || @@ -2209,10 +2209,9 @@ static void s2255_stop_readpipe(struct s2255_dev *dev) return; } -static void s2255_fwload_start(struct s2255_dev *dev, int reset) +static void s2255_fwload_start(struct s2255_dev *dev) { - if (reset) - s2255_reset_dsppower(dev); + s2255_reset_dsppower(dev); dev->fw_data->fw_size = dev->fw_data->fw->size; atomic_set(&dev->fw_data->fw_state, S2255_FW_NOTLOADED); memcpy(dev->fw_data->pfw_data, @@ -2337,7 +2336,7 @@ static int s2255_probe(struct usb_interface *interface, retval = s2255_board_init(dev); if (retval) goto errorBOARDINIT; - s2255_fwload_start(dev, 0); + s2255_fwload_start(dev); /* loads v4l specific */ retval = s2255_probe_v4l(dev); if (retval) -- GitLab From 52cf1d964e4ca89ed80f97a8451245c9bb13a63d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 6 Nov 2017 05:20:01 -0500 Subject: [PATCH 0046/1190] media: vimc: add test_pattern and h/vflip controls to the sensor Add support for the test_pattern control and the h/vflip controls. This makes it possible to switch to more interesting test patterns and to test control handling in v4l-subdevs. There are more tpg-related controls that can be added, but this is a good start. Signed-off-by: Hans Verkuil [hans.verkuil@cisco.com: fix small whitespace checkpatch warning] Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vimc/vimc-common.h | 5 ++ drivers/media/platform/vimc/vimc-sensor.c | 63 ++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vimc/vimc-common.h b/drivers/media/platform/vimc/vimc-common.h index dca528a316e76..2e9981b181669 100644 --- a/drivers/media/platform/vimc/vimc-common.h +++ b/drivers/media/platform/vimc/vimc-common.h @@ -22,6 +22,11 @@ #include #include +/* VIMC-specific controls */ +#define VIMC_CID_VIMC_BASE (0x00f00000 | 0xf000) +#define VIMC_CID_VIMC_CLASS (0x00f00000 | 1) +#define VIMC_CID_TEST_PATTERN (VIMC_CID_VIMC_BASE + 0) + #define VIMC_FRAME_MAX_WIDTH 4096 #define VIMC_FRAME_MAX_HEIGHT 2160 #define VIMC_FRAME_MIN_WIDTH 16 diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c index 02e68c8fc02bf..ca1c52232d1e3 100644 --- a/drivers/media/platform/vimc/vimc-sensor.c +++ b/drivers/media/platform/vimc/vimc-sensor.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ struct vimc_sen_device { u8 *frame; /* The active format */ struct v4l2_mbus_framefmt mbus_format; + struct v4l2_ctrl_handler hdl; }; static const struct v4l2_mbus_framefmt fmt_default = { @@ -291,6 +293,31 @@ static const struct v4l2_subdev_ops vimc_sen_ops = { .video = &vimc_sen_video_ops, }; +static int vimc_sen_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct vimc_sen_device *vsen = + container_of(ctrl->handler, struct vimc_sen_device, hdl); + + switch (ctrl->id) { + case VIMC_CID_TEST_PATTERN: + tpg_s_pattern(&vsen->tpg, ctrl->val); + break; + case V4L2_CID_HFLIP: + tpg_s_hflip(&vsen->tpg, ctrl->val); + break; + case V4L2_CID_VFLIP: + tpg_s_vflip(&vsen->tpg, ctrl->val); + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct v4l2_ctrl_ops vimc_sen_ctrl_ops = { + .s_ctrl = vimc_sen_s_ctrl, +}; + static void vimc_sen_comp_unbind(struct device *comp, struct device *master, void *master_data) { @@ -299,10 +326,28 @@ static void vimc_sen_comp_unbind(struct device *comp, struct device *master, container_of(ved, struct vimc_sen_device, ved); vimc_ent_sd_unregister(ved, &vsen->sd); + v4l2_ctrl_handler_free(&vsen->hdl); tpg_free(&vsen->tpg); kfree(vsen); } +/* Image Processing Controls */ +static const struct v4l2_ctrl_config vimc_sen_ctrl_class = { + .flags = V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY, + .id = VIMC_CID_VIMC_CLASS, + .name = "VIMC Controls", + .type = V4L2_CTRL_TYPE_CTRL_CLASS, +}; + +static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = { + .ops = &vimc_sen_ctrl_ops, + .id = VIMC_CID_TEST_PATTERN, + .name = "Test Pattern", + .type = V4L2_CTRL_TYPE_MENU, + .max = TPG_PAT_NOISE, + .qmenu = tpg_pattern_strings, +}; + static int vimc_sen_comp_bind(struct device *comp, struct device *master, void *master_data) { @@ -316,6 +361,20 @@ static int vimc_sen_comp_bind(struct device *comp, struct device *master, if (!vsen) return -ENOMEM; + v4l2_ctrl_handler_init(&vsen->hdl, 4); + + v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_class, NULL); + v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_test_pattern, NULL); + v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops, + V4L2_CID_VFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops, + V4L2_CID_HFLIP, 0, 1, 1, 0); + vsen->sd.ctrl_handler = &vsen->hdl; + if (vsen->hdl.error) { + ret = vsen->hdl.error; + goto err_free_vsen; + } + /* Initialize ved and sd */ ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev, pdata->entity_name, @@ -323,7 +382,7 @@ static int vimc_sen_comp_bind(struct device *comp, struct device *master, (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE}, &vimc_sen_ops); if (ret) - goto err_free_vsen; + goto err_free_hdl; dev_set_drvdata(comp, &vsen->ved); vsen->dev = comp; @@ -342,6 +401,8 @@ static int vimc_sen_comp_bind(struct device *comp, struct device *master, err_unregister_ent_sd: vimc_ent_sd_unregister(&vsen->ved, &vsen->sd); +err_free_hdl: + v4l2_ctrl_handler_free(&vsen->hdl); err_free_vsen: kfree(vsen); -- GitLab From cc05c0ba23bbc05d34caeb4773b89e1dfc2598b8 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 10 Nov 2017 11:45:54 -0500 Subject: [PATCH 0047/1190] media: pulse8-cec: print time using time64_t The firmware timestamp is an unsigned 32-bit value, but we copy it into a signed 32-bit variable, so we can theoretically get an overflow in the calculation when the timestamp is between 2038 and 2106. This changes the temporary variable to time64_t and changes the deprecated time_to_tm() over to time64_to_tm() accordingly. There is still an overflow in y2106, but that is a limitation of the firmware interface, not a kernel problem. Signed-off-by: Arnd Bergmann Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pulse8-cec/pulse8-cec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c index 50146f263d904..350635826aaed 100644 --- a/drivers/media/usb/pulse8-cec/pulse8-cec.c +++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c @@ -329,7 +329,7 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio, u8 cmd[2]; int err; struct tm tm; - time_t date; + time64_t date; pulse8->vers = 0; @@ -349,7 +349,7 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio, if (err) return err; date = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; - time_to_tm(date, 0, &tm); + time64_to_tm(date, 0, &tm); dev_info(pulse8->dev, "Firmware build date %04ld.%02d.%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -- GitLab From 48ea2e926b5ad29c0747fbd90e605cc56fb78298 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 5 Nov 2017 07:36:36 -0500 Subject: [PATCH 0048/1190] media: cec: add the adap_monitor_pin_enable op Some devices can monitor the CEC pin using an interrupt, but you only want to enable the interrupt if you actually switch to pin monitoring mode. So add a new op that is called when pin monitoring needs to be switched on or off. Also fix a small bug where the initial CEC pin event was sent again when calling S_MODE twice with the same CEC_MODE_MONITOR_PIN mode. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/cec/cec-adap.c | 23 +++++++++++++++++++++++ drivers/media/cec/cec-api.c | 21 ++++++++++++++++----- drivers/media/cec/cec-priv.h | 2 ++ include/media/cec.h | 1 + 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 91d72805ee598..2a097e016414e 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -2053,6 +2053,29 @@ void cec_monitor_all_cnt_dec(struct cec_adapter *adap) WARN_ON(call_op(adap, adap_monitor_all_enable, 0)); } +/* + * Helper functions to keep track of the 'monitor pin' use count. + * + * These functions are called with adap->lock held. + */ +int cec_monitor_pin_cnt_inc(struct cec_adapter *adap) +{ + int ret = 0; + + if (adap->monitor_pin_cnt == 0) + ret = call_op(adap, adap_monitor_pin_enable, 1); + if (ret == 0) + adap->monitor_pin_cnt++; + return ret; +} + +void cec_monitor_pin_cnt_dec(struct cec_adapter *adap) +{ + adap->monitor_pin_cnt--; + if (adap->monitor_pin_cnt == 0) + WARN_ON(call_op(adap, adap_monitor_pin_enable, 0)); +} + #ifdef CONFIG_DEBUG_FS /* * Log the current state of the CEC adapter. diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index 3dba3aa34a430..3eb4a069cde8e 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -354,6 +354,7 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, u32 mode; u8 mode_initiator; u8 mode_follower; + bool send_pin_event = false; long err = 0; if (copy_from_user(&mode, parg, sizeof(mode))) @@ -433,6 +434,19 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, } } + if (!err) { + bool old_mon_pin = fh->mode_follower == CEC_MODE_MONITOR_PIN; + bool new_mon_pin = mode_follower == CEC_MODE_MONITOR_PIN; + + if (old_mon_pin != new_mon_pin) { + send_pin_event = new_mon_pin; + if (new_mon_pin) + err = cec_monitor_pin_cnt_inc(adap); + else + cec_monitor_pin_cnt_dec(adap); + } + } + if (err) { mutex_unlock(&adap->lock); return err; @@ -440,11 +454,9 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, if (fh->mode_follower == CEC_MODE_FOLLOWER) adap->follower_cnt--; - if (fh->mode_follower == CEC_MODE_MONITOR_PIN) - adap->monitor_pin_cnt--; if (mode_follower == CEC_MODE_FOLLOWER) adap->follower_cnt++; - if (mode_follower == CEC_MODE_MONITOR_PIN) { + if (send_pin_event) { struct cec_event ev = { .flags = CEC_EVENT_FL_INITIAL_STATE, }; @@ -452,7 +464,6 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, ev.event = adap->cec_pin_is_high ? CEC_EVENT_PIN_CEC_HIGH : CEC_EVENT_PIN_CEC_LOW; cec_queue_event_fh(fh, &ev, 0); - adap->monitor_pin_cnt++; } if (mode_follower == CEC_MODE_EXCL_FOLLOWER || mode_follower == CEC_MODE_EXCL_FOLLOWER_PASSTHRU) { @@ -608,7 +619,7 @@ static int cec_release(struct inode *inode, struct file *filp) if (fh->mode_follower == CEC_MODE_FOLLOWER) adap->follower_cnt--; if (fh->mode_follower == CEC_MODE_MONITOR_PIN) - adap->monitor_pin_cnt--; + cec_monitor_pin_cnt_dec(adap); if (fh->mode_follower == CEC_MODE_MONITOR_ALL) cec_monitor_all_cnt_dec(adap); mutex_unlock(&adap->lock); diff --git a/drivers/media/cec/cec-priv.h b/drivers/media/cec/cec-priv.h index 70767a7900f22..daf597643af8b 100644 --- a/drivers/media/cec/cec-priv.h +++ b/drivers/media/cec/cec-priv.h @@ -40,6 +40,8 @@ void cec_put_device(struct cec_devnode *devnode); /* cec-adap.c */ int cec_monitor_all_cnt_inc(struct cec_adapter *adap); void cec_monitor_all_cnt_dec(struct cec_adapter *adap); +int cec_monitor_pin_cnt_inc(struct cec_adapter *adap); +void cec_monitor_pin_cnt_dec(struct cec_adapter *adap); int cec_adap_status(struct seq_file *file, void *priv); int cec_thread_func(void *_adap); void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block); diff --git a/include/media/cec.h b/include/media/cec.h index 16341210d3ba1..dd781e928b727 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -122,6 +122,7 @@ struct cec_adap_ops { /* Low-level callbacks */ int (*adap_enable)(struct cec_adapter *adap, bool enable); int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); + int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable); int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, u32 signal_free_time, struct cec_msg *msg); -- GitLab From 15ae0be9c671e912a6749d821bc69ccfff766c19 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 23 Nov 2017 09:05:06 -0500 Subject: [PATCH 0049/1190] media: cec-core.rst: document the new adap_monitor_pin_enable op Document what this op does. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/kapi/cec-core.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/media/kapi/cec-core.rst b/Documentation/media/kapi/cec-core.rst index d37e107f2fde5..62b9a14481773 100644 --- a/Documentation/media/kapi/cec-core.rst +++ b/Documentation/media/kapi/cec-core.rst @@ -103,6 +103,7 @@ your driver: /* Low-level callbacks */ int (*adap_enable)(struct cec_adapter *adap, bool enable); int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); + int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable); int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, u32 signal_free_time, struct cec_msg *msg); @@ -144,6 +145,19 @@ called if the CEC_CAP_MONITOR_ALL capability is set. This callback is optional Note that adap_monitor_all_enable must return 0 if enable is false. +To enable/disable the 'monitor pin' mode: + +.. c:function:: + int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable); + +If enabled, then the adapter should be put in a mode to also monitor CEC pin +changes. Not all hardware supports this and this function is only called if +the CEC_CAP_MONITOR_PIN capability is set. This callback is optional +(some hardware may always be in 'monitor pin' mode). + +Note that adap_monitor_pin_enable must return 0 if enable is false. + + To program a new logical address: .. c:function:: -- GitLab From c8959a39fd47189a1474a4e92ffa34763589d6b0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 22 Nov 2017 04:12:39 -0500 Subject: [PATCH 0050/1190] media: cec: disable the hardware when unregistered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the device is being unregistered disable the hardware, don't wait until cec_delete_adapter is called as the hardware may have disappeared by then. This would be the case for hotplugable devices. Signed-off-by: Hans Verkuil Reported-by: Bård Eirik Winther Tested-by: Bård Eirik Winther Signed-off-by: Mauro Carvalho Chehab --- drivers/media/cec/cec-api.c | 11 ++++------- drivers/media/cec/cec-core.c | 15 +++++++++------ include/media/cec.h | 12 ++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index 3eb4a069cde8e..37e468074dc16 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -46,12 +46,11 @@ static inline struct cec_devnode *cec_devnode_data(struct file *filp) static unsigned int cec_poll(struct file *filp, struct poll_table_struct *poll) { - struct cec_devnode *devnode = cec_devnode_data(filp); struct cec_fh *fh = filp->private_data; struct cec_adapter *adap = fh->adap; unsigned int res = 0; - if (!devnode->registered) + if (!cec_is_registered(adap)) return POLLERR | POLLHUP; mutex_lock(&adap->lock); if (adap->is_configured && @@ -486,13 +485,12 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, static long cec_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { - struct cec_devnode *devnode = cec_devnode_data(filp); struct cec_fh *fh = filp->private_data; struct cec_adapter *adap = fh->adap; bool block = !(filp->f_flags & O_NONBLOCK); void __user *parg = (void __user *)arg; - if (!devnode->registered) + if (!cec_is_registered(adap)) return -ENODEV; switch (cmd) { @@ -626,9 +624,8 @@ static int cec_release(struct inode *inode, struct file *filp) mutex_lock(&devnode->lock); list_del(&fh->list); - if (list_empty(&devnode->fhs) && - !adap->needs_hpd && - adap->phys_addr == CEC_PHYS_ADDR_INVALID) { + if (cec_is_registered(adap) && list_empty(&devnode->fhs) && + !adap->needs_hpd && adap->phys_addr == CEC_PHYS_ADDR_INVALID) { WARN_ON(adap->ops->adap_enable(adap, false)); } mutex_unlock(&devnode->lock); diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c index 5870da6a567f3..b5845b47fe6c2 100644 --- a/drivers/media/cec/cec-core.c +++ b/drivers/media/cec/cec-core.c @@ -160,8 +160,9 @@ static int __must_check cec_devnode_register(struct cec_devnode *devnode, * This function can safely be called if the device node has never been * registered or has already been unregistered. */ -static void cec_devnode_unregister(struct cec_devnode *devnode) +static void cec_devnode_unregister(struct cec_adapter *adap) { + struct cec_devnode *devnode = &adap->devnode; struct cec_fh *fh; mutex_lock(&devnode->lock); @@ -179,6 +180,11 @@ static void cec_devnode_unregister(struct cec_devnode *devnode) devnode->unregistered = true; mutex_unlock(&devnode->lock); + mutex_lock(&adap->lock); + __cec_s_phys_addr(adap, CEC_PHYS_ADDR_INVALID, false); + __cec_s_log_addrs(adap, NULL, false); + mutex_unlock(&adap->lock); + cdev_device_del(&devnode->cdev, &devnode->dev); put_device(&devnode->dev); } @@ -192,7 +198,7 @@ static void cec_cec_notify(struct cec_adapter *adap, u16 pa) void cec_register_cec_notifier(struct cec_adapter *adap, struct cec_notifier *notifier) { - if (WARN_ON(!adap->devnode.registered)) + if (WARN_ON(!cec_is_registered(adap))) return; adap->notifier = notifier; @@ -373,7 +379,7 @@ void cec_unregister_adapter(struct cec_adapter *adap) if (adap->notifier) cec_notifier_unregister(adap->notifier); #endif - cec_devnode_unregister(&adap->devnode); + cec_devnode_unregister(adap); } EXPORT_SYMBOL_GPL(cec_unregister_adapter); @@ -381,9 +387,6 @@ void cec_delete_adapter(struct cec_adapter *adap) { if (IS_ERR_OR_NULL(adap)) return; - mutex_lock(&adap->lock); - __cec_s_phys_addr(adap, CEC_PHYS_ADDR_INVALID, false); - mutex_unlock(&adap->lock); kthread_stop(adap->kthread); if (adap->kthread_config) kthread_stop(adap->kthread_config); diff --git a/include/media/cec.h b/include/media/cec.h index dd781e928b727..1c6a797cb6d4a 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -230,6 +230,18 @@ static inline bool cec_is_sink(const struct cec_adapter *adap) return adap->phys_addr == 0; } +/** + * cec_is_registered() - is the CEC adapter registered? + * + * @adap: the CEC adapter, may be NULL. + * + * Return: true if the adapter is registered, false otherwise. + */ +static inline bool cec_is_registered(const struct cec_adapter *adap) +{ + return adap && adap->devnode.registered; +} + #define cec_phys_addr_exp(pa) \ ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf -- GitLab From 13109fbc78018f0bdfd52b111d7c1443da650b78 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 17 Oct 2017 13:19:07 -0400 Subject: [PATCH 0051/1190] media: staging: media: imx: fix inconsistent IS_ERR and PTR_ERR Fix inconsistent IS_ERR and PTR_ERR in csi_link_validate. The proper pointer to be passed as argument is sensor. This issue was detected with the help of Coccinelle. Reported-by: Julia Lawall Signed-off-by: Gustavo A. R. Silva Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index bb1d6dafca834..ebb4ca530de2e 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -989,7 +989,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, sensor = __imx_media_find_sensor(priv->md, &priv->sd.entity); if (IS_ERR(sensor)) { v4l2_err(&priv->sd, "no sensor attached\n"); - return PTR_ERR(priv->sensor); + return PTR_ERR(sensor); } mutex_lock(&priv->lock); -- GitLab From a95d811e50f1eae1da11b47b5dbc757cab9c8994 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Wed, 8 Nov 2017 13:58:03 -0500 Subject: [PATCH 0052/1190] media: coda: remove definition of CODA_STD_MJPG According to i.MX VPU API Reference Manuals the MJPG video codec is referenced to by number 7, not 3. Also Philipp pointed out that this value is only meant to fill in CMD_ENC_SEQ_COD_STD for encoding, only on i.MX53. It was never written to any register, and even if defined correctly, wouldn't be needed for i.MX6. So avoid confusion and remove this definition. Signed-off-by: Martin Kepplinger Acked-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda/coda_regs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/platform/coda/coda_regs.h b/drivers/media/platform/coda/coda_regs.h index 38df5fd9a2fa7..35e620c7f1f45 100644 --- a/drivers/media/platform/coda/coda_regs.h +++ b/drivers/media/platform/coda/coda_regs.h @@ -254,7 +254,6 @@ #define CODA9_STD_H264 0 #define CODA_STD_H263 1 #define CODA_STD_H264 2 -#define CODA_STD_MJPG 3 #define CODA9_STD_MPEG4 3 #define CODA_CMD_ENC_SEQ_SRC_SIZE 0x190 -- GitLab From d5ac225c7d64c9c3ef821239edc035634e594ec9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 9 Nov 2017 16:28:14 -0500 Subject: [PATCH 0053/1190] media: cpia2: Fix a couple off by one bugs The cam->buffers[] array has cam->num_frames elements so the > needs to be changed to >= to avoid going beyond the end of the array. The ->buffers[] array is allocated in cpia2_allocate_buffers() if you want to confirm. Fixes: ab33d5071de7 ("V4L/DVB (3376): Add cpia2 camera support") Signed-off-by: Dan Carpenter Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cpia2/cpia2_v4l.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c index 3dedd83f0b19f..a1c59f19cf2d6 100644 --- a/drivers/media/usb/cpia2/cpia2_v4l.c +++ b/drivers/media/usb/cpia2/cpia2_v4l.c @@ -808,7 +808,7 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) struct camera_data *cam = video_drvdata(file); if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; @@ -859,7 +859,7 @@ static int cpia2_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->memory != V4L2_MEMORY_MMAP || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; DBG("QBUF #%d\n", buf->index); -- GitLab From 41e33085284dd2bc6b6180d8381ff8a509b9d8ba Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 10 Nov 2017 11:46:17 -0500 Subject: [PATCH 0054/1190] media: vivid: print time in y2038-safe way time_to_tm() takes a time_t value that overflows in 2038 on 32-bit systems. time64_to_tm() doesn't have this problem, so let's use that in combination with ktime_get_real_seconds() to read a 64-bit time value. Signed-off-by: Arnd Bergmann Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vivid/vivid-rds-gen.c | 2 +- drivers/media/platform/vivid/vivid-vbi-gen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vivid/vivid-rds-gen.c b/drivers/media/platform/vivid/vivid-rds-gen.c index 53c7777dc0019..996e35e28d37a 100644 --- a/drivers/media/platform/vivid/vivid-rds-gen.c +++ b/drivers/media/platform/vivid/vivid-rds-gen.c @@ -103,7 +103,7 @@ void vivid_rds_generate(struct vivid_rds_gen *rds) * EN 50067:1998 to convert a UTC date to an RDS Modified * Julian Day. */ - time_to_tm(get_seconds(), 0, &tm); + time64_to_tm(ktime_get_real_seconds(), 0, &tm); l = tm.tm_mon <= 1; date = 14956 + tm.tm_mday + ((tm.tm_year - l) * 1461) / 4 + ((tm.tm_mon + 2 + l * 12) * 306001) / 10000; diff --git a/drivers/media/platform/vivid/vivid-vbi-gen.c b/drivers/media/platform/vivid/vivid-vbi-gen.c index a2159de83d0bb..02c79d7cedab3 100644 --- a/drivers/media/platform/vivid/vivid-vbi-gen.c +++ b/drivers/media/platform/vivid/vivid-vbi-gen.c @@ -190,7 +190,7 @@ static void vivid_vbi_gen_set_time_of_day(u8 *packet) struct tm tm; u8 checksum, i; - time_to_tm(get_seconds(), 0, &tm); + time64_to_tm(ktime_get_real_seconds(), 0, &tm); packet[0] = calc_parity(0x07); packet[1] = calc_parity(0x01); packet[2] = calc_parity(0x40 | tm.tm_min); -- GitLab From b627758489fddc8dbf5519092f4cf181d2b995ca Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 17 Nov 2017 09:18:26 -0500 Subject: [PATCH 0055/1190] media: usbvision: remove unneeded DRIVER_LICENSE #define There is no need to #define the license of the driver, just put it in the MODULE_LICENSE() line directly as a text string. This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference. Cc: Hans Verkuil Cc: Johan Hovold Cc: Davidlohr Bueso Cc: Sakari Ailus Reported-by: Philippe Ombredanne Signed-off-by: Greg Kroah-Hartman Reviewed-by: Philippe Ombredanne Acked-by: Mauro Carvalho Chehab Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/usbvision/usbvision-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index 960272d3c9241..0f5954a1fea25 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c @@ -72,7 +72,6 @@ #define DRIVER_NAME "usbvision" #define DRIVER_ALIAS "USBVision" #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" -#define DRIVER_LICENSE "GPL" #define USBVISION_VERSION_STRING "0.9.11" #define ENABLE_HEXDUMP 0 /* Enable if you need it */ @@ -141,7 +140,7 @@ MODULE_PARM_DESC(radio_nr, "Set radio device number (/dev/radioX). Default: -1 /* Misc stuff */ MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE(DRIVER_LICENSE); +MODULE_LICENSE("GPL"); MODULE_VERSION(USBVISION_VERSION_STRING); MODULE_ALIAS(DRIVER_ALIAS); -- GitLab From ccbc1e3876d5476fc23429690a683294ef0f755b Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 20 Nov 2017 02:47:54 -0500 Subject: [PATCH 0056/1190] media: mtk-vcodec: add missing MODULE_LICENSE/DESCRIPTION This change resolves a new compile-time warning when built as a loadable module: WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/mtk-vcodec/mtk-vcodec-common.o see include/linux/module.h for more information This adds the license as "GPL v2", which matches the header of the file. MODULE_DESCRIPTION is also added. Signed-off-by: Jesse Chan Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c index 46768c0561936..0c28d0b995ccd 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c @@ -115,3 +115,6 @@ struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev) return ctx; } EXPORT_SYMBOL(mtk_vcodec_get_curr_ctx); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Mediatek video codec driver"); -- GitLab From 5331aec1bf9c9da557668174e0a4bfcee39f1121 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 20 Nov 2017 15:56:28 -0500 Subject: [PATCH 0057/1190] media: soc_camera: soc_scale_crop: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE This change resolves a new compile-time warning when built as a loadable module: WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/soc_camera/soc_scale_crop.o see include/linux/module.h for more information This adds the license as "GPL", which matches the header of the file. MODULE_DESCRIPTION and MODULE_AUTHOR are also added. Signed-off-by: Jesse Chan Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_scale_crop.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c index 270ec613c27ca..6164102e6f9f9 100644 --- a/drivers/media/platform/soc_camera/soc_scale_crop.c +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c @@ -420,3 +420,7 @@ void soc_camera_calc_client_output(struct soc_camera_device *icd, mf->height = soc_camera_shift_scale(rect->height, shift, scale_v); } EXPORT_SYMBOL(soc_camera_calc_client_output); + +MODULE_DESCRIPTION("soc-camera scaling-cropping functions"); +MODULE_AUTHOR("Guennadi Liakhovetski "); +MODULE_LICENSE("GPL"); -- GitLab From 20772c1a6f0e03d4231e2b539863987fa0c94e89 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Mon, 20 Nov 2017 15:56:52 -0500 Subject: [PATCH 0058/1190] media: tegra-cec: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE This change resolves a new compile-time warning when built as a loadable module: WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/tegra-cec/tegra_cec.o see include/linux/module.h for more information This adds the license as "GPL v2", which matches the header of the file. MODULE_DESCRIPTION and MODULE_AUTHOR are also added. Signed-off-by: Jesse Chan Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/tegra-cec/tegra_cec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/tegra-cec/tegra_cec.c b/drivers/media/platform/tegra-cec/tegra_cec.c index 807c94c700493..92f93a8800158 100644 --- a/drivers/media/platform/tegra-cec/tegra_cec.c +++ b/drivers/media/platform/tegra-cec/tegra_cec.c @@ -493,3 +493,8 @@ static struct platform_driver tegra_cec_driver = { }; module_platform_driver(tegra_cec_driver); + +MODULE_DESCRIPTION("Tegra HDMI CEC driver"); +MODULE_AUTHOR("NVIDIA CORPORATION"); +MODULE_AUTHOR("Cisco Systems, Inc. and/or its affiliates"); +MODULE_LICENSE("GPL v2"); -- GitLab From 5a18c2434f8bfc8bc2fb0f8af3e44f7408d63e4f Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Wed, 22 Nov 2017 22:34:44 -0500 Subject: [PATCH 0059/1190] media: davinci: vpif_capture: add NULL check on devm_kzalloc return value Check return value from call to devm_kzalloc() in order to prevent a NULL pointer dereference. This issue was detected with the help of Coccinelle. Fixes: 4a5f8ae50b66 ("[media] davinci: vpif_capture: get subdevs from DT when available") Signed-off-by: Gustavo A. R. Silva Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index fca4dc829f73e..e45916f69defe 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -1550,6 +1550,8 @@ vpif_capture_get_pdata(struct platform_device *pdev) sizeof(*chan->inputs) * VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL); + if (!chan->inputs) + return NULL; chan->input_count++; chan->inputs[i].input.type = V4L2_INPUT_TYPE_CAMERA; -- GitLab From a7837e11679e015ef6c4b3f04ae09d17b0980c4e Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Fri, 24 Nov 2017 04:34:01 -0500 Subject: [PATCH 0060/1190] media: venus: venc: configure entropy mode H264 entropy mode can be selected via V4L2 API but is eventually not applied. Configure encoder with selected mode, CALVC (def) or CABAC. Note that hw/firmware also expects a CABAC model configuration which currently doesn't have existing V4L2 API control. For now, use model_0 which seems always supported and so the default one. Signed-off-by: Loic Poulain Reviewed-by: Stanimir Varbanov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/qcom/venus/venc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 8cfc866b07e5d..0c2331f53b798 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -641,6 +641,7 @@ static int venc_set_properties(struct venus_inst *inst) if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { struct hfi_h264_vui_timing_info info; + struct hfi_h264_entropy_control entropy; ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; info.enable = 1; @@ -650,6 +651,16 @@ static int venc_set_properties(struct venus_inst *inst) ret = hfi_session_set_property(inst, ptype, &info); if (ret) return ret; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; + entropy.entropy_mode = venc_v4l2_to_hfi( + V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, + ctr->h264_entropy_mode); + entropy.cabac_model = HFI_H264_CABAC_MODEL_0; + + ret = hfi_session_set_property(inst, ptype, &entropy); + if (ret) + return ret; } /* IDR periodicity, n: -- GitLab From f7d12fea16cbcc38d08092c6267e75fabeaa9093 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Fri, 24 Nov 2017 04:34:02 -0500 Subject: [PATCH 0061/1190] media: venus: venc: Apply inloop deblocking filter Deblocking filter allows to reduce blocking artifacts and improve visual quality. This is configurable via the V4L2 API but eventually not applied to the encoder. Note that alpha and beta deblocking values are 32-bit signed (-6;+6). Signed-off-by: Loic Poulain Reviewed-by: Stanimir Varbanov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/qcom/venus/core.h | 4 ++-- .../media/platform/qcom/venus/hfi_helper.h | 4 ++-- drivers/media/platform/qcom/venus/venc.c | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index a0fe80df0cbd5..0360d295f4c83 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -144,8 +144,8 @@ struct venc_controls { u32 h264_min_qp; u32 h264_max_qp; u32 h264_loop_filter_mode; - u32 h264_loop_filter_alpha; - u32 h264_loop_filter_beta; + s32 h264_loop_filter_alpha; + s32 h264_loop_filter_beta; u32 vp8_min_qp; u32 vp8_max_qp; diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 8d282dba9e572..55d8eb21403a7 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -585,8 +585,8 @@ struct hfi_enable { struct hfi_h264_db_control { u32 mode; - u32 slice_alpha_offset; - u32 slice_beta_offset; + s32 slice_alpha_offset; + s32 slice_beta_offset; }; #define HFI_H264_ENTROPY_CAVLC 0x1 diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 0c2331f53b798..e3a10a852cade 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -234,6 +234,16 @@ static int venc_v4l2_to_hfi(int id, int value) case 3: return HFI_VPX_PROFILE_VERSION_3; } + case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: + switch (value) { + case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED: + default: + return HFI_H264_DB_MODE_ALL_BOUNDARY; + case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED: + return HFI_H264_DB_MODE_DISABLE; + case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY: + return HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY; + } } return 0; @@ -642,6 +652,7 @@ static int venc_set_properties(struct venus_inst *inst) if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { struct hfi_h264_vui_timing_info info; struct hfi_h264_entropy_control entropy; + struct hfi_h264_db_control deblock; ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; info.enable = 1; @@ -661,6 +672,17 @@ static int venc_set_properties(struct venus_inst *inst) ret = hfi_session_set_property(inst, ptype, &entropy); if (ret) return ret; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; + deblock.mode = venc_v4l2_to_hfi( + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, + ctr->h264_loop_filter_mode); + deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; + deblock.slice_beta_offset = ctr->h264_loop_filter_beta; + + ret = hfi_session_set_property(inst, ptype, &deblock); + if (ret) + return ret; } /* IDR periodicity, n: -- GitLab From 6c542426b610c14acff0e815e5fe513abdbb9a16 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 27 Nov 2017 08:19:55 -0500 Subject: [PATCH 0062/1190] media: solo6x10: use ktime_get_ts64() for time sync solo6x10 correctly deals with time stamps and will never suffer from overflows, but it uses the deprecated 'struct timespec' type and 'ktime_get_ts()' interface to read the monotonic clock. This changes it to use ktime_get_ts64() instead, so we can eventually remove ktime_get_ts(). Signed-off-by: Arnd Bergmann Signed-off-by: Ismael Luceno Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/solo6x10/solo6x10-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c index ca0873e47bead..19ffd2ed3cc7b 100644 --- a/drivers/media/pci/solo6x10/solo6x10-core.c +++ b/drivers/media/pci/solo6x10/solo6x10-core.c @@ -47,18 +47,19 @@ MODULE_PARM_DESC(full_eeprom, "Allow access to full 128B EEPROM (dangerous)"); static void solo_set_time(struct solo_dev *solo_dev) { - struct timespec ts; + struct timespec64 ts; - ktime_get_ts(&ts); + ktime_get_ts64(&ts); - solo_reg_write(solo_dev, SOLO_TIMER_SEC, ts.tv_sec); - solo_reg_write(solo_dev, SOLO_TIMER_USEC, ts.tv_nsec / NSEC_PER_USEC); + /* no overflow because we use monotonic timestamps */ + solo_reg_write(solo_dev, SOLO_TIMER_SEC, (u32)ts.tv_sec); + solo_reg_write(solo_dev, SOLO_TIMER_USEC, (u32)ts.tv_nsec / NSEC_PER_USEC); } static void solo_timer_sync(struct solo_dev *solo_dev) { u32 sec, usec; - struct timespec ts; + struct timespec64 ts; long diff; if (solo_dev->type != SOLO_DEV_6110) @@ -72,11 +73,11 @@ static void solo_timer_sync(struct solo_dev *solo_dev) sec = solo_reg_read(solo_dev, SOLO_TIMER_SEC); usec = solo_reg_read(solo_dev, SOLO_TIMER_USEC); - ktime_get_ts(&ts); + ktime_get_ts64(&ts); - diff = (long)ts.tv_sec - (long)sec; + diff = (s32)ts.tv_sec - (s32)sec; diff = (diff * 1000000) - + ((long)(ts.tv_nsec / NSEC_PER_USEC) - (long)usec); + + ((s32)(ts.tv_nsec / NSEC_PER_USEC) - (s32)usec); if (diff > 1000 || diff < -1000) { solo_set_time(solo_dev); -- GitLab From 1d88f4bccfd87b6359f11032f2018893d531d18d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 27 Nov 2017 08:20:00 -0500 Subject: [PATCH 0063/1190] media: staging: imx: use ktime_t for timestamps The imx media driver passes around monotonic timestamps in the deprecated 'timespec' format. This is not a problem for the driver, as they won't overflow, but moving to either timespec64 or ktime_t is preferred. I'm picking ktime_t for simplicity here. frame_interval_monitor() is the main function that changes, as it tries to compare a time interval in microseconds. The algorithm slightly changes here, to avoid 64-bit division. The code previously assumed that the error was at most 32-bit worth of microseconds here, so I'm making the same assumption but add an explicit test for it. Signed-off-by: Arnd Bergmann Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-csi.c | 8 ++---- drivers/staging/media/imx/imx-media-fim.c | 30 +++++++++++++---------- drivers/staging/media/imx/imx-media.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index ebb4ca530de2e..f4a3bf5ca2bbc 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -207,13 +207,9 @@ static irqreturn_t csi_idmac_eof_interrupt(int irq, void *dev_id) goto unlock; } - if (priv->fim) { - struct timespec cur_ts; - - ktime_get_ts(&cur_ts); + if (priv->fim) /* call frame interval monitor */ - imx_media_fim_eof_monitor(priv->fim, &cur_ts); - } + imx_media_fim_eof_monitor(priv->fim, ktime_get()); csi_vb2_buf_done(priv); diff --git a/drivers/staging/media/imx/imx-media-fim.c b/drivers/staging/media/imx/imx-media-fim.c index 47275ef803f35..6df189135db88 100644 --- a/drivers/staging/media/imx/imx-media-fim.c +++ b/drivers/staging/media/imx/imx-media-fim.c @@ -66,7 +66,7 @@ struct imx_media_fim { int icap_flags; int counter; - struct timespec last_ts; + ktime_t last_ts; unsigned long sum; /* usec */ unsigned long nominal; /* usec */ @@ -147,22 +147,26 @@ static void send_fim_event(struct imx_media_fim *fim, unsigned long error) * (presumably random) interrupt latency. */ static void frame_interval_monitor(struct imx_media_fim *fim, - struct timespec *ts) + ktime_t timestamp) { - unsigned long interval, error, error_avg; + long long interval, error; + unsigned long error_avg; bool send_event = false; - struct timespec diff; if (!fim->enabled || ++fim->counter <= 0) goto out_update_ts; - diff = timespec_sub(*ts, fim->last_ts); - interval = diff.tv_sec * 1000 * 1000 + diff.tv_nsec / 1000; - error = abs(interval - fim->nominal); + /* max error is less than l00µs, so use 32-bit division or fail */ + interval = ktime_to_ns(ktime_sub(timestamp, fim->last_ts)); + error = abs(interval - NSEC_PER_USEC * (u64)fim->nominal); + if (error > U32_MAX) + error = U32_MAX; + else + error = abs((u32)error / NSEC_PER_USEC); if (fim->tolerance_max && error >= fim->tolerance_max) { dev_dbg(fim->sd->dev, - "FIM: %lu ignored, out of tolerance bounds\n", + "FIM: %llu ignored, out of tolerance bounds\n", error); fim->counter--; goto out_update_ts; @@ -184,7 +188,7 @@ static void frame_interval_monitor(struct imx_media_fim *fim, } out_update_ts: - fim->last_ts = *ts; + fim->last_ts = timestamp; if (send_event) send_fim_event(fim, error_avg); } @@ -195,14 +199,14 @@ static void frame_interval_monitor(struct imx_media_fim *fim, * to interrupt latency. */ static void fim_input_capture_handler(int channel, void *dev_id, - struct timespec *ts) + ktime_t timestamp) { struct imx_media_fim *fim = dev_id; unsigned long flags; spin_lock_irqsave(&fim->lock, flags); - frame_interval_monitor(fim, ts); + frame_interval_monitor(fim, timestamp); if (!completion_done(&fim->icap_first_event)) complete(&fim->icap_first_event); @@ -405,14 +409,14 @@ static int init_fim_controls(struct imx_media_fim *fim) * the frame_interval_monitor() is called by the input capture event * callback handler in that case. */ -void imx_media_fim_eof_monitor(struct imx_media_fim *fim, struct timespec *ts) +void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp) { unsigned long flags; spin_lock_irqsave(&fim->lock, flags); if (!icap_enabled(fim)) - frame_interval_monitor(fim, ts); + frame_interval_monitor(fim, timestamp); spin_unlock_irqrestore(&fim->lock, flags); } diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index e5b8d2953be52..a5ae0baa5e19c 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -280,7 +280,7 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd, /* imx-media-fim.c */ struct imx_media_fim; -void imx_media_fim_eof_monitor(struct imx_media_fim *fim, struct timespec *ts); +void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp); int imx_media_fim_set_stream(struct imx_media_fim *fim, const struct v4l2_fract *frame_interval, bool on); -- GitLab From aad2fa4c8b1d99a737f97b031cc3e262f158b02e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 27 Nov 2017 10:25:56 -0500 Subject: [PATCH 0064/1190] media: vivid: use ktime_t for timestamp calculation timespec is generally deprecated because of the y2038 overflow. In vivid, the usage is fine, since we are dealing with monotonic timestamps, but we can also simplify the code by going to ktime_t. Using ktime_divns() should be roughly as efficient as the old code, since the constant 64-bit division gets turned into a multiplication on modern platforms, and we save multiple 32-bit divisions that can be expensive e.g. on ARMv7. Tested-by: Hans Verkuil Signed-off-by: Arnd Bergmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vivid/vivid-core.c | 2 +- drivers/media/platform/vivid/vivid-core.h | 2 +- drivers/media/platform/vivid/vivid-radio-rx.c | 11 +++++------ drivers/media/platform/vivid/vivid-radio-tx.c | 8 +++----- drivers/media/platform/vivid/vivid-rds-gen.h | 1 + 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c index 5f316a5e38dbe..a091cfd931648 100644 --- a/drivers/media/platform/vivid/vivid-core.c +++ b/drivers/media/platform/vivid/vivid-core.c @@ -995,7 +995,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) dev->edid_max_blocks = dev->edid_blocks = 2; memcpy(dev->edid, vivid_hdmi_edid, sizeof(vivid_hdmi_edid)); - ktime_get_ts(&dev->radio_rds_init_ts); + dev->radio_rds_init_time = ktime_get(); /* create all controls */ ret = vivid_create_controls(dev, ccs_cap == -1, ccs_out == -1, no_error_inj, diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h index 5cdf95bdc4d16..d8bff4dcefb70 100644 --- a/drivers/media/platform/vivid/vivid-core.h +++ b/drivers/media/platform/vivid/vivid-core.h @@ -510,7 +510,7 @@ struct vivid_dev { /* Shared between radio receiver and transmitter */ bool radio_rds_loop; - struct timespec radio_rds_init_ts; + ktime_t radio_rds_init_time; /* CEC */ struct cec_adapter *cec_rx_adap; diff --git a/drivers/media/platform/vivid/vivid-radio-rx.c b/drivers/media/platform/vivid/vivid-radio-rx.c index 47c36c26096b2..35fbff4905358 100644 --- a/drivers/media/platform/vivid/vivid-radio-rx.c +++ b/drivers/media/platform/vivid/vivid-radio-rx.c @@ -38,9 +38,9 @@ ssize_t vivid_radio_rx_read(struct file *file, char __user *buf, size_t size, loff_t *offset) { struct vivid_dev *dev = video_drvdata(file); - struct timespec ts; struct v4l2_rds_data *data = dev->rds_gen.data; bool use_alternates; + ktime_t timestamp; unsigned blk; int perc; int i; @@ -64,17 +64,16 @@ ssize_t vivid_radio_rx_read(struct file *file, char __user *buf, } retry: - ktime_get_ts(&ts); - use_alternates = ts.tv_sec % 10 >= 5; + timestamp = ktime_sub(ktime_get(), dev->radio_rds_init_time); + blk = ktime_divns(timestamp, VIVID_RDS_NSEC_PER_BLK); + use_alternates = (blk % VIVID_RDS_GEN_BLOCKS) & 1; + if (dev->radio_rx_rds_last_block == 0 || dev->radio_rx_rds_use_alternates != use_alternates) { dev->radio_rx_rds_use_alternates = use_alternates; /* Re-init the RDS generator */ vivid_radio_rds_init(dev); } - ts = timespec_sub(ts, dev->radio_rds_init_ts); - blk = ts.tv_sec * 100 + ts.tv_nsec / 10000000; - blk = (blk * VIVID_RDS_GEN_BLOCKS) / 500; if (blk >= dev->radio_rx_rds_last_block + VIVID_RDS_GEN_BLOCKS) dev->radio_rx_rds_last_block = blk - VIVID_RDS_GEN_BLOCKS + 1; diff --git a/drivers/media/platform/vivid/vivid-radio-tx.c b/drivers/media/platform/vivid/vivid-radio-tx.c index 0e8025b7b4dde..897b56195ca7a 100644 --- a/drivers/media/platform/vivid/vivid-radio-tx.c +++ b/drivers/media/platform/vivid/vivid-radio-tx.c @@ -37,7 +37,7 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf, { struct vivid_dev *dev = video_drvdata(file); struct v4l2_rds_data *data = dev->rds_gen.data; - struct timespec ts; + ktime_t timestamp; unsigned blk; int i; @@ -58,10 +58,8 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf, dev->radio_tx_rds_owner = file->private_data; retry: - ktime_get_ts(&ts); - ts = timespec_sub(ts, dev->radio_rds_init_ts); - blk = ts.tv_sec * 100 + ts.tv_nsec / 10000000; - blk = (blk * VIVID_RDS_GEN_BLOCKS) / 500; + timestamp = ktime_sub(ktime_get(), dev->radio_rds_init_time); + blk = ktime_divns(timestamp, VIVID_RDS_NSEC_PER_BLK); if (blk - VIVID_RDS_GEN_BLOCKS >= dev->radio_tx_rds_last_block) dev->radio_tx_rds_last_block = blk - VIVID_RDS_GEN_BLOCKS + 1; diff --git a/drivers/media/platform/vivid/vivid-rds-gen.h b/drivers/media/platform/vivid/vivid-rds-gen.h index eff4bf552ed36..e55e3b22b7ca4 100644 --- a/drivers/media/platform/vivid/vivid-rds-gen.h +++ b/drivers/media/platform/vivid/vivid-rds-gen.h @@ -29,6 +29,7 @@ #define VIVID_RDS_GEN_GROUPS 57 #define VIVID_RDS_GEN_BLKS_PER_GRP 4 #define VIVID_RDS_GEN_BLOCKS (VIVID_RDS_GEN_BLKS_PER_GRP * VIVID_RDS_GEN_GROUPS) +#define VIVID_RDS_NSEC_PER_BLK (u32)(5ull * NSEC_PER_SEC / VIVID_RDS_GEN_BLOCKS) struct vivid_rds_gen { struct v4l2_rds_data data[VIVID_RDS_GEN_BLOCKS]; -- GitLab From 0ff6c131c8424ea94092f30b61d9205ab606b99a Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 28 Nov 2017 08:01:24 -0500 Subject: [PATCH 0065/1190] media: i2c: adv748x: Restore full DT paths in kernel messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of_node_full_name() now returns only the basename, the endpoint information printed became useless: adv748x 4-0070: Endpoint endpoint on port 7 adv748x 4-0070: Endpoint endpoint on port 8 adv748x 4-0070: Endpoint endpoint on port 10 adv748x 4-0070: Endpoint endpoint on port 11 Restore the old behavior by using "%pOF" instead: adv748x 4-0070: Endpoint /soc/i2c@e66d8000/video-receiver@70/port@7/endpoint on port 7 adv748x 4-0070: Endpoint /soc/i2c@e66d8000/video-receiver@70/port@8/endpoint on port 8 adv748x 4-0070: Endpoint /soc/i2c@e66d8000/video-receiver@70/port@10/endpoint on port 10 adv748x 4-0070: Endpoint /soc/i2c@e66d8000/video-receiver@70/port@11/endpoint on port 11 Fixes: a7e4cfb0a7ca4773 ("of/fdt: only store the device node basename in full_name") Signed-off-by: Geert Uytterhoeven Reviewed-by: Niklas Söderlund Acked-by: Kieran Bingham Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv748x/adv748x-core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c index 10c3d469175c4..fd92c9e4b519d 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -644,14 +644,12 @@ static int adv748x_parse_dt(struct adv748x_state *state) for_each_endpoint_of_node(state->dev->of_node, ep_np) { of_graph_parse_endpoint(ep_np, &ep); - adv_info(state, "Endpoint %s on port %d", - of_node_full_name(ep.local_node), - ep.port); + adv_info(state, "Endpoint %pOF on port %d", ep.local_node, + ep.port); if (ep.port >= ADV748X_PORT_MAX) { - adv_err(state, "Invalid endpoint %s on port %d", - of_node_full_name(ep.local_node), - ep.port); + adv_err(state, "Invalid endpoint %pOF on port %d", + ep.local_node, ep.port); continue; } -- GitLab From f3105f0ae4d9fda5b3922319dfe248cdb504c2a8 Mon Sep 17 00:00:00 2001 From: Stanimir Varbanov Date: Wed, 29 Nov 2017 08:25:21 -0500 Subject: [PATCH 0066/1190] media: venus: cleanup set_property controls Move ptype (property type) initialization out of switch case and save few lines of code. Signed-off-by: Stanimir Varbanov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/qcom/venus/hfi_cmds.c | 73 +------------------- 1 file changed, 2 insertions(+), 71 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index b83c5b8ddccb5..1cfeb77430415 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -421,12 +421,12 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; pkt->shdr.session_id = hash32_ptr(cookie); pkt->num_properties = 1; + pkt->data[0] = ptype; switch (ptype) { case HFI_PROPERTY_CONFIG_FRAME_RATE: { struct hfi_framerate *in = pdata, *frate = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_FRAME_RATE; frate->buffer_type = in->buffer_type; frate->framerate = in->framerate; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*frate); @@ -436,7 +436,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_uncompressed_format_select *in = pdata; struct hfi_uncompressed_format_select *hfi = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT; hfi->buffer_type = in->buffer_type; hfi->format = in->format; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi); @@ -445,7 +444,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_FRAME_SIZE: { struct hfi_framesize *in = pdata, *fsize = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_FRAME_SIZE; fsize->buffer_type = in->buffer_type; fsize->height = in->height; fsize->width = in->width; @@ -455,7 +453,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_REALTIME: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_REALTIME; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -463,7 +460,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: { struct hfi_buffer_count_actual *in = pdata, *count = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL; count->count_actual = in->count_actual; count->type = in->type; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); @@ -472,7 +468,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL: { struct hfi_buffer_size_actual *in = pdata, *sz = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL; sz->size = in->size; sz->type = in->type; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*sz); @@ -482,8 +477,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_buffer_display_hold_count_actual *in = pdata; struct hfi_buffer_display_hold_count_actual *count = prop_data; - pkt->data[0] = - HFI_PROPERTY_PARAM_BUFFER_DISPLAY_HOLD_COUNT_ACTUAL; count->hold_count = in->hold_count; count->type = in->type; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); @@ -493,7 +486,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_nal_stream_format_select *in = pdata; struct hfi_nal_stream_format_select *fmt = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT; fmt->format = in->format; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*fmt); break; @@ -510,7 +502,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -518,7 +509,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE: { struct hfi_enable_picture *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE; en->picture_type = in->picture_type; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -526,8 +516,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = - HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -536,7 +524,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_enable *in = pdata; struct hfi_enable *en = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -544,7 +531,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM: { struct hfi_multi_stream *in = pdata, *multi = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; multi->buffer_type = in->buffer_type; multi->enable = in->enable; multi->width = in->width; @@ -556,8 +542,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_display_picture_buffer_count *in = pdata; struct hfi_display_picture_buffer_count *count = prop_data; - pkt->data[0] = - HFI_PROPERTY_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT; count->count = in->count; count->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); @@ -576,7 +560,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_DIVX_FORMAT; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -584,7 +567,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -592,7 +574,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -600,7 +581,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -608,14 +588,11 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = - HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; } case HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME: - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME; pkt->shdr.hdr.size += sizeof(u32); break; case HFI_PROPERTY_PARAM_VENC_MPEG4_SHORT_HEADER: @@ -625,7 +602,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE: { struct hfi_bitrate *in = pdata, *brate = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; brate->bitrate = in->bitrate; brate->layer_id = in->layer_id; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*brate); @@ -634,7 +610,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: { struct hfi_bitrate *in = pdata, *hfi = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE; hfi->bitrate = in->bitrate; hfi->layer_id = in->layer_id; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi); @@ -643,7 +618,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: { struct hfi_profile_level *in = pdata, *pl = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; pl->level = in->level; pl->profile = in->profile; if (pl->profile <= 0) @@ -660,7 +634,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL: { struct hfi_h264_entropy_control *in = pdata, *hfi = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; hfi->entropy_mode = in->entropy_mode; if (hfi->entropy_mode == HFI_H264_ENTROPY_CABAC) hfi->cabac_model = in->cabac_model; @@ -682,7 +655,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_RATE_CONTROL; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -690,7 +662,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION: { struct hfi_mpeg4_time_resolution *in = pdata, *res = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION; res->time_increment_resolution = in->time_increment_resolution; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*res); break; @@ -698,7 +669,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION: { struct hfi_mpeg4_header_extension *in = pdata, *ext = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION; ext->header_extension = in->header_extension; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ext); break; @@ -716,7 +686,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; db->mode = in->mode; db->slice_alpha_offset = in->slice_alpha_offset; db->slice_beta_offset = in->slice_beta_offset; @@ -726,7 +695,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_SESSION_QP: { struct hfi_quantization *in = pdata, *quant = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_SESSION_QP; quant->qp_i = in->qp_i; quant->qp_p = in->qp_p; quant->qp_b = in->qp_b; @@ -738,7 +706,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_quantization_range *in = pdata, *range = prop_data; u32 min_qp, max_qp; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE; min_qp = in->min_qp; max_qp = in->max_qp; @@ -764,8 +731,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_VC1_PERF_CFG: { struct hfi_vc1e_perf_cfg_type *in = pdata, *perf = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_VC1_PERF_CFG; - memcpy(perf->search_range_x_subsampled, in->search_range_x_subsampled, sizeof(perf->search_range_x_subsampled)); @@ -780,7 +745,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_max_num_b_frames *bframes = prop_data; u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES; bframes->max_num_b_frames = *in; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*bframes); break; @@ -788,7 +752,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD: { struct hfi_intra_period *in = pdata, *intra = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD; intra->pframes = in->pframes; intra->bframes = in->bframes; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra); @@ -797,7 +760,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD: { struct hfi_idr_period *in = pdata, *idr = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; idr->idr_period = in->idr_period; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*idr); break; @@ -806,7 +768,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_conceal_color *color = prop_data; u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR; color->conceal_color = *in; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*color); break; @@ -835,7 +796,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_CONFIG_VPE_OPERATIONS; ops->rotation = in->rotation; ops->flip = in->flip; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ops); @@ -856,7 +816,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH; intra->mode = in->mode; intra->air_mbs = in->air_mbs; intra->air_ref = in->air_ref; @@ -878,7 +837,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_CONTROL; multi->multi_slice = in->multi_slice; multi->slice_size = in->slice_size; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi); @@ -887,7 +845,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_SLICE_DELIVERY_MODE: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_SLICE_DELIVERY_MODE; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -895,7 +852,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO: { struct hfi_h264_vui_timing_info *in = pdata, *vui = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; vui->enable = in->enable; vui->fixed_framerate = in->fixed_framerate; vui->time_scale = in->time_scale; @@ -905,7 +861,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VPE_DEINTERLACE: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VPE_DEINTERLACE; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -913,7 +868,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_H264_GENERATE_AUDNAL: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_H264_GENERATE_AUDNAL; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -921,7 +875,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: { struct hfi_buffer_alloc_mode *in = pdata, *mode = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; mode->type = in->type; mode->mode = in->mode; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*mode); @@ -930,7 +883,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -938,8 +890,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = - HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -947,7 +897,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -956,7 +905,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_scs_threshold *thres = prop_data; u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_SCS_THRESHOLD; thres->threshold_value = *in; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*thres); break; @@ -974,7 +922,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_MVC_BUFFER_LAYOUT; mvc->layout_type = in->layout_type; mvc->bright_view_first = in->bright_view_first; mvc->ngap = in->ngap; @@ -994,7 +941,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_LTRMODE; ltr->ltr_mode = in->ltr_mode; ltr->ltr_count = in->ltr_count; ltr->trust_mode = in->trust_mode; @@ -1004,7 +950,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_USELTRFRAME: { struct hfi_ltr_use *in = pdata, *ltr_use = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_USELTRFRAME; ltr_use->frames = in->frames; ltr_use->ref_ltr = in->ref_ltr; ltr_use->use_constrnt = in->use_constrnt; @@ -1014,7 +959,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME: { struct hfi_ltr_mark *in = pdata, *ltr_mark = prop_data; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME; ltr_mark->mark_frame = in->mark_frame; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_mark); break; @@ -1022,7 +966,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER: { u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -1030,7 +973,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER: { u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -1038,7 +980,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -1046,7 +987,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_INITIAL_QP: { struct hfi_initial_quantization *in = pdata, *quant = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_INITIAL_QP; quant->init_qp_enable = in->init_qp_enable; quant->qp_i = in->qp_i; quant->qp_p = in->qp_p; @@ -1058,7 +998,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, struct hfi_vpe_color_space_conversion *in = pdata; struct hfi_vpe_color_space_conversion *csc = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VPE_COLOR_SPACE_CONVERSION; memcpy(csc->csc_matrix, in->csc_matrix, sizeof(csc->csc_matrix)); memcpy(csc->csc_bias, in->csc_bias, sizeof(csc->csc_bias)); @@ -1069,8 +1008,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = - HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -1078,7 +1015,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_H264_NAL_SVC_EXT: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_H264_NAL_SVC_EXT; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -1086,7 +1022,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_CONFIG_VENC_PERF_MODE: { u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_CONFIG_VENC_PERF_MODE; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -1094,7 +1029,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER: { u32 *in = pdata; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER; pkt->data[1] = *in; pkt->shdr.hdr.size += sizeof(u32) * 2; break; @@ -1102,7 +1036,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VDEC_NONCP_OUTPUT2: { struct hfi_enable *in = pdata, *en = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_NONCP_OUTPUT2; en->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); break; @@ -1110,7 +1043,6 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE: { struct hfi_hybrid_hierp *in = pdata, *hierp = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE; hierp->layers = in->layers; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hierp); break; @@ -1185,6 +1117,7 @@ pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; pkt->shdr.session_id = hash32_ptr(cookie); pkt->num_properties = 1; + pkt->data[0] = ptype; /* * Any session set property which is different in 3XX packetization @@ -1196,7 +1129,6 @@ pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, struct hfi_multi_stream *in = pdata; struct hfi_multi_stream_3x *multi = prop_data; - pkt->data[0] = HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; multi->buffer_type = in->buffer_type; multi->enable = in->enable; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi); @@ -1218,7 +1150,6 @@ pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, break; } - pkt->data[0] = HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH; intra->mode = in->mode; intra->mbs = in->cir_mbs; pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra); -- GitLab From 248cb158bc1a262ff3101b9e5439ff3850b2cfd5 Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Wed, 29 Nov 2017 11:20:16 -0500 Subject: [PATCH 0067/1190] media: exynos4-is: Use PTR_ERR_OR_ZERO() Fix ptr_ret.cocci warnings: drivers/media/platform/exynos4-is/fimc-lite.c:1465:1-3: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Signed-off-by: Vasyl Gomonovych Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 4a3c9948ca547..5db572aa88995 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1462,10 +1462,7 @@ static void fimc_lite_clk_put(struct fimc_lite *fimc) static int fimc_lite_clk_get(struct fimc_lite *fimc) { fimc->clock = clk_get(&fimc->pdev->dev, FLITE_CLK_NAME); - if (IS_ERR(fimc->clock)) - return PTR_ERR(fimc->clock); - - return 0; + return PTR_ERR_OR_ZERO(fimc->clock); } static const struct of_device_id flite_of_match[]; -- GitLab From e96cdc9a0aa2fcaa276a76e8ffa86fc10a1d3d99 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 6 Nov 2017 15:13:28 -0500 Subject: [PATCH 0068/1190] media: uvcvideo: Add D3DFMT_L8 support Microsoft HoloLense UVC sensor uses D3DFMT instead of FOURCC when exposing formats. This adds support for D3DFMT_L8 as exposed from the Acer Windows Mixed Reality Headset. Signed-off-by: Nicolas Dufresne Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_driver.c | 5 +++++ drivers/media/usb/uvc/uvcvideo.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 28b91b7d756f5..07e427d365163 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -93,6 +93,11 @@ static struct uvc_format_desc uvc_fmts[] = { .guid = UVC_GUID_FORMAT_Y8, .fcc = V4L2_PIX_FMT_GREY, }, + { + .name = "Greyscale 8-bit (D3DFMT_L8)", + .guid = UVC_GUID_FORMAT_D3DFMT_L8, + .fcc = V4L2_PIX_FMT_GREY, + }, { .name = "Greyscale 10-bit (Y10 )", .guid = UVC_GUID_FORMAT_Y10, diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 05398784d1c89..19e725e2bda5b 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -154,6 +154,11 @@ { 'I', 'N', 'V', 'I', 0xdb, 0x57, 0x49, 0x5e, \ 0x8e, 0x3f, 0xf4, 0x79, 0x53, 0x2b, 0x94, 0x6f} +#define UVC_GUID_FORMAT_D3DFMT_L8 \ + {0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} + + /* ------------------------------------------------------------------------ * Driver specific constants. */ -- GitLab From 5ba3dff4f3f4b0a3c8775d6ea48c07b11a7ad790 Mon Sep 17 00:00:00 2001 From: Jaejoong Kim Date: Fri, 20 Oct 2017 03:25:27 -0400 Subject: [PATCH 0069/1190] media: uvcvideo: Remove duplicate & operation usb_endpoint_maxp() has an inline keyword and searches for bits[10:0] by & operation with 0x7ff. So, we can remove the duplicate & operation with 0x7ff. Signed-off-by: Jaejoong Kim Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index fb86d6af398d3..f4ace6352520b 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1469,13 +1469,13 @@ static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev, case USB_SPEED_HIGH: psize = usb_endpoint_maxp(&ep->desc); mult = usb_endpoint_maxp_mult(&ep->desc); - return (psize & 0x07ff) * mult; + return psize * mult; case USB_SPEED_WIRELESS: psize = usb_endpoint_maxp(&ep->desc); return psize; default: psize = usb_endpoint_maxp(&ep->desc); - return psize & 0x07ff; + return psize; } } -- GitLab From dfc1648c576719b5a2701805aab1e208789d5969 Mon Sep 17 00:00:00 2001 From: Baoyou Xie Date: Wed, 6 Sep 2017 22:59:48 -0400 Subject: [PATCH 0070/1190] media: uvcvideo: Mark buffer error where overflow Some cameras post inaccurate frame where next frame data overlap it. this results in screen flicker, and it need to be prevented. So this patch marks the buffer error to discard the frame where buffer overflow. Signed-off-by: Baoyou Xie Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index f4ace6352520b..73cd44e8bd81f 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1077,6 +1077,7 @@ static void uvc_video_decode_data(struct uvc_streaming *stream, /* Complete the current frame if the buffer size was exceeded. */ if (len > maxlen) { uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n"); + buf->error = 1; buf->state = UVC_BUF_STATE_READY; } } -- GitLab From 0393e735649dc41358adb7b603bd57dad1ed3260 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 17 Oct 2017 13:15:54 -0400 Subject: [PATCH 0071/1190] media: uvcvideo: Stream error events carry no data According to the UVC specification, stream error events carry no data. Fix a buffer overflow (that should be harmless given data alignment) when reporting the stream error event by removing the data byte from the message. Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_status.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c index f552ab9979568..1ef20e74b7aca 100644 --- a/drivers/media/usb/uvc/uvc_status.c +++ b/drivers/media/usb/uvc/uvc_status.c @@ -93,8 +93,9 @@ static void uvc_event_streaming(struct uvc_device *dev, __u8 *data, int len) data[1], data[3] ? "pressed" : "released", len); uvc_input_report_key(dev, KEY_CAMERA, data[3]); } else { - uvc_trace(UVC_TRACE_STATUS, "Stream %u error event %02x %02x " - "len %d.\n", data[1], data[2], data[3], len); + uvc_trace(UVC_TRACE_STATUS, + "Stream %u error event %02x len %d.\n", + data[1], data[2], len); } } -- GitLab From e20a8e771dc66361aecd8e23eef3de6048604ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 2 Nov 2017 21:25:24 +0100 Subject: [PATCH 0072/1190] platform/x86: dell-laptop: Fix keyboard max lighting for Dell Latitude E6410 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This machine reports number of keyboard backlight led levels, instead of value of the last led level index. Therefore max_brightness properly needs to be subtracted by 1 to match led max_brightness API. Signed-off-by: Pali Rohár Reported-by: Gabriel M. Elder Link: https://bugzilla.kernel.org/show_bug.cgi?id=196913 Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/dell-laptop.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index bf897b1832b18..cd4725e7e0b56 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -37,6 +37,7 @@ struct quirk_entry { u8 touchpad_led; + u8 kbd_led_levels_off_1; int needs_kbd_timeouts; /* @@ -67,6 +68,10 @@ static struct quirk_entry quirk_dell_xps13_9333 = { .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 }, }; +static struct quirk_entry quirk_dell_latitude_e6410 = { + .kbd_led_levels_off_1 = 1, +}; + static struct platform_driver platform_driver = { .driver = { .name = "dell-laptop", @@ -269,6 +274,15 @@ static const struct dmi_system_id dell_quirks[] __initconst = { }, .driver_data = &quirk_dell_xps13_9333, }, + { + .callback = dmi_matched, + .ident = "Dell Latitude E6410", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6410"), + }, + .driver_data = &quirk_dell_latitude_e6410, + }, { } }; @@ -1149,6 +1163,9 @@ static int kbd_get_info(struct kbd_info *info) units = (buffer->output[2] >> 8) & 0xFF; info->levels = (buffer->output[2] >> 16) & 0xFF; + if (quirks && quirks->kbd_led_levels_off_1 && info->levels) + info->levels--; + if (units & BIT(0)) info->seconds = (buffer->output[3] >> 0) & 0xFF; if (units & BIT(1)) -- GitLab From 1e478ac1989314798c3db7a91c44f52854402db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Sat, 11 Nov 2017 23:20:23 +0100 Subject: [PATCH 0073/1190] platform/x86: dell-laptop: Use bool in struct quirk_entry for true/false fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In struct quirk_entry some boolean fields used int, some u8 type. Change them all to bool type. Signed-off-by: Pali Rohár Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/dell-laptop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index cd4725e7e0b56..629d96048b633 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -36,10 +36,10 @@ #include "dell-smbios.h" struct quirk_entry { - u8 touchpad_led; - u8 kbd_led_levels_off_1; + bool touchpad_led; + bool kbd_led_levels_off_1; - int needs_kbd_timeouts; + bool needs_kbd_timeouts; /* * Ordered list of timeouts expressed in seconds. * The list must end with -1 @@ -50,7 +50,7 @@ struct quirk_entry { static struct quirk_entry *quirks; static struct quirk_entry quirk_dell_vostro_v130 = { - .touchpad_led = 1, + .touchpad_led = true, }; static int __init dmi_matched(const struct dmi_system_id *dmi) @@ -64,12 +64,12 @@ static int __init dmi_matched(const struct dmi_system_id *dmi) * is used then BIOS silently set timeout to 0 without any error message. */ static struct quirk_entry quirk_dell_xps13_9333 = { - .needs_kbd_timeouts = 1, + .needs_kbd_timeouts = true, .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 }, }; static struct quirk_entry quirk_dell_latitude_e6410 = { - .kbd_led_levels_off_1 = 1, + .kbd_led_levels_off_1 = true, }; static struct platform_driver platform_driver = { -- GitLab From 1c828496228deb7a080362bbdf8e70c50bc924b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 9 Nov 2017 23:44:32 +0100 Subject: [PATCH 0074/1190] platform/x86: intel-vbtn: support SW_TABLET_MODE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Event code 0xcc is emitted by several convertibles (Dell XPS 12 9Q33 BIOS A8, Dell XPS 13 2in1 9365, HP Spectre x360, Lenovo Thinkpad Helix) when entering tablet mode, and 0xcd on return to laptop mode. Signed-off-by: Stefan Brüns Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/intel-vbtn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index 58c5ff36523ab..ae55be91a64bc 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -42,6 +42,8 @@ static const struct key_entry intel_vbtn_keymap[] = { { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */ { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */ { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */ + { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Tablet */ + { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Laptop */ { KE_END }, }; -- GitLab From 95f38fd46cc5e45a0d5224f486e805d17ea3d93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 9 Nov 2017 23:44:33 +0100 Subject: [PATCH 0075/1190] platform/x86: intel-vbtn: Support separate press/release events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently all key events use autorelease, but this forbids use as a modifier key. As all event codes come in even/odd pairs, we can lookup the key type (KE_KEY/KE_IGNORE) for the key up event corresponding to the currently handled key down event. If the key up is ignored, we keep setting the autorelease flag for the key down. Signed-off-by: Stefan Brüns Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/intel-vbtn.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index ae55be91a64bc..e3f6375af85c3 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -76,14 +76,27 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) { struct platform_device *device = context; struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); + const struct key_entry *ke_rel; + bool autorelease; if (priv->wakeup_mode) { if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) { pm_wakeup_hard_event(&device->dev); return; } - } else if (sparse_keymap_report_event(priv->input_dev, event, 1, true)) { - return; + } else { + /* Use the fact press/release come in even/odd pairs */ + if ((event & 1) && sparse_keymap_report_event(priv->input_dev, + event, 0, false)) + return; + + ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev, + event | 1); + autorelease = !ke_rel || ke_rel->type == KE_IGNORE; + + if (sparse_keymap_report_event(priv->input_dev, event, 1, + autorelease)) + return; } dev_dbg(&device->dev, "unknown event index 0x%x\n", event); } -- GitLab From 4982327ff6755377a8a66e84113f496f3a6c53bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 9 Nov 2017 23:44:34 +0100 Subject: [PATCH 0076/1190] Input: add KEY_ROTATE_LOCK_TOGGLE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The key has the same use as the SW_ROTATE_LOCK, but is used on devices where the state is not tracked by the hardware but has to be handled in software. Signed-off-by: Stefan Brüns Signed-off-by: Darren Hart (VMware) --- include/uapi/linux/input-event-codes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 061fa62958a22..53fbae27b280c 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -594,6 +594,7 @@ #define BTN_DPAD_RIGHT 0x223 #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ +#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ -- GitLab From 3d5d95d316b6fb3863a633293beb4e1e69dc7693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 9 Nov 2017 23:44:35 +0100 Subject: [PATCH 0077/1190] platform/x86: intel-vbtn: support KEY_ROTATE_LOCK_TOGGLE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Rotate Lock button event is emitted on the XPS 12 (BIOS A8, but not on BIOS A2). Signed-off-by: Stefan Brüns Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/intel-vbtn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index e3f6375af85c3..a484bcc6393b7 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -42,6 +42,8 @@ static const struct key_entry intel_vbtn_keymap[] = { { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */ { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */ { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */ + { KE_KEY, 0xC8, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key press */ + { KE_KEY, 0xC9, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key release */ { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Tablet */ { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Laptop */ { KE_END }, -- GitLab From 9678d0ef77d71a25e2194606238d9cb5b544c0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 9 Nov 2017 23:44:36 +0100 Subject: [PATCH 0078/1190] platform/x86: intel-vbtn: support panel front button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Lenovo Helix 2 and Dell XPS 12 (9Q33) have an extra button on the front showing a 'Windows' logo, both reporting event codes 0xC2/0xC3 on press/release. On the Dell, both press/release are distinct events while on the Helix 2 both events are generated on release. Tested on XPS 12, for info on the Helix 2 see: https://www.spinics.net/lists/ibm-acpi-devel/msg03982.html Signed-off-by: Stefan Brüns Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/intel-vbtn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index a484bcc6393b7..0861efe490d02 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -38,6 +38,8 @@ static const struct acpi_device_id intel_vbtn_ids[] = { static const struct key_entry intel_vbtn_keymap[] = { { KE_KEY, 0xC0, { KEY_POWER } }, /* power key press */ { KE_IGNORE, 0xC1, { KEY_POWER } }, /* power key release */ + { KE_KEY, 0xC2, { KEY_LEFTMETA } }, /* 'Windows' key press */ + { KE_KEY, 0xC3, { KEY_LEFTMETA } }, /* 'Windows' key release */ { KE_KEY, 0xC4, { KEY_VOLUMEUP } }, /* volume-up key press */ { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */ { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */ -- GitLab From 20835280ce0495f933bc8a69f2faac31f23daa2f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:08 -0500 Subject: [PATCH 0079/1190] media: rc: add SPDX identifiers to the code I wrote As we're now using SPDX identifiers, on the several media drivers I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Philippe Ombredanne Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-nec-decoder.c | 19 ++++----------- drivers/media/rc/ir-rc5-decoder.c | 21 +++++----------- drivers/media/rc/ir-sanyo-decoder.c | 37 +++++++++++------------------ drivers/media/rc/rc-core-priv.h | 18 ++++---------- drivers/media/rc/rc-ir-raw.c | 17 ++++--------- drivers/media/rc/rc-main.c | 19 ++++----------- 6 files changed, 38 insertions(+), 93 deletions(-) diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c index 6880c190dcd25..22eed9505244f 100644 --- a/drivers/media/rc/ir-nec-decoder.c +++ b/drivers/media/rc/ir-nec-decoder.c @@ -1,16 +1,7 @@ -/* ir-nec-decoder.c - handle NEC IR Pulse/Space protocol - * - * Copyright (C) 2010 by Mauro Carvalho Chehab - * - * 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 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// ir-nec-decoder.c - handle NEC IR Pulse/Space protocol +// +// Copyright (C) 2010 by Mauro Carvalho Chehab #include #include @@ -281,7 +272,7 @@ static void __exit ir_nec_decode_exit(void) module_init(ir_nec_decode_init); module_exit(ir_nec_decode_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Mauro Carvalho Chehab"); MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); MODULE_DESCRIPTION("NEC IR protocol decoder"); diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c index 1292f534de434..cbff3e26d481c 100644 --- a/drivers/media/rc/ir-rc5-decoder.c +++ b/drivers/media/rc/ir-rc5-decoder.c @@ -1,17 +1,8 @@ -/* ir-rc5-decoder.c - decoder for RC5(x) and StreamZap protocols - * - * Copyright (C) 2010 by Mauro Carvalho Chehab - * Copyright (C) 2010 by Jarod Wilson - * - * 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 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// ir-rc5-decoder.c - decoder for RC5(x) and StreamZap protocols +// +// Copyright (C) 2010 by Mauro Carvalho Chehab +// Copyright (C) 2010 by Jarod Wilson /* * This decoder handles the 14 bit RC5 protocol, 15 bit "StreamZap" protocol @@ -300,7 +291,7 @@ static void __exit ir_rc5_decode_exit(void) module_init(ir_rc5_decode_init); module_exit(ir_rc5_decode_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Mauro Carvalho Chehab and Jarod Wilson"); MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); MODULE_DESCRIPTION("RC5(x/sz) IR protocol decoder"); diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c index d94e07b02f3b0..2138f0e9472d7 100644 --- a/drivers/media/rc/ir-sanyo-decoder.c +++ b/drivers/media/rc/ir-sanyo-decoder.c @@ -1,25 +1,16 @@ -/* ir-sanyo-decoder.c - handle SANYO IR Pulse/Space protocol - * - * Copyright (C) 2011 by Mauro Carvalho Chehab - * - * 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 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. - * - * This protocol uses the NEC protocol timings. However, data is formatted as: - * 13 bits Custom Code - * 13 bits NOT(Custom Code) - * 8 bits Key data - * 8 bits NOT(Key data) - * - * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon - * Information for this protocol is available at the Sanyo LC7461 datasheet. - */ +// SPDX-License-Identifier: GPL-2.0 +// ir-sanyo-decoder.c - handle SANYO IR Pulse/Space protocol +// +// Copyright (C) 2011 by Mauro Carvalho Chehab +// +// This protocol uses the NEC protocol timings. However, data is formatted as: +// 13 bits Custom Code +// 13 bits NOT(Custom Code) +// 8 bits Key data +// 8 bits NOT(Key data) +// +// According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon +// Information for this protocol is available at the Sanyo LC7461 datasheet. #include #include @@ -236,7 +227,7 @@ static void __exit ir_sanyo_decode_exit(void) module_init(ir_sanyo_decode_init); module_exit(ir_sanyo_decode_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Mauro Carvalho Chehab"); MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); MODULE_DESCRIPTION("SANYO IR protocol decoder"); diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index ae4dd0c277310..564d6e13585e5 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -1,17 +1,7 @@ -/* - * Remote Controller core raw events header - * - * Copyright (C) 2010 by Mauro Carvalho Chehab - * - * 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 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// Remote Controller core raw events header +// +// Copyright (C) 2010 by Mauro Carvalho Chehab #ifndef _RC_CORE_PRIV #define _RC_CORE_PRIV diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index d78483a504c9f..0616eee564a89 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -1,16 +1,7 @@ -/* rc-ir-raw.c - handle IR pulse/space events - * - * Copyright (C) 2010 by Mauro Carvalho Chehab - * - * 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 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// rc-ir-raw.c - handle IR pulse/space events +// +// Copyright (C) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index c144b77eac987..372f4d61cb485 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1,16 +1,7 @@ -/* rc-main.c - Remote Controller core module - * - * Copyright (C) 2009-2010 by Mauro Carvalho Chehab - * - * 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 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// rc-main.c - Remote Controller core module +// +// Copyright (C) 2009-2010 by Mauro Carvalho Chehab #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -1905,4 +1896,4 @@ EXPORT_SYMBOL_GPL(rc_core_debug); module_param_named(debug, rc_core_debug, int, 0644); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); -- GitLab From 0c20e8cac2bf7d0b215bff887b7cc805e9273edd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:09 -0500 Subject: [PATCH 0080/1190] media: tuners: add SPDX identifiers to the code I wrote As we're now using SPDX identifiers, on the several media drivers I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Philippe Ombredanne Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 56 +++++++++-------------- drivers/media/tuners/tea5761.c | 15 +++--- drivers/media/tuners/tea5767.c | 21 ++++----- drivers/media/tuners/tuner-xc2028-types.h | 5 +- drivers/media/tuners/tuner-xc2028.c | 18 ++++---- drivers/media/tuners/tuner-xc2028.h | 5 +- 6 files changed, 51 insertions(+), 69 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index ba80376a3b864..69a507f355b59 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -1,36 +1,24 @@ -/* - * Rafael Micro R820T driver - * - * Copyright (C) 2013 Mauro Carvalho Chehab - * - * This driver was written from scratch, based on an existing driver - * that it is part of rtl-sdr git tree, released under GPLv2: - * https://groups.google.com/forum/#!topic/ultra-cheap-sdr/Y3rBEOFtHug - * https://github.com/n1gp/gr-baz - * - * From what I understood from the threads, the original driver was converted - * to userspace from a Realtek tree. I couldn't find the original tree. - * However, the original driver look awkward on my eyes. So, I decided to - * write a new version from it from the scratch, while trying to reproduce - * everything found there. - * - * TODO: - * After locking, the original driver seems to have some routines to - * improve reception. This was not implemented here yet. - * - * RF Gain set/get is not implemented. - * - * 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. - * - */ +// SPDX-License-Identifier: GPL-2.0 +// Rafael Micro R820T driver +// +// Copyright (C) 2013 Mauro Carvalho Chehab +// +// This driver was written from scratch, based on an existing driver +// that it is part of rtl-sdr git tree, released under GPLv2: +// https://groups.google.com/forum/#!topic/ultra-cheap-sdr/Y3rBEOFtHug +// https://github.com/n1gp/gr-baz +// +// From what I understood from the threads, the original driver was converted +// to userspace from a Realtek tree. I couldn't find the original tree. +// However, the original driver look awkward on my eyes. So, I decided to +// write a new version from it from the scratch, while trying to reproduce +// everything found there. +// +// TODO: +// After locking, the original driver seems to have some routines to +// improve reception. This was not implemented here yet. +// +// RF Gain set/get is not implemented. #include #include @@ -2388,4 +2376,4 @@ EXPORT_SYMBOL_GPL(r820t_attach); MODULE_DESCRIPTION("Rafael Micro r820t silicon tuner driver"); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/tuners/tea5761.c b/drivers/media/tuners/tea5761.c index a9b1bb134409e..88b3e80c38ad9 100644 --- a/drivers/media/tuners/tea5761.c +++ b/drivers/media/tuners/tea5761.c @@ -1,11 +1,8 @@ -/* - * For Philips TEA5761 FM Chip - * I2C address is allways 0x20 (0x10 at 7-bit mode). - * - * Copyright (c) 2005-2007 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNUv2 General Public License - * - */ +// SPDX-License-Identifier: GPL-2.0 +// For Philips TEA5761 FM Chip +// I2C address is always 0x20 (0x10 at 7-bit mode). +// +// Copyright (c) 2005-2007 Mauro Carvalho Chehab (mchehab@infradead.org) #include #include @@ -341,4 +338,4 @@ EXPORT_SYMBOL_GPL(tea5761_autodetection); MODULE_DESCRIPTION("Philips TEA5761 FM tuner driver"); MODULE_AUTHOR("Mauro Carvalho Chehab "); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/tuners/tea5767.c b/drivers/media/tuners/tea5767.c index 525b7ab90c803..2b2c064d7dc36 100644 --- a/drivers/media/tuners/tea5767.c +++ b/drivers/media/tuners/tea5767.c @@ -1,14 +1,11 @@ -/* - * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview - * I2C address is allways 0xC0. - * - * - * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNU General Public License - * - * tea5767 autodetection thanks to Torsten Seeboth and Atsushi Nakagawa - * from their contributions on DScaler. - */ +// SPDX-License-Identifier: GPL-2.0 +// For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview +// I2C address is always 0xC0. +// +// Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@infradead.org) +// +// tea5767 autodetection thanks to Torsten Seeboth and Atsushi Nakagawa +// from their contributions on DScaler. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -473,4 +470,4 @@ EXPORT_SYMBOL_GPL(tea5767_autodetection); MODULE_DESCRIPTION("Philips TEA5767 FM tuner driver"); MODULE_AUTHOR("Mauro Carvalho Chehab "); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/tuners/tuner-xc2028-types.h b/drivers/media/tuners/tuner-xc2028-types.h index 7e4798783db73..bb0437c36c03b 100644 --- a/drivers/media/tuners/tuner-xc2028-types.h +++ b/drivers/media/tuners/tuner-xc2028-types.h @@ -1,10 +1,11 @@ -/* tuner-xc2028_types +/* + * SPDX-License-Identifier: GPL-2.0 + * tuner-xc2028_types * * This file includes internal tipes to be used inside tuner-xc2028. * Shouldn't be included outside tuner-xc2028 * * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNU General Public License v2 */ /* xc3028 firmware types */ diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c index b5b62b08159e0..ae739f842c2de 100644 --- a/drivers/media/tuners/tuner-xc2028.c +++ b/drivers/media/tuners/tuner-xc2028.c @@ -1,12 +1,10 @@ -/* tuner-xc2028 - * - * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) - * - * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com) - * - frontend interface - * - * This code is placed under the terms of the GNU General Public License v2 - */ +// SPDX-License-Identifier: GPL-2.0 +// tuner-xc2028 +// +// Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) +// +// Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com) +// - frontend interface #include #include @@ -1521,6 +1519,6 @@ EXPORT_SYMBOL(xc2028_attach); MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); MODULE_AUTHOR("Michel Ludwig "); MODULE_AUTHOR("Mauro Carvalho Chehab "); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_FIRMWARE(XC2028_DEFAULT_FIRMWARE); MODULE_FIRMWARE(XC3028L_DEFAULT_FIRMWARE); diff --git a/drivers/media/tuners/tuner-xc2028.h b/drivers/media/tuners/tuner-xc2028.h index 98e4effca8964..d8378f9960a55 100644 --- a/drivers/media/tuners/tuner-xc2028.h +++ b/drivers/media/tuners/tuner-xc2028.h @@ -1,7 +1,8 @@ -/* tuner-xc2028 +/* + * SPDX-License-Identifier: GPL-2.0 + * tuner-xc2028 * * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNU General Public License v2 */ #ifndef __TUNER_XC2028_H__ -- GitLab From 75d1e3ef9f98145acff7e558dfe2a175f1e4db9e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:10 -0500 Subject: [PATCH 0081/1190] media: usb: add SPDX identifiers to some code I wrote As we're now using SPDX identifiers, on several media drivers I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Philippe Ombredanne Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-input.c | 25 ++++++------------- drivers/media/usb/cx231xx/cx231xx-input.c | 28 +++++++--------------- drivers/media/usb/tm6000/tm6000-alsa.c | 18 +++++--------- drivers/media/usb/tm6000/tm6000-cards.c | 20 ++++------------ drivers/media/usb/tm6000/tm6000-core.c | 24 ++++++------------- drivers/media/usb/tm6000/tm6000-i2c.c | 24 ++++++------------- drivers/media/usb/tm6000/tm6000-regs.h | 18 ++++---------- drivers/media/usb/tm6000/tm6000-stds.c | 18 ++++---------- drivers/media/usb/tm6000/tm6000-usb-isoc.h | 18 ++++---------- drivers/media/usb/tm6000/tm6000-video.c | 24 ++++++------------- drivers/media/usb/tm6000/tm6000.h | 24 ++++++------------- 11 files changed, 67 insertions(+), 174 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c index af68afe085b55..832ed9f257845 100644 --- a/drivers/media/usb/au0828/au0828-input.c +++ b/drivers/media/usb/au0828/au0828-input.c @@ -1,21 +1,10 @@ -/* - handle au0828 IR remotes via linux kernel input layer. - - Copyright (C) 2014 Mauro Carvalho Chehab - Copyright (c) 2014 Samsung Electronics Co., Ltd. - - Based on em28xx-input.c. - - 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// handle au0828 IR remotes via linux kernel input layer. +// +// Copyright (c) 2014 Mauro Carvalho Chehab +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Based on em28xx-input.c. #include "au0828.h" diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c index 02ebeb16055f2..3e9b73a6b7c93 100644 --- a/drivers/media/usb/cx231xx/cx231xx-input.c +++ b/drivers/media/usb/cx231xx/cx231xx-input.c @@ -1,22 +1,12 @@ -/* - * cx231xx IR glue driver - * - * Copyright (C) 2010 Mauro Carvalho Chehab - * - * Polaris (cx231xx) has its support for IR's with a design close to MCE. - * however, a few designs are using an external I2C chip for IR, instead - * of using the one provided by the chip. - * This driver provides support for those extra devices - * - * 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. - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// cx231xx IR glue driver +// +// Copyright (c) 2010 Mauro Carvalho Chehab +// +// Polaris (cx231xx) has its support for IR's with a design close to MCE. +// however, a few designs are using an external I2C chip for IR, instead +// of using the one provided by the chip. +// This driver provides support for those extra devices #include "cx231xx.h" #include diff --git a/drivers/media/usb/tm6000/tm6000-alsa.c b/drivers/media/usb/tm6000/tm6000-alsa.c index 3717a6844ea8e..f18cffae4c85a 100644 --- a/drivers/media/usb/tm6000/tm6000-alsa.c +++ b/drivers/media/usb/tm6000/tm6000-alsa.c @@ -1,14 +1,8 @@ -/* - * - * Support for audio capture for tm5600/6000/6010 - * (c) 2007-2008 Mauro Carvalho Chehab - * - * Based on cx88-alsa.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ +// SPDX-License-Identifier: GPL-2.0 +// Support for audio capture for tm5600/6000/6010 +// Copyright (c) 2007-2008 Mauro Carvalho Chehab +// +// Based on cx88-alsa.c #include #include @@ -57,7 +51,7 @@ MODULE_PARM_DESC(index, "Index value for tm6000x capture interface(s)."); MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards"); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_SUPPORTED_DEVICE("{{Trident,tm5600},{{Trident,tm6000},{{Trident,tm6010}"); static unsigned int debug; module_param(debug, int, 0644); diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c index 77347541904df..8d2aa63f9b947 100644 --- a/drivers/media/usb/tm6000/tm6000-cards.c +++ b/drivers/media/usb/tm6000/tm6000-cards.c @@ -1,17 +1,7 @@ -/* - * tm6000-cards.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-cards.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab #include #include @@ -1405,4 +1395,4 @@ module_usb_driver(tm6000_usb_driver); MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000/TM6010 USB2 adapter"); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c index 8c265bd80faa7..23a1332d98e62 100644 --- a/drivers/media/usb/tm6000/tm6000-core.c +++ b/drivers/media/usb/tm6000/tm6000-core.c @@ -1,20 +1,10 @@ -/* - * tm6000-core.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * Copyright (C) 2007 Michel Ludwig - * - DVB-T support - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-core.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab +// +// Copyright (c) 2007 Michel Ludwig +// - DVB-T support #include #include diff --git a/drivers/media/usb/tm6000/tm6000-i2c.c b/drivers/media/usb/tm6000/tm6000-i2c.c index cbcc1472f1c75..c9a62bbff27a2 100644 --- a/drivers/media/usb/tm6000/tm6000-i2c.c +++ b/drivers/media/usb/tm6000/tm6000-i2c.c @@ -1,20 +1,10 @@ -/* - * tm6000-i2c.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * Copyright (C) 2007 Michel Ludwig - * - Fix SMBus Read Byte command - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-i2c.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab +// +// Copyright (c) 2007 Michel Ludwig +// - Fix SMBus Read Byte command #include #include diff --git a/drivers/media/usb/tm6000/tm6000-regs.h b/drivers/media/usb/tm6000/tm6000-regs.h index ab3fb74c476c5..6723e373fdc61 100644 --- a/drivers/media/usb/tm6000/tm6000-regs.h +++ b/drivers/media/usb/tm6000/tm6000-regs.h @@ -1,17 +1,7 @@ -/* - * tm6000-regs.h - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-regs.h - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab /* * Define TV Master TM5600/TM6000/TM6010 Request codes diff --git a/drivers/media/usb/tm6000/tm6000-stds.c b/drivers/media/usb/tm6000/tm6000-stds.c index aa43810d17f97..c0c75951246b0 100644 --- a/drivers/media/usb/tm6000/tm6000-stds.c +++ b/drivers/media/usb/tm6000/tm6000-stds.c @@ -1,17 +1,7 @@ -/* - * tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2007 Mauro Carvalho Chehab - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2007 Mauro Carvalho Chehab #include #include diff --git a/drivers/media/usb/tm6000/tm6000-usb-isoc.h b/drivers/media/usb/tm6000/tm6000-usb-isoc.h index 6a13a27c55d7e..e69f5cf8fe9f1 100644 --- a/drivers/media/usb/tm6000/tm6000-usb-isoc.h +++ b/drivers/media/usb/tm6000/tm6000-usb-isoc.h @@ -1,17 +1,7 @@ -/* - * tm6000-buf.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-buf.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab #include diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c index 9fa25de6b5a95..a95ea629b2033 100644 --- a/drivers/media/usb/tm6000/tm6000-video.c +++ b/drivers/media/usb/tm6000/tm6000-video.c @@ -1,20 +1,10 @@ -/* - * tm6000-video.c - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * Copyright (C) 2007 Michel Ludwig - * - Fixed module load/unload - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000-video.c - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab +// +// Copyright (c) 2007 Michel Ludwig +// - Fixed module load/unload #include #include diff --git a/drivers/media/usb/tm6000/tm6000.h b/drivers/media/usb/tm6000/tm6000.h index 7ec478d75f55e..d53c8e1068e8e 100644 --- a/drivers/media/usb/tm6000/tm6000.h +++ b/drivers/media/usb/tm6000/tm6000.h @@ -1,20 +1,10 @@ -/* - * tm6000.h - driver for TM5600/TM6000/TM6010 USB video capture devices - * - * Copyright (C) 2006-2007 Mauro Carvalho Chehab - * - * Copyright (C) 2007 Michel Ludwig - * - DVB-T support - * - * 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 - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0 +// tm6000.h - driver for TM5600/TM6000/TM6010 USB video capture devices +// +// Copyright (c) 2006-2007 Mauro Carvalho Chehab +// +// Copyright (c) 2007 Michel Ludwig +// - DVB-T support #include #include -- GitLab From 688c73c64d1acdb73565656dd2ea1cf8a4e5b2a3 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:11 -0500 Subject: [PATCH 0082/1190] media: rc keymaps: add SPDX identifiers to the code I wrote As we're now using SPDX identifiers, on the several RC keymap files I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to identify GPL v2, as this is the minimal license requirement for those modles. Signed-off-by: Mauro Carvalho Chehab --- .../media/rc/keymaps/rc-adstech-dvb-t-pci.c | 17 ++++------- drivers/media/rc/keymaps/rc-apac-viewcomp.c | 17 ++++------- drivers/media/rc/keymaps/rc-asus-pc39.c | 17 ++++------- drivers/media/rc/keymaps/rc-asus-ps3-100.c | 17 ++++------- .../rc/keymaps/rc-ati-tv-wonder-hd-600.c | 17 ++++------- drivers/media/rc/keymaps/rc-avermedia-a16d.c | 17 ++++------- .../media/rc/keymaps/rc-avermedia-cardbus.c | 17 ++++------- drivers/media/rc/keymaps/rc-avermedia-dvbt.c | 17 ++++------- drivers/media/rc/keymaps/rc-avermedia-m135a.c | 15 ++++------ drivers/media/rc/keymaps/rc-avermedia.c | 17 ++++------- drivers/media/rc/keymaps/rc-avertv-303.c | 17 ++++------- drivers/media/rc/keymaps/rc-behold-columbus.c | 17 ++++------- drivers/media/rc/keymaps/rc-behold.c | 17 ++++------- drivers/media/rc/keymaps/rc-budget-ci-old.c | 17 ++++------- drivers/media/rc/keymaps/rc-cinergy-1400.c | 17 ++++------- drivers/media/rc/keymaps/rc-cinergy.c | 17 ++++------- drivers/media/rc/keymaps/rc-dib0700-nec.c | 27 +++++++---------- drivers/media/rc/keymaps/rc-dib0700-rc5.c | 27 +++++++---------- drivers/media/rc/keymaps/rc-dm1105-nec.c | 17 ++++------- drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c | 17 ++++------- .../media/rc/keymaps/rc-dntv-live-dvbt-pro.c | 17 ++++------- drivers/media/rc/keymaps/rc-em-terratec.c | 17 ++++------- .../media/rc/keymaps/rc-encore-enltv-fm53.c | 17 ++++------- drivers/media/rc/keymaps/rc-encore-enltv.c | 17 ++++------- drivers/media/rc/keymaps/rc-encore-enltv2.c | 17 ++++------- drivers/media/rc/keymaps/rc-evga-indtube.c | 17 ++++------- drivers/media/rc/keymaps/rc-eztv.c | 17 ++++------- drivers/media/rc/keymaps/rc-flydvb.c | 17 ++++------- drivers/media/rc/keymaps/rc-flyvideo.c | 17 ++++------- drivers/media/rc/keymaps/rc-fusionhdtv-mce.c | 17 ++++------- drivers/media/rc/keymaps/rc-gadmei-rm008z.c | 17 ++++------- .../media/rc/keymaps/rc-genius-tvgo-a11mce.c | 17 ++++------- drivers/media/rc/keymaps/rc-gotview7135.c | 17 ++++------- drivers/media/rc/keymaps/rc-hauppauge.c | 29 ++++++++----------- drivers/media/rc/keymaps/rc-iodata-bctv7e.c | 17 ++++------- drivers/media/rc/keymaps/rc-kaiomy.c | 17 ++++------- drivers/media/rc/keymaps/rc-kworld-315u.c | 17 ++++------- .../rc/keymaps/rc-kworld-plus-tv-analog.c | 17 ++++------- drivers/media/rc/keymaps/rc-manli.c | 17 ++++------- .../media/rc/keymaps/rc-msi-tvanywhere-plus.c | 17 ++++------- drivers/media/rc/keymaps/rc-msi-tvanywhere.c | 17 ++++------- drivers/media/rc/keymaps/rc-nebula.c | 17 ++++------- .../rc/keymaps/rc-nec-terratec-cinergy-xs.c | 17 ++++------- drivers/media/rc/keymaps/rc-norwood.c | 17 ++++------- drivers/media/rc/keymaps/rc-npgtech.c | 17 ++++------- drivers/media/rc/keymaps/rc-pctv-sedna.c | 17 ++++------- drivers/media/rc/keymaps/rc-pinnacle-color.c | 17 ++++------- drivers/media/rc/keymaps/rc-pinnacle-grey.c | 17 ++++------- .../media/rc/keymaps/rc-pinnacle-pctv-hd.c | 17 ++++------- drivers/media/rc/keymaps/rc-pixelview-002t.c | 17 ++++------- drivers/media/rc/keymaps/rc-pixelview-mk12.c | 17 ++++------- drivers/media/rc/keymaps/rc-pixelview-new.c | 17 ++++------- drivers/media/rc/keymaps/rc-pixelview.c | 17 ++++------- .../rc/keymaps/rc-powercolor-real-angel.c | 17 ++++------- drivers/media/rc/keymaps/rc-proteus-2309.c | 17 ++++------- drivers/media/rc/keymaps/rc-purpletv.c | 17 ++++------- drivers/media/rc/keymaps/rc-pv951.c | 17 ++++------- .../rc/keymaps/rc-real-audio-220-32-keys.c | 17 ++++------- drivers/media/rc/keymaps/rc-tbs-nec.c | 17 ++++------- .../media/rc/keymaps/rc-terratec-cinergy-xs.c | 17 ++++------- drivers/media/rc/keymaps/rc-tevii-nec.c | 17 ++++------- drivers/media/rc/keymaps/rc-tt-1500.c | 17 ++++------- drivers/media/rc/keymaps/rc-videomate-s350.c | 17 ++++------- .../media/rc/keymaps/rc-videomate-tv-pvr.c | 17 ++++------- .../rc/keymaps/rc-winfast-usbii-deluxe.c | 17 ++++------- drivers/media/rc/keymaps/rc-winfast.c | 17 ++++------- 66 files changed, 411 insertions(+), 741 deletions(-) diff --git a/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c b/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c index 2d303c2cee3b0..732687ce06375 100644 --- a/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c +++ b/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c @@ -1,14 +1,9 @@ -/* adstech-dvb-t-pci.h - Keytable for adstech_dvb_t_pci Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// adstech-dvb-t-pci.h - Keytable for adstech_dvb_t_pci Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-apac-viewcomp.c b/drivers/media/rc/keymaps/rc-apac-viewcomp.c index 65bc8957d9c32..af2e7fdc7b85d 100644 --- a/drivers/media/rc/keymaps/rc-apac-viewcomp.c +++ b/drivers/media/rc/keymaps/rc-apac-viewcomp.c @@ -1,14 +1,9 @@ -/* apac-viewcomp.h - Keytable for apac_viewcomp Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// apac-viewcomp.h - Keytable for apac_viewcomp Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-asus-pc39.c b/drivers/media/rc/keymaps/rc-asus-pc39.c index 530e1d1158d1f..13a935c3ac59f 100644 --- a/drivers/media/rc/keymaps/rc-asus-pc39.c +++ b/drivers/media/rc/keymaps/rc-asus-pc39.c @@ -1,14 +1,9 @@ -/* asus-pc39.h - Keytable for asus_pc39 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// asus-pc39.h - Keytable for asus_pc39 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-asus-ps3-100.c b/drivers/media/rc/keymaps/rc-asus-ps3-100.c index c91ba332984cb..7f836fcc68ace 100644 --- a/drivers/media/rc/keymaps/rc-asus-ps3-100.c +++ b/drivers/media/rc/keymaps/rc-asus-ps3-100.c @@ -1,14 +1,9 @@ -/* asus-ps3-100.h - Keytable for asus_ps3_100 Remote Controller - * - * Copyright (c) 2012 by Mauro Carvalho Chehab - * - * Based on a previous patch from Remi Schwartz - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// asus-ps3-100.h - Keytable for asus_ps3_100 Remote Controller +// +// Copyright (c) 2012 by Mauro Carvalho Chehab +// +// Based on a previous patch from Remi Schwartz #include #include diff --git a/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c b/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c index 11b4bdd2392b2..b4b7932c0c5a1 100644 --- a/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c +++ b/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c @@ -1,14 +1,9 @@ -/* ati-tv-wonder-hd-600.h - Keytable for ati_tv_wonder_hd_600 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// ati-tv-wonder-hd-600.h - Keytable for ati_tv_wonder_hd_600 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-avermedia-a16d.c b/drivers/media/rc/keymaps/rc-avermedia-a16d.c index 510dc90ebf49c..5549c043cfe4a 100644 --- a/drivers/media/rc/keymaps/rc-avermedia-a16d.c +++ b/drivers/media/rc/keymaps/rc-avermedia-a16d.c @@ -1,14 +1,9 @@ -/* avermedia-a16d.h - Keytable for avermedia_a16d Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avermedia-a16d.h - Keytable for avermedia_a16d Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c index 4bbc1e68d1b87..74edcd82e6853 100644 --- a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c +++ b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c @@ -1,14 +1,9 @@ -/* avermedia-cardbus.h - Keytable for avermedia_cardbus Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avermedia-cardbus.h - Keytable for avermedia_cardbus Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c index f6b8547dbad34..796184160a48b 100644 --- a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c +++ b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c @@ -1,14 +1,9 @@ -/* avermedia-dvbt.h - Keytable for avermedia_dvbt Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avermedia-dvbt.h - Keytable for avermedia_dvbt Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-avermedia-m135a.c b/drivers/media/rc/keymaps/rc-avermedia-m135a.c index 6d5a73b7ccecf..f6977df1a75ba 100644 --- a/drivers/media/rc/keymaps/rc-avermedia-m135a.c +++ b/drivers/media/rc/keymaps/rc-avermedia-m135a.c @@ -1,13 +1,8 @@ -/* avermedia-m135a.c - Keytable for Avermedia M135A Remote Controllers - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * Copyright (c) 2010 by Herton Ronaldo Krzesinski - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avermedia-m135a.c - Keytable for Avermedia M135A Remote Controllers +// +// Copyright (c) 2010 by Mauro Carvalho Chehab +// Copyright (c) 2010 by Herton Ronaldo Krzesinski #include #include diff --git a/drivers/media/rc/keymaps/rc-avermedia.c b/drivers/media/rc/keymaps/rc-avermedia.c index 6503f11c7df5f..631ff52564f02 100644 --- a/drivers/media/rc/keymaps/rc-avermedia.c +++ b/drivers/media/rc/keymaps/rc-avermedia.c @@ -1,14 +1,9 @@ -/* avermedia.h - Keytable for avermedia Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avermedia.h - Keytable for avermedia Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-avertv-303.c b/drivers/media/rc/keymaps/rc-avertv-303.c index fbdd7ada57ce1..47ca8b7ea532a 100644 --- a/drivers/media/rc/keymaps/rc-avertv-303.c +++ b/drivers/media/rc/keymaps/rc-avertv-303.c @@ -1,14 +1,9 @@ -/* avertv-303.h - Keytable for avertv_303 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// avertv-303.h - Keytable for avertv_303 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-behold-columbus.c b/drivers/media/rc/keymaps/rc-behold-columbus.c index d256743be9982..61f679fec45c8 100644 --- a/drivers/media/rc/keymaps/rc-behold-columbus.c +++ b/drivers/media/rc/keymaps/rc-behold-columbus.c @@ -1,14 +1,9 @@ -/* behold-columbus.h - Keytable for behold_columbus Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// behold-columbus.h - Keytable for behold_columbus Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-behold.c b/drivers/media/rc/keymaps/rc-behold.c index 93dc795adc67b..9b1b57e3c875e 100644 --- a/drivers/media/rc/keymaps/rc-behold.c +++ b/drivers/media/rc/keymaps/rc-behold.c @@ -1,14 +1,9 @@ -/* behold.h - Keytable for behold Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// behold.h - Keytable for behold Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-budget-ci-old.c b/drivers/media/rc/keymaps/rc-budget-ci-old.c index 81ea1424d9e5b..56f051af61541 100644 --- a/drivers/media/rc/keymaps/rc-budget-ci-old.c +++ b/drivers/media/rc/keymaps/rc-budget-ci-old.c @@ -1,14 +1,9 @@ -/* budget-ci-old.h - Keytable for budget_ci_old Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// budget-ci-old.h - Keytable for budget_ci_old Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-cinergy-1400.c b/drivers/media/rc/keymaps/rc-cinergy-1400.c index bcb96b3dda858..dacb13c53bb43 100644 --- a/drivers/media/rc/keymaps/rc-cinergy-1400.c +++ b/drivers/media/rc/keymaps/rc-cinergy-1400.c @@ -1,14 +1,9 @@ -/* cinergy-1400.h - Keytable for cinergy_1400 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// cinergy-1400.h - Keytable for cinergy_1400 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-cinergy.c b/drivers/media/rc/keymaps/rc-cinergy.c index fd56c402aae5d..6ab2e51b764d4 100644 --- a/drivers/media/rc/keymaps/rc-cinergy.c +++ b/drivers/media/rc/keymaps/rc-cinergy.c @@ -1,14 +1,9 @@ -/* cinergy.h - Keytable for cinergy Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// cinergy.h - Keytable for cinergy Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-dib0700-nec.c b/drivers/media/rc/keymaps/rc-dib0700-nec.c index 1b4df106b7b58..4ee801acb089e 100644 --- a/drivers/media/rc/keymaps/rc-dib0700-nec.c +++ b/drivers/media/rc/keymaps/rc-dib0700-nec.c @@ -1,19 +1,14 @@ -/* rc-dvb0700-big.c - Keytable for devices in dvb0700 - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * TODO: This table is a real mess, as it merges RC codes from several - * devices into a big table. It also has both RC-5 and NEC codes inside. - * It should be broken into small tables, and the protocols should properly - * be identificated. - * - * The table were imported from dib0700_devices.c. - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// rc-dvb0700-big.c - Keytable for devices in dvb0700 +// +// Copyright (c) 2010 by Mauro Carvalho Chehab +// +// TODO: This table is a real mess, as it merges RC codes from several +// devices into a big table. It also has both RC-5 and NEC codes inside. +// It should be broken into small tables, and the protocols should properly +// be identificated. +// +// The table were imported from dib0700_devices.c. #include #include diff --git a/drivers/media/rc/keymaps/rc-dib0700-rc5.c b/drivers/media/rc/keymaps/rc-dib0700-rc5.c index b0f8151bb824c..ef4085a0fda3d 100644 --- a/drivers/media/rc/keymaps/rc-dib0700-rc5.c +++ b/drivers/media/rc/keymaps/rc-dib0700-rc5.c @@ -1,19 +1,14 @@ -/* rc-dvb0700-big.c - Keytable for devices in dvb0700 - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * TODO: This table is a real mess, as it merges RC codes from several - * devices into a big table. It also has both RC-5 and NEC codes inside. - * It should be broken into small tables, and the protocols should properly - * be identificated. - * - * The table were imported from dib0700_devices.c. - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// rc-dvb0700-big.c - Keytable for devices in dvb0700 +// +// Copyright (c) 2010 by Mauro Carvalho Chehab +// +// TODO: This table is a real mess, as it merges RC codes from several +// devices into a big table. It also has both RC-5 and NEC codes inside. +// It should be broken into small tables, and the protocols should properly +// be identificated. +// +// The table were imported from dib0700_devices.c. #include #include diff --git a/drivers/media/rc/keymaps/rc-dm1105-nec.c b/drivers/media/rc/keymaps/rc-dm1105-nec.c index c353445d10ed5..d853cd9a09368 100644 --- a/drivers/media/rc/keymaps/rc-dm1105-nec.c +++ b/drivers/media/rc/keymaps/rc-dm1105-nec.c @@ -1,14 +1,9 @@ -/* dm1105-nec.h - Keytable for dm1105_nec Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// dm1105-nec.h - Keytable for dm1105_nec Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c b/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c index 5bafd5b70f5ee..cdc1d8c990cb2 100644 --- a/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c +++ b/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c @@ -1,14 +1,9 @@ -/* dntv-live-dvb-t.h - Keytable for dntv_live_dvb_t Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// dntv-live-dvb-t.h - Keytable for dntv_live_dvb_t Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c b/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c index 360167c8829b0..38e1d1b837da8 100644 --- a/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c +++ b/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c @@ -1,14 +1,9 @@ -/* dntv-live-dvbt-pro.h - Keytable for dntv_live_dvbt_pro Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// dntv-live-dvbt-pro.h - Keytable for dntv_live_dvbt_pro Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-em-terratec.c b/drivers/media/rc/keymaps/rc-em-terratec.c index 18e1a2679c20e..cbbba21484fbb 100644 --- a/drivers/media/rc/keymaps/rc-em-terratec.c +++ b/drivers/media/rc/keymaps/rc-em-terratec.c @@ -1,14 +1,9 @@ -/* em-terratec.h - Keytable for em_terratec Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// em-terratec.h - Keytable for em_terratec Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c index 72ffd5cb0108d..e4e78c1f41231 100644 --- a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c +++ b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c @@ -1,14 +1,9 @@ -/* encore-enltv-fm53.h - Keytable for encore_enltv_fm53 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// encore-enltv-fm53.h - Keytable for encore_enltv_fm53 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-encore-enltv.c b/drivers/media/rc/keymaps/rc-encore-enltv.c index e0381e7aa964b..5b4e832d5fac2 100644 --- a/drivers/media/rc/keymaps/rc-encore-enltv.c +++ b/drivers/media/rc/keymaps/rc-encore-enltv.c @@ -1,14 +1,9 @@ -/* encore-enltv.h - Keytable for encore_enltv Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// encore-enltv.h - Keytable for encore_enltv Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-encore-enltv2.c b/drivers/media/rc/keymaps/rc-encore-enltv2.c index e9b0bfba319c9..c3d4437a6fdad 100644 --- a/drivers/media/rc/keymaps/rc-encore-enltv2.c +++ b/drivers/media/rc/keymaps/rc-encore-enltv2.c @@ -1,14 +1,9 @@ -/* encore-enltv2.h - Keytable for encore_enltv2 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// encore-enltv2.h - Keytable for encore_enltv2 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-evga-indtube.c b/drivers/media/rc/keymaps/rc-evga-indtube.c index b77c5e9086682..f4398444330b9 100644 --- a/drivers/media/rc/keymaps/rc-evga-indtube.c +++ b/drivers/media/rc/keymaps/rc-evga-indtube.c @@ -1,14 +1,9 @@ -/* evga-indtube.h - Keytable for evga_indtube Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// evga-indtube.h - Keytable for evga_indtube Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-eztv.c b/drivers/media/rc/keymaps/rc-eztv.c index 5013b3b2aa93a..0e481d51fcb53 100644 --- a/drivers/media/rc/keymaps/rc-eztv.c +++ b/drivers/media/rc/keymaps/rc-eztv.c @@ -1,14 +1,9 @@ -/* eztv.h - Keytable for eztv Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// eztv.h - Keytable for eztv Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-flydvb.c b/drivers/media/rc/keymaps/rc-flydvb.c index 418b325212736..45940d7c92d05 100644 --- a/drivers/media/rc/keymaps/rc-flydvb.c +++ b/drivers/media/rc/keymaps/rc-flydvb.c @@ -1,14 +1,9 @@ -/* flydvb.h - Keytable for flydvb Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// flydvb.h - Keytable for flydvb Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-flyvideo.c b/drivers/media/rc/keymaps/rc-flyvideo.c index 93fb87ecf061c..b2d4e4c7b192e 100644 --- a/drivers/media/rc/keymaps/rc-flyvideo.c +++ b/drivers/media/rc/keymaps/rc-flyvideo.c @@ -1,14 +1,9 @@ -/* flyvideo.h - Keytable for flyvideo Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// flyvideo.h - Keytable for flyvideo Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c index 9ed3f749262bc..1c63fc7d45766 100644 --- a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c +++ b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c @@ -1,14 +1,9 @@ -/* fusionhdtv-mce.h - Keytable for fusionhdtv_mce Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// fusionhdtv-mce.h - Keytable for fusionhdtv_mce Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c index 3443b721d092a..4a0a9786914f5 100644 --- a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c +++ b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c @@ -1,14 +1,9 @@ -/* gadmei-rm008z.h - Keytable for gadmei_rm008z Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// gadmei-rm008z.h - Keytable for gadmei_rm008z Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c index d140e8d45bcc0..cc876a85cc31b 100644 --- a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c +++ b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c @@ -1,14 +1,9 @@ -/* genius-tvgo-a11mce.h - Keytable for genius_tvgo_a11mce Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// genius-tvgo-a11mce.h - Keytable for genius_tvgo_a11mce Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-gotview7135.c b/drivers/media/rc/keymaps/rc-gotview7135.c index 51230fbb52bad..6b94bd39d9771 100644 --- a/drivers/media/rc/keymaps/rc-gotview7135.c +++ b/drivers/media/rc/keymaps/rc-gotview7135.c @@ -1,14 +1,9 @@ -/* gotview7135.h - Keytable for gotview7135 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// gotview7135.h - Keytable for gotview7135 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-hauppauge.c b/drivers/media/rc/keymaps/rc-hauppauge.c index 890164b68d64b..582aa90124434 100644 --- a/drivers/media/rc/keymaps/rc-hauppauge.c +++ b/drivers/media/rc/keymaps/rc-hauppauge.c @@ -1,20 +1,15 @@ -/* rc-hauppauge.c - Keytable for Hauppauge Remote Controllers - * - * keymap imported from ir-keymaps.c - * - * This map currently contains the code for four different RCs: - * - New Hauppauge Gray; - * - Old Hauppauge Gray (with a golden screen for media keys); - * - Hauppauge Black; - * - DSR-0112 remote bundled with Haupauge MiniStick. - * - * Copyright (c) 2010-2011 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// rc-hauppauge.c - Keytable for Hauppauge Remote Controllers +// +// keymap imported from ir-keymaps.c +// +// This map currently contains the code for four different RCs: +// - New Hauppauge Gray; +// - Old Hauppauge Gray (with a golden screen for media keys); +// - Hauppauge Black; +// - DSR-0112 remote bundled with Haupauge MiniStick. +// +// Copyright (c) 2010-2011 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c index 8cf87a15c4f28..6ced43458f2a0 100644 --- a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c +++ b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c @@ -1,14 +1,9 @@ -/* iodata-bctv7e.h - Keytable for iodata_bctv7e Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// iodata-bctv7e.h - Keytable for iodata_bctv7e Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-kaiomy.c b/drivers/media/rc/keymaps/rc-kaiomy.c index e791f1e1b43bb..f0f88df186065 100644 --- a/drivers/media/rc/keymaps/rc-kaiomy.c +++ b/drivers/media/rc/keymaps/rc-kaiomy.c @@ -1,14 +1,9 @@ -/* kaiomy.h - Keytable for kaiomy Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// kaiomy.h - Keytable for kaiomy Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-kworld-315u.c b/drivers/media/rc/keymaps/rc-kworld-315u.c index 71dce0138f0e4..ed0e0586dea2f 100644 --- a/drivers/media/rc/keymaps/rc-kworld-315u.c +++ b/drivers/media/rc/keymaps/rc-kworld-315u.c @@ -1,14 +1,9 @@ -/* kworld-315u.h - Keytable for kworld_315u Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// kworld-315u.h - Keytable for kworld_315u Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c b/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c index e0322ed16c94f..453e04377de74 100644 --- a/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c +++ b/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c @@ -1,14 +1,9 @@ -/* kworld-plus-tv-analog.h - Keytable for kworld_plus_tv_analog Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// kworld-plus-tv-analog.h - Keytable for kworld_plus_tv_analog Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-manli.c b/drivers/media/rc/keymaps/rc-manli.c index da566902a4ddd..29c9feaf413b5 100644 --- a/drivers/media/rc/keymaps/rc-manli.c +++ b/drivers/media/rc/keymaps/rc-manli.c @@ -1,14 +1,9 @@ -/* manli.h - Keytable for manli Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// manli.h - Keytable for manli Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c index dfa0ed1d76678..78cf2c286083f 100644 --- a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c +++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c @@ -1,14 +1,9 @@ -/* msi-tvanywhere-plus.h - Keytable for msi_tvanywhere_plus Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// msi-tvanywhere-plus.h - Keytable for msi_tvanywhere_plus Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c index 2111816a3f591..359a57be3a665 100644 --- a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c +++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c @@ -1,14 +1,9 @@ -/* msi-tvanywhere.h - Keytable for msi_tvanywhere Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// msi-tvanywhere.h - Keytable for msi_tvanywhere Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-nebula.c b/drivers/media/rc/keymaps/rc-nebula.c index 109b6e1a8b1a9..17d7c1b324da5 100644 --- a/drivers/media/rc/keymaps/rc-nebula.c +++ b/drivers/media/rc/keymaps/rc-nebula.c @@ -1,14 +1,9 @@ -/* nebula.h - Keytable for nebula Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// nebula.h - Keytable for nebula Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c index bb2d3a2962c01..76beef44a8d7d 100644 --- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c +++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c @@ -1,14 +1,9 @@ -/* nec-terratec-cinergy-xs.h - Keytable for nec_terratec_cinergy_xs Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// nec-terratec-cinergy-xs.h - Keytable for nec_terratec_cinergy_xs Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-norwood.c b/drivers/media/rc/keymaps/rc-norwood.c index cd25df3367499..3765705c5549f 100644 --- a/drivers/media/rc/keymaps/rc-norwood.c +++ b/drivers/media/rc/keymaps/rc-norwood.c @@ -1,14 +1,9 @@ -/* norwood.h - Keytable for norwood Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// norwood.h - Keytable for norwood Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-npgtech.c b/drivers/media/rc/keymaps/rc-npgtech.c index 140bbc20a7646..abaf7f6d4cb71 100644 --- a/drivers/media/rc/keymaps/rc-npgtech.c +++ b/drivers/media/rc/keymaps/rc-npgtech.c @@ -1,14 +1,9 @@ -/* npgtech.h - Keytable for npgtech Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// npgtech.h - Keytable for npgtech Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pctv-sedna.c b/drivers/media/rc/keymaps/rc-pctv-sedna.c index 52b4558b7bd0e..e3462c5c8984b 100644 --- a/drivers/media/rc/keymaps/rc-pctv-sedna.c +++ b/drivers/media/rc/keymaps/rc-pctv-sedna.c @@ -1,14 +1,9 @@ -/* pctv-sedna.h - Keytable for pctv_sedna Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pctv-sedna.h - Keytable for pctv_sedna Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pinnacle-color.c b/drivers/media/rc/keymaps/rc-pinnacle-color.c index 973c9c34e3047..63c2851e9dfe4 100644 --- a/drivers/media/rc/keymaps/rc-pinnacle-color.c +++ b/drivers/media/rc/keymaps/rc-pinnacle-color.c @@ -1,14 +1,9 @@ -/* pinnacle-color.h - Keytable for pinnacle_color Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pinnacle-color.h - Keytable for pinnacle_color Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pinnacle-grey.c b/drivers/media/rc/keymaps/rc-pinnacle-grey.c index 22e44b0d2a934..31794d4180dbf 100644 --- a/drivers/media/rc/keymaps/rc-pinnacle-grey.c +++ b/drivers/media/rc/keymaps/rc-pinnacle-grey.c @@ -1,14 +1,9 @@ -/* pinnacle-grey.h - Keytable for pinnacle_grey Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pinnacle-grey.h - Keytable for pinnacle_grey Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c index 186dcf8e04910..876aeb6e1d9cc 100644 --- a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c +++ b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c @@ -1,14 +1,9 @@ -/* pinnacle-pctv-hd.h - Keytable for pinnacle_pctv_hd Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pinnacle-pctv-hd.h - Keytable for pinnacle_pctv_hd Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pixelview-002t.c b/drivers/media/rc/keymaps/rc-pixelview-002t.c index b235ada2e28fb..4ed85f61d0eef 100644 --- a/drivers/media/rc/keymaps/rc-pixelview-002t.c +++ b/drivers/media/rc/keymaps/rc-pixelview-002t.c @@ -1,14 +1,9 @@ -/* rc-pixelview-mk12.h - Keytable for pixelview Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// rc-pixelview-mk12.h - Keytable for pixelview Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pixelview-mk12.c b/drivers/media/rc/keymaps/rc-pixelview-mk12.c index 453d52d663fe2..6ded64b732a59 100644 --- a/drivers/media/rc/keymaps/rc-pixelview-mk12.c +++ b/drivers/media/rc/keymaps/rc-pixelview-mk12.c @@ -1,14 +1,9 @@ -/* rc-pixelview-mk12.h - Keytable for pixelview Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// rc-pixelview-mk12.h - Keytable for pixelview Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pixelview-new.c b/drivers/media/rc/keymaps/rc-pixelview-new.c index ef97095ec8f12..791130f108ff7 100644 --- a/drivers/media/rc/keymaps/rc-pixelview-new.c +++ b/drivers/media/rc/keymaps/rc-pixelview-new.c @@ -1,14 +1,9 @@ -/* pixelview-new.h - Keytable for pixelview_new Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pixelview-new.h - Keytable for pixelview_new Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pixelview.c b/drivers/media/rc/keymaps/rc-pixelview.c index cfd8f80d3617b..9889197351657 100644 --- a/drivers/media/rc/keymaps/rc-pixelview.c +++ b/drivers/media/rc/keymaps/rc-pixelview.c @@ -1,14 +1,9 @@ -/* pixelview.h - Keytable for pixelview Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pixelview.h - Keytable for pixelview Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c index b63f82bcf29a8..4988e71c524cf 100644 --- a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c +++ b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c @@ -1,14 +1,9 @@ -/* powercolor-real-angel.h - Keytable for powercolor_real_angel Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// powercolor-real-angel.h - Keytable for powercolor_real_angel Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-proteus-2309.c b/drivers/media/rc/keymaps/rc-proteus-2309.c index be34c517e4e1e..d2c13d0e7bfff 100644 --- a/drivers/media/rc/keymaps/rc-proteus-2309.c +++ b/drivers/media/rc/keymaps/rc-proteus-2309.c @@ -1,14 +1,9 @@ -/* proteus-2309.h - Keytable for proteus_2309 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// proteus-2309.h - Keytable for proteus_2309 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-purpletv.c b/drivers/media/rc/keymaps/rc-purpletv.c index 84c40b97ee00c..c8011f4d96ea8 100644 --- a/drivers/media/rc/keymaps/rc-purpletv.c +++ b/drivers/media/rc/keymaps/rc-purpletv.c @@ -1,14 +1,9 @@ -/* purpletv.h - Keytable for purpletv Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// purpletv.h - Keytable for purpletv Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-pv951.c b/drivers/media/rc/keymaps/rc-pv951.c index be190ddebfc48..5235ee899c308 100644 --- a/drivers/media/rc/keymaps/rc-pv951.c +++ b/drivers/media/rc/keymaps/rc-pv951.c @@ -1,14 +1,9 @@ -/* pv951.h - Keytable for pv951 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// pv951.h - Keytable for pv951 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c b/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c index 957fa21747ea6..1cf7866496757 100644 --- a/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c +++ b/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c @@ -1,14 +1,9 @@ -/* real-audio-220-32-keys.h - Keytable for real_audio_220_32_keys Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// real-audio-220-32-keys.h - Keytable for real_audio_220_32_keys Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-tbs-nec.c b/drivers/media/rc/keymaps/rc-tbs-nec.c index 05facc043272f..42766cb877c39 100644 --- a/drivers/media/rc/keymaps/rc-tbs-nec.c +++ b/drivers/media/rc/keymaps/rc-tbs-nec.c @@ -1,14 +1,9 @@ -/* tbs-nec.h - Keytable for tbs_nec Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// tbs-nec.h - Keytable for tbs_nec Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c index 3d0f6f7e5bea7..6cf53a56bce4d 100644 --- a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c +++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c @@ -1,14 +1,9 @@ -/* terratec-cinergy-xs.h - Keytable for terratec_cinergy_xs Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// terratec-cinergy-xs.h - Keytable for terratec_cinergy_xs Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-tevii-nec.c b/drivers/media/rc/keymaps/rc-tevii-nec.c index 31f8a0fd1f2c1..58fcc72f528e2 100644 --- a/drivers/media/rc/keymaps/rc-tevii-nec.c +++ b/drivers/media/rc/keymaps/rc-tevii-nec.c @@ -1,14 +1,9 @@ -/* tevii-nec.h - Keytable for tevii_nec Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// tevii-nec.h - Keytable for tevii_nec Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-tt-1500.c b/drivers/media/rc/keymaps/rc-tt-1500.c index 374c230705d23..52f239d2c0258 100644 --- a/drivers/media/rc/keymaps/rc-tt-1500.c +++ b/drivers/media/rc/keymaps/rc-tt-1500.c @@ -1,14 +1,9 @@ -/* tt-1500.h - Keytable for tt_1500 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// tt-1500.h - Keytable for tt_1500 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-videomate-s350.c b/drivers/media/rc/keymaps/rc-videomate-s350.c index b4f1032698728..e4d4dff06a243 100644 --- a/drivers/media/rc/keymaps/rc-videomate-s350.c +++ b/drivers/media/rc/keymaps/rc-videomate-s350.c @@ -1,14 +1,9 @@ -/* videomate-s350.h - Keytable for videomate_s350 Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// videomate-s350.h - Keytable for videomate_s350 Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c index c431fdf44057d..7c48909444075 100644 --- a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c +++ b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c @@ -1,14 +1,9 @@ -/* videomate-tv-pvr.h - Keytable for videomate_tv_pvr Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// videomate-tv-pvr.h - Keytable for videomate_tv_pvr Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c index 5a437e61bd5d3..30495673cddda 100644 --- a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c +++ b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c @@ -1,14 +1,9 @@ -/* winfast-usbii-deluxe.h - Keytable for winfast_usbii_deluxe Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// winfast-usbii-deluxe.h - Keytable for winfast_usbii_deluxe Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include diff --git a/drivers/media/rc/keymaps/rc-winfast.c b/drivers/media/rc/keymaps/rc-winfast.c index 53685d1f9a47a..ee7f4c349fd6e 100644 --- a/drivers/media/rc/keymaps/rc-winfast.c +++ b/drivers/media/rc/keymaps/rc-winfast.c @@ -1,14 +1,9 @@ -/* winfast.h - Keytable for winfast Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// winfast.h - Keytable for winfast Remote Controller +// +// keymap imported from ir-keymaps.c +// +// Copyright (c) 2010 by Mauro Carvalho Chehab #include #include -- GitLab From 459ee17c56898bcfac501008b22deb54122d2b63 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:12 -0500 Subject: [PATCH 0083/1190] media: i2c: add SPDX identifiers to the code I wrote As we're now using SPDX identifiers, on the several media drivers I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2. Signed-off-by: Mauro Carvalho Chehab Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9v011.c | 13 ++++--- drivers/media/i2c/saa7115.c | 58 +++++++++++++------------------- drivers/media/i2c/saa711x_regs.h | 14 ++------ drivers/media/i2c/tvp5150.c | 13 ++++--- drivers/media/i2c/tvp5150_reg.h | 5 +-- 5 files changed, 42 insertions(+), 61 deletions(-) diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index 9ed1b26b65498..5e29064fae91c 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c @@ -1,9 +1,8 @@ -/* - * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor - * - * Copyright (c) 2009 Mauro Carvalho Chehab - * This code is placed under the terms of the GNU General Public License v2 - */ +// SPDX-License-Identifier: GPL-2.0 +// +// mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor +// +// Copyright (c) 2009 Mauro Carvalho Chehab #include #include @@ -17,7 +16,7 @@ MODULE_DESCRIPTION("Micron mt9v011 sensor driver"); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); static int debug; module_param(debug, int, 0); diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index d863b04aa2a89..7dd6cff6d811b 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1,37 +1,27 @@ -/* saa711x - Philips SAA711x video decoder driver - * This driver can work with saa7111, saa7111a, saa7113, saa7114, - * saa7115 and saa7118. - * - * Based on saa7114 driver by Maxim Yevtyushkin, which is based on - * the saa7111 driver by Dave Perks. - * - * Copyright (C) 1998 Dave Perks - * Copyright (C) 2002 Maxim Yevtyushkin - * - * Slight changes for video timing and attachment output by - * Wolfgang Scherr - * - * Moved over to the linux >= 2.4.x i2c protocol (1/1/2003) - * by Ronald Bultje - * - * Added saa7115 support by Kevin Thayer - * (2/17/2003) - * - * VBI support (2004) and cleanups (2005) by Hans Verkuil - * - * Copyright (c) 2005-2006 Mauro Carvalho Chehab - * SAA7111, SAA7113 and SAA7118 support - * - * 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. - */ +// SPDX-License-Identifier: GPL-2.0+ +// saa711x - Philips SAA711x video decoder driver +// This driver can work with saa7111, saa7111a, saa7113, saa7114, +// saa7115 and saa7118. +// +// Based on saa7114 driver by Maxim Yevtyushkin, which is based on +// the saa7111 driver by Dave Perks. +// +// Copyright (C) 1998 Dave Perks +// Copyright (C) 2002 Maxim Yevtyushkin +// +// Slight changes for video timing and attachment output by +// Wolfgang Scherr +// +// Moved over to the linux >= 2.4.x i2c protocol (1/1/2003) +// by Ronald Bultje +// +// Added saa7115 support by Kevin Thayer +// (2/17/2003) +// +// VBI support (2004) and cleanups (2005) by Hans Verkuil +// +// Copyright (c) 2005-2006 Mauro Carvalho Chehab +// SAA7111, SAA7113 and SAA7118 support #include "saa711x_regs.h" diff --git a/drivers/media/i2c/saa711x_regs.h b/drivers/media/i2c/saa711x_regs.h index 730ca90b30ac3..a50d480e101a8 100644 --- a/drivers/media/i2c/saa711x_regs.h +++ b/drivers/media/i2c/saa711x_regs.h @@ -1,16 +1,8 @@ -/* saa711x - Philips SAA711x video decoder register specifications +/* + * SPDX-License-Identifier: GPL-2.0+ + * saa711x - Philips SAA711x video decoder register specifications * * Copyright (c) 2006 Mauro Carvalho Chehab - * - * 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. */ #define R_00_CHIP_VERSION 0x00 diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 7b79a74987519..3c1851984b907 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -1,9 +1,8 @@ -/* - * tvp5150 - Texas Instruments TVP5150A/AM1 and TVP5151 video decoder driver - * - * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNU General Public License v2 - */ +// SPDX-License-Identifier: GPL-2.0 +// +// tvp5150 - Texas Instruments TVP5150A/AM1 and TVP5151 video decoder driver +// +// Copyright (c) 2005,2006 Mauro Carvalho Chehab #include #include @@ -30,7 +29,7 @@ MODULE_DESCRIPTION("Texas Instruments TVP5150A/TVP5150AM1/TVP5151 video decoder driver"); MODULE_AUTHOR("Mauro Carvalho Chehab"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); static int debug; diff --git a/drivers/media/i2c/tvp5150_reg.h b/drivers/media/i2c/tvp5150_reg.h index 30a48c28d05ab..654c442847879 100644 --- a/drivers/media/i2c/tvp5150_reg.h +++ b/drivers/media/i2c/tvp5150_reg.h @@ -1,8 +1,9 @@ /* + * SPDX-License-Identifier: GPL-2.0 + * * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder registers * - * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org) - * This code is placed under the terms of the GNU General Public License v2 + * Copyright (c) 2005,2006 Mauro Carvalho Chehab */ #define TVP5150_VD_IN_SRC_SEL_1 0x00 /* Video input source selection #1 */ -- GitLab From 1e6f57b2b4ef75fef59ee8771c95bbaf2b086af7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 1 Dec 2017 08:47:13 -0500 Subject: [PATCH 0084/1190] media: siano: add SPDX markups As we're now using SPDX identifiers, add the proper SPDX, better identifying the licenses whith apply to the source code. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2 at the Siano's common driver. Some codes there are licensed on GPL v2 or latter, while others are GPL v2 only. So, in order to reflect the common license that applies to everything, the module itself should be GPLv2 only. While here, use the Kernel's coding style for the comments with copyright info. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-debugfs.c | 21 ++---------- drivers/media/common/siano/smsir.c | 35 ++++++------------- drivers/media/common/siano/smsir.h | 37 +++++++-------------- 3 files changed, 25 insertions(+), 68 deletions(-) diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c index 1a8677ade3917..e06aec0ed18e0 100644 --- a/drivers/media/common/siano/smsdvb-debugfs.c +++ b/drivers/media/common/siano/smsdvb-debugfs.c @@ -1,21 +1,6 @@ -/*********************************************************************** - * - * Copyright(c) 2013 Mauro Carvalho Chehab - * - * 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, see . - * - ***********************************************************************/ +// SPDX-License-Identifier: GPL-2.0+ +// +// Copyright(c) 2013 Mauro Carvalho Chehab #include "smscoreapi.h" diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c index e77bb0c95e69c..56db0a9444218 100644 --- a/drivers/media/common/siano/smsir.c +++ b/drivers/media/common/siano/smsir.c @@ -1,28 +1,13 @@ -/**************************************************************** - - Siano Mobile Silicon, Inc. - MDTV receiver kernel modules. - Copyright (C) 2006-2009, Uri Shkolnik - - Copyright (c) 2010 - Mauro Carvalho Chehab - - Ported the driver to use rc-core - - IR raw event decoding is now done at rc-core - - Code almost re-written - - 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, see . - - ****************************************************************/ +// SPDX-License-Identifier: GPL-2.0+ +// +// Siano Mobile Silicon, Inc. +// MDTV receiver kernel modules. +// Copyright (C) 2006-2009, Uri Shkolnik +// +// Copyright (c) 2010 - Mauro Carvalho Chehab +// - Ported the driver to use rc-core +// - IR raw event decoding is now done at rc-core +// - Code almost re-written #include "smscoreapi.h" diff --git a/drivers/media/common/siano/smsir.h b/drivers/media/common/siano/smsir.h index d9abd96ef48bf..b2c54c256e865 100644 --- a/drivers/media/common/siano/smsir.h +++ b/drivers/media/common/siano/smsir.h @@ -1,28 +1,15 @@ -/**************************************************************** - -Siano Mobile Silicon, Inc. -MDTV receiver kernel modules. -Copyright (C) 2006-2009, Uri Shkolnik - - Copyright (c) 2010 - Mauro Carvalho Chehab - - Ported the driver to use rc-core - - IR raw event decoding is now done at rc-core - - Code almost re-written - -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, see . - -****************************************************************/ +/* + * SPDX-License-Identifier: GPL-2.0+ + * + * Siano Mobile Silicon, Inc. + * MDTV receiver kernel modules. + * Copyright (C) 2006-2009, Uri Shkolnik + * + * Copyright (c) 2010 - Mauro Carvalho Chehab + * - Ported the driver to use rc-core + * - IR raw event decoding is now done at rc-core + * - Code almost re-written + */ #ifndef __SMS_IR_H__ #define __SMS_IR_H__ -- GitLab From 3d932ee27e852e4904647f15b64dedca51187ad7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 26 Sep 2017 17:10:20 -0400 Subject: [PATCH 0085/1190] media: dvb-usb-v2: lmedm04: Improve logic checking of warm start Warm start has no check as whether a genuine device has connected and proceeds to next execution path. Check device should read 0x47 at offset of 2 on USB descriptor read and it is the amount requested of 6 bytes. Fix for kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access as Reported-by: Andrey Konovalov Signed-off-by: Malcolm Priestley Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 5e320fa4a7950..992f2011a6ba9 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -494,18 +494,23 @@ static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, static int lme2510_return_status(struct dvb_usb_device *d) { - int ret = 0; + int ret; u8 *data; - data = kzalloc(10, GFP_KERNEL); + data = kzalloc(6, GFP_KERNEL); if (!data) return -ENOMEM; - ret |= usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), - 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200); - info("Firmware Status: %x (%x)", ret , data[2]); + ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), + 0x06, 0x80, 0x0302, 0x00, + data, 0x6, 200); + if (ret != 6) + ret = -EINVAL; + else + ret = data[2]; + + info("Firmware Status: %6ph", data); - ret = (ret < 0) ? -ENODEV : data[2]; kfree(data); return ret; } @@ -1189,6 +1194,7 @@ static int lme2510_get_adapter_count(struct dvb_usb_device *d) static int lme2510_identify_state(struct dvb_usb_device *d, const char **name) { struct lme2510_state *st = d->priv; + int status; usb_reset_configuration(d->udev); @@ -1197,12 +1203,16 @@ static int lme2510_identify_state(struct dvb_usb_device *d, const char **name) st->dvb_usb_lme2510_firmware = dvb_usb_lme2510_firmware; - if (lme2510_return_status(d) == 0x44) { + status = lme2510_return_status(d); + if (status == 0x44) { *name = lme_firmware_switch(d, 0); return COLD; } - return 0; + if (status != 0x47) + return -EINVAL; + + return WARM; } static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type, -- GitLab From 7bf7a7116ed313c601307f7e585419369926ab05 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 26 Sep 2017 17:10:21 -0400 Subject: [PATCH 0086/1190] media: dvb-usb-v2: lmedm04: move ts2020 attach to dm04_lme2510_tuner When the tuner was split from m88rs2000 the attach function is in wrong place. Move to dm04_lme2510_tuner to trap errors on failure and removing a call to lme_coldreset. Prevents driver starting up without any tuner connected. Fixes to trap for ts2020 fail. LME2510(C): FE Found M88RS2000 ts2020: probe of 0-0060 failed with error -11 ... LME2510(C): TUN Found RS2000 tuner kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] PREEMPT SMP KASAN Reported-by: Andrey Konovalov Signed-off-by: Malcolm Priestley Tested-by: Andrey Konovalov Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 992f2011a6ba9..be26c029546bd 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -1076,8 +1076,6 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) if (adap->fe[0]) { info("FE Found M88RS2000"); - dvb_attach(ts2020_attach, adap->fe[0], &ts2020_config, - &d->i2c_adap); st->i2c_tuner_gate_w = 5; st->i2c_tuner_gate_r = 5; st->i2c_tuner_addr = 0x60; @@ -1143,17 +1141,18 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap) ret = st->tuner_config; break; case TUNER_RS2000: - ret = st->tuner_config; + if (dvb_attach(ts2020_attach, adap->fe[0], + &ts2020_config, &d->i2c_adap)) + ret = st->tuner_config; break; default: break; } - if (ret) + if (ret) { info("TUN Found %s tuner", tun_msg[ret]); - else { - info("TUN No tuner found --- resetting device"); - lme_coldreset(d); + } else { + info("TUN No tuner found"); return -ENODEV; } -- GitLab From 7d4b6f5590b47b8bc040d63863088d67a9fb17f4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 29 Sep 2017 17:38:39 -0400 Subject: [PATCH 0087/1190] media: staging/imx: fix complete handler The complete handler walks all entities, expecting to find an imx subdevice for each and every entity. However, camera drivers such as smiapp can themselves contain multiple entities, for which there will not be an imx subdevice. This causes imx_media_find_subdev_by_sd() to fail, making the imx capture system unusable with such cameras. Work around this by killing the error entirely, thereby allowing the imx capture to be used with such cameras. Signed-off-by: Russell King Acked-by: Steve Longerbeam Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 47c4c954fed5b..6a773c76cd9e6 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -345,8 +345,11 @@ static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd, sd = media_entity_to_v4l2_subdev(entity); imxsd = imx_media_find_subdev_by_sd(imxmd, sd); - if (IS_ERR(imxsd)) - return PTR_ERR(imxsd); + if (IS_ERR(imxsd)) { + v4l2_err(&imxmd->v4l2_dev, "failed to find subdev for entity %s, sd %p err %ld\n", + entity->name, sd, PTR_ERR(imxsd)); + return 0; + } imxpad = &imxsd->pad[srcpad->index]; vdev_idx = imxpad->num_vdevs; -- GitLab From 37ea9830139b321497640b6d8fe93bb2fe00d1f6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 29 Sep 2017 17:41:59 -0400 Subject: [PATCH 0088/1190] media: imx-csi: fix burst size Setting a burst size of "8" doesn't work for IMX219 with 8-bit bayer, but a burst size of "16" does. Fix this. Signed-off-by: Russell King Acked-by: Philipp Zabel Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index f4a3bf5ca2bbc..d90cfda1529c9 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -337,7 +337,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: - burst_size = 8; + burst_size = 16; passthrough = true; passthrough_bits = 8; break; -- GitLab From 7ff061303382ed4151ff6932a9f356f6aac0bc4a Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Tue, 10 Oct 2017 17:34:58 -0400 Subject: [PATCH 0089/1190] media: cx25840: describe standard for 0b1100 value in AFD_FMT_STAT bits A 0b1100 value in 4 LSBs of "General Status 1" register (AFD_FMT_STAT) has known meaning for CX2584x-series chips - it means that a SECAM signal is currently detected by the chip. Use this opportunity to also fix wrong binary values that were present as comments attached to some entries in an array where chip register -> V4L2 standard mappings are stored. Signed-off-by: Maciej S. Szmigiero Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/cx25840/cx25840-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index f38bf819d8054..ec0e91369853e 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -1757,11 +1757,11 @@ static int cx25840_g_std(struct v4l2_subdev *sd, v4l2_std_id *std) /* 0111 */ V4L2_STD_PAL_Nc, /* 1000 */ V4L2_STD_PAL_60, - /* 1001 */ V4L2_STD_UNKNOWN, - /* 1010 */ V4L2_STD_UNKNOWN, /* 1001 */ V4L2_STD_UNKNOWN, /* 1010 */ V4L2_STD_UNKNOWN, /* 1011 */ V4L2_STD_UNKNOWN, + /* 1100 */ V4L2_STD_SECAM, + /* 1101 */ V4L2_STD_UNKNOWN, /* 1110 */ V4L2_STD_UNKNOWN, /* 1111 */ V4L2_STD_UNKNOWN }; -- GitLab From 4f1bdf0a75a4d16149c470800d8c4bf3da13e92d Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Tue, 10 Oct 2017 17:35:37 -0400 Subject: [PATCH 0090/1190] media: cx25840: fix a possible divide by zero in set_fmt callback If set_fmt callback is called with format->width or format->height set to zero and HACTIVE_CNT or VACTIVE_CNT bits (respectively) in chip are zero we will divide by zero later in this callback when we try to calculate HSC or VSC values. Fix this by explicitly rejecting these values. Signed-off-by: Maciej S. Szmigiero Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/cx25840/cx25840-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index ec0e91369853e..940c8b1712497 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -1395,8 +1395,9 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd, * height. Without that margin the cx23885 fails in this * check. */ - if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) || - (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) { + if ((fmt->width == 0) || (Vlines == 0) || + (fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) || + (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) { v4l_err(client, "%dx%d is not a valid size!\n", fmt->width, fmt->height); return -ERANGE; -- GitLab From 19326ef0874e8fdcf4d6d6fe97e85b2dac69a954 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 12 Oct 2017 12:03:34 -0400 Subject: [PATCH 0091/1190] media: dt-bindings: media: xilinx: fix typo in example Fix typo s/:/;/ Cc: Rob Herring Cc: Hyun Kwon Signed-off-by: Akinobu Mita Acked-by: Rob Herring Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt index 9dd86b3db9377..439351ab2a795 100644 --- a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt +++ b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt @@ -66,6 +66,6 @@ Example: tpg1_out: endpoint { remote-endpoint = <&switch_in0>; }; - }: + }; }; }; -- GitLab From 2919d12de52106279b92a75e9a6788b5c668a159 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 15 Oct 2017 14:54:52 -0400 Subject: [PATCH 0092/1190] media: mxl5xx: fix tuning logic The tuning logic is broken with regards to status report: it relies on a previously-cached value that may not be valid if re-tuned. Change the logic to always read the status. Acked-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/mxl5xx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/media/dvb-frontends/mxl5xx.c b/drivers/media/dvb-frontends/mxl5xx.c index 53064e11f5f1e..1ebc3830579ff 100644 --- a/drivers/media/dvb-frontends/mxl5xx.c +++ b/drivers/media/dvb-frontends/mxl5xx.c @@ -636,16 +636,9 @@ static int tune(struct dvb_frontend *fe, bool re_tune, if (r) return r; state->tune_time = jiffies; - return 0; } - if (*status & FE_HAS_LOCK) - return 0; - r = read_status(fe, status); - if (r) - return r; - - return 0; + return read_status(fe, status); } static enum fe_code_rate conv_fec(enum MXL_HYDRA_FEC_E fec) -- GitLab From 1d8343aa35b11dba89dc8f6855157200c51f606c Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:50 -0400 Subject: [PATCH 0093/1190] media: ddbridge: remove unneeded *fe vars from attach functions These are only used in C/T demod attach functions, don't add any real benefit (ie. line length savings) and in case of cxd28xx_attach aren't even used consequently. Remove them. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-core.c | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index f4bd4908acdd5..653e7986923c1 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -848,21 +848,20 @@ static int demod_attach_drxk(struct ddb_input *input) struct i2c_adapter *i2c = &input->port->i2c->adap; struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; struct device *dev = input->port->dev->dev; - struct dvb_frontend *fe; struct drxk_config config; memset(&config, 0, sizeof(config)); config.adr = 0x29 + (input->nr & 1); config.microcode_name = "drxk_a3.mc"; - fe = dvb->fe = dvb_attach(drxk_attach, &config, i2c); - if (!fe) { + dvb->fe = dvb_attach(drxk_attach, &config, i2c); + if (!dvb->fe) { dev_err(dev, "No DRXK found!\n"); return -ENODEV; } - fe->sec_priv = input; - dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl; - fe->ops.i2c_gate_ctrl = locked_gate_ctrl; + dvb->fe->sec_priv = input; + dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; + dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; return 0; } @@ -912,19 +911,18 @@ static int demod_attach_stv0367(struct ddb_input *input) struct i2c_adapter *i2c = &input->port->i2c->adap; struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; struct device *dev = input->port->dev->dev; - struct dvb_frontend *fe; /* attach frontend */ - fe = dvb->fe = dvb_attach(stv0367ddb_attach, + dvb->fe = dvb_attach(stv0367ddb_attach, &ddb_stv0367_config[(input->nr & 1)], i2c); if (!dvb->fe) { dev_err(dev, "No stv0367 found!\n"); return -ENODEV; } - fe->sec_priv = input; - dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl; - fe->ops.i2c_gate_ctrl = locked_gate_ctrl; + dvb->fe->sec_priv = input; + dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; + dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; return 0; } @@ -956,7 +954,6 @@ static int demod_attach_cxd28xx(struct ddb_input *input, int par, int osc24) struct i2c_adapter *i2c = &input->port->i2c->adap; struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; struct device *dev = input->port->dev->dev; - struct dvb_frontend *fe; struct cxd2841er_config cfg; /* the cxd2841er driver expects 8bit/shifted I2C addresses */ @@ -971,15 +968,15 @@ static int demod_attach_cxd28xx(struct ddb_input *input, int par, int osc24) cfg.flags |= CXD2841ER_TS_SERIAL; /* attach frontend */ - fe = dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); + dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); if (!dvb->fe) { dev_err(dev, "No cxd2837/38/43/54 found!\n"); return -ENODEV; } - fe->sec_priv = input; - dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl; - fe->ops.i2c_gate_ctrl = locked_gate_ctrl; + dvb->fe->sec_priv = input; + dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; + dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; return 0; } -- GitLab From 757d78d35aeab1e53a9025128a14d8b63b1a2ba3 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:51 -0400 Subject: [PATCH 0094/1190] media: ddbridge: fixup checkpatch-strict issues Fixes several alignment, braces, space-before-cast, camelcase et al issues reported by checkpatch --strict, plus a few more checkpatch didn't report. Three checks are left after this though: - one CamelCase in ddbridge-core, related to defines/vars/enums referenced from the stv090x demod driver - one macro argument reuse in ddbridge-core aswell - one unbalanced braces around else in ddbridge-main, which is due to #ifdefs related to CONFIG_PCI_MSI, which preferrably should be kept as-is for readability. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-core.c | 131 ++++++++++---------- drivers/media/pci/ddbridge/ddbridge-hw.c | 8 +- drivers/media/pci/ddbridge/ddbridge-i2c.c | 16 +-- drivers/media/pci/ddbridge/ddbridge-main.c | 23 ++-- drivers/media/pci/ddbridge/ddbridge-maxs8.c | 44 ++++--- drivers/media/pci/ddbridge/ddbridge-regs.h | 32 ++--- drivers/media/pci/ddbridge/ddbridge.h | 89 +++++++------ 7 files changed, 179 insertions(+), 164 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 653e7986923c1..0eaa2efdcc54f 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -112,7 +112,6 @@ static void ddb_set_dma_tables(struct ddb *dev) } } - /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ @@ -210,8 +209,9 @@ static int ddb_redirect(u32 i, u32 p) if (input->redi) { input2->redi = input->redi; input->redi = NULL; - } else + } else { input2->redi = input; + } } input->redo = port->output; port->output->redi = input; @@ -357,9 +357,9 @@ static void calc_con(struct ddb_output *output, u32 *con, u32 *con2, u32 flags) max_bitrate = 0; gap = 0; if (bitrate != 72000) { - if (bitrate >= 96000) + if (bitrate >= 96000) { *con |= 0x800; - else { + } else { *con |= 0x1000; nco = (bitrate * 8192 + 71999) / 72000; @@ -506,7 +506,6 @@ static void ddb_input_start(struct ddb_input *input) } } - static void ddb_input_start_all(struct ddb_input *input) { struct ddb_input *i = input; @@ -572,7 +571,7 @@ static ssize_t ddb_output_write(struct ddb_output *output, while (left) { len = output->dma->size - output->dma->coff; if ((((output->dma->cbuf + 1) % output->dma->num) == idx) && - (off == 0)) { + off == 0) { if (len <= 188) break; len -= 188; @@ -593,7 +592,8 @@ static ssize_t ddb_output_write(struct ddb_output *output, buf, len)) return -EIO; if (alt_dma) - dma_sync_single_for_device(dev->dev, + dma_sync_single_for_device( + dev->dev, output->dma->pbuf[output->dma->cbuf], output->dma->size, DMA_TO_DEVICE); left -= len; @@ -632,7 +632,7 @@ static u32 ddb_input_avail(struct ddb_input *input) } static ssize_t ddb_input_read(struct ddb_input *input, - __user u8 *buf, size_t count) + __user u8 *buf, size_t count) { struct ddb *dev = input->port->dev; u32 left = count; @@ -648,7 +648,8 @@ static ssize_t ddb_input_read(struct ddb_input *input, if (free > left) free = left; if (alt_dma) - dma_sync_single_for_cpu(dev->dev, + dma_sync_single_for_cpu( + dev->dev, input->dma->pbuf[input->dma->cbuf], input->dma->size, DMA_FROM_DEVICE); ret = copy_to_user(buf, input->dma->vbuf[input->dma->cbuf] + @@ -792,8 +793,10 @@ static int ts_open(struct inode *inode, struct file *file) } else if ((file->f_flags & O_ACCMODE) == O_WRONLY) { if (!output) return -EINVAL; - } else + } else { return -EINVAL; + } + err = dvb_generic_open(inode, file); if (err < 0) return err; @@ -822,7 +825,6 @@ static struct dvb_device dvbdev_ci = { .fops = &ci_fops, }; - /****************************************************************************/ /****************************************************************************/ @@ -914,7 +916,7 @@ static int demod_attach_stv0367(struct ddb_input *input) /* attach frontend */ dvb->fe = dvb_attach(stv0367ddb_attach, - &ddb_stv0367_config[(input->nr & 1)], i2c); + &ddb_stv0367_config[(input->nr & 1)], i2c); if (!dvb->fe) { dev_err(dev, "No stv0367 found!\n"); @@ -1017,7 +1019,7 @@ static int tuner_attach_tda18212(struct ddb_input *input, u32 porttype) /* perform tuner init/attach */ client = i2c_new_device(adapter, &board_info); - if (client == NULL || client->dev.driver == NULL) + if (!client || !client->dev.driver) goto err; if (!try_module_get(client->dev.driver->owner)) { @@ -1132,7 +1134,7 @@ static int tuner_attach_stv6110(struct ddb_input *input, int type) return -ENODEV; } dev_info(dev, "attach tuner input %d adr %02x\n", - input->nr, tunerconf->addr); + input->nr, tunerconf->addr); feconf->tuner_init = ctl->tuner_init; feconf->tuner_sleep = ctl->tuner_sleep; @@ -1262,7 +1264,8 @@ static void dvb_input_detach(struct ddb_input *input) dvb_frontend_detach(dvb->fe2); if (dvb->fe) dvb_frontend_detach(dvb->fe); - dvb->fe = dvb->fe2 = NULL; + dvb->fe = NULL; + dvb->fe2 = NULL; /* fallthrough */ case 0x20: client = dvb->i2c_client[0]; @@ -1406,7 +1409,8 @@ static int dvb_input_attach(struct ddb_input *input) DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING; dvbdemux->start_feed = start_feed; dvbdemux->stop_feed = stop_feed; - dvbdemux->filternum = dvbdemux->feednum = 256; + dvbdemux->filternum = 256; + dvbdemux->feednum = 256; ret = dvb_dmx_init(dvbdemux); if (ret < 0) return ret; @@ -1433,7 +1437,8 @@ static int dvb_input_attach(struct ddb_input *input) return ret; dvb->attached = 0x20; - dvb->fe = dvb->fe2 = NULL; + dvb->fe = NULL; + dvb->fe2 = NULL; switch (port->type) { case DDB_TUNER_MXL5XX: if (fe_attach_mxl5xx(input) < 0) @@ -1700,11 +1705,11 @@ static int init_xo2_ci(struct ddb_port *port) if (data[0] > 1) { dev_info(dev->dev, "Port %d: invalid XO2 CI %02x\n", - port->nr, data[0]); + port->nr, data[0]); return -1; } dev_info(dev->dev, "Port %d: DuoFlex CI %u.%u\n", - port->nr, data[0], data[1]); + port->nr, data[0], data[1]); i2c_read_reg(i2c, 0x10, 0x08, &val); if (val != 0) { @@ -1715,7 +1720,6 @@ static int init_xo2_ci(struct ddb_port *port) i2c_write_reg(i2c, 0x10, 0x08, 3); usleep_range(2000, 3000); - /* speed: 0=55,1=75,2=90,3=104 MBit/s */ i2c_write_reg(i2c, 0x10, 0x09, 1); @@ -1818,7 +1822,7 @@ static void ddb_port_probe(struct ddb_port *port) port->i2c->regs + I2C_TIMING); } else { dev_info(dev->dev, "Port %d: Uninitialized DuoFlex\n", - port->nr); + port->nr); return; } } else if (port_has_xo2(port, &type, &id)) { @@ -1909,7 +1913,6 @@ static void ddb_port_probe(struct ddb_port *port) } } - /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ @@ -1999,7 +2002,7 @@ static int slot_reset(struct dvb_ca_en50221 *ca, int slot) CI_CONTROL(ci->nr)); ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON | CI_RESET_CAM, CI_CONTROL(ci->nr)); - udelay(20); + usleep_range(20, 25); ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON, CI_CONTROL(ci->nr)); return 0; @@ -2264,7 +2267,7 @@ static int ddb_port_attach(struct ddb_port *port) case DDB_PORT_LOOP: ret = dvb_register_device(port->dvb[0].adap, &port->dvb[0].dev, - &dvbdev_ci, (void *) port->output, + &dvbdev_ci, (void *)port->output, DVB_DEVICE_SEC, 0); break; default: @@ -2323,7 +2326,6 @@ void ddb_ports_detach(struct ddb *dev) dvb_unregister_adapters(dev); } - /* Copy input DMA pointers to output DMA and ACK. */ static void input_write_output(struct ddb_input *input, @@ -2350,16 +2352,18 @@ static void input_write_dvb(struct ddb_input *input, struct ddb *dev = input->port->dev; int ack = 1; - dma = dma2 = input->dma; - /* if there also is an output connected, do not ACK. + dma = input->dma; + dma2 = input->dma; + /* + * if there also is an output connected, do not ACK. * input_write_output will ACK. */ if (input->redo) { dma2 = input->redo->dma; ack = 0; } - while (dma->cbuf != ((dma->stat >> 11) & 0x1f) - || (4 & dma->ctrl)) { + while (dma->cbuf != ((dma->stat >> 11) & 0x1f) || + (4 & dma->ctrl)) { if (4 & dma->ctrl) { /* dev_err(dev->dev, "Overflow dma %d\n", dma->nr); */ ack = 1; @@ -2382,7 +2386,7 @@ static void input_write_dvb(struct ddb_input *input, static void input_work(struct work_struct *work) { struct ddb_dma *dma = container_of(work, struct ddb_dma, work); - struct ddb_input *input = (struct ddb_input *) dma->io; + struct ddb_input *input = (struct ddb_input *)dma->io; struct ddb *dev = input->port->dev; unsigned long flags; @@ -2404,11 +2408,11 @@ static void input_work(struct work_struct *work) static void input_handler(unsigned long data) { - struct ddb_input *input = (struct ddb_input *) data; + struct ddb_input *input = (struct ddb_input *)data; struct ddb_dma *dma = input->dma; - - /* If there is no input connected, input_tasklet() will + /* + * If there is no input connected, input_tasklet() will * just copy pointers and ACK. So, there is no need to go * through the tasklet scheduler. */ @@ -2420,7 +2424,7 @@ static void input_handler(unsigned long data) static void output_handler(unsigned long data) { - struct ddb_output *output = (struct ddb_output *) data; + struct ddb_output *output = (struct ddb_output *)data; struct ddb_dma *dma = output->dma; struct ddb *dev = output->port->dev; @@ -2509,10 +2513,10 @@ static void ddb_input_init(struct ddb_port *port, int nr, int pnr, int anr) dma_nr += 32 + (port->lnr - 1) * 8; dev_dbg(dev->dev, "init link %u, input %u, handler %u\n", - port->lnr, nr, dma_nr + base); + port->lnr, nr, dma_nr + base); dev->handler[0][dma_nr + base] = input_handler; - dev->handler_data[0][dma_nr + base] = (unsigned long) input; + dev->handler_data[0][dma_nr + base] = (unsigned long)input; ddb_dma_init(input, dma_nr, 0); } } @@ -2531,14 +2535,14 @@ static void ddb_output_init(struct ddb_port *port, int nr) (rm->output->base + rm->output->size * nr); dev_dbg(dev->dev, "init link %u, output %u, regs %08x\n", - port->lnr, nr, output->regs); + port->lnr, nr, output->regs); if (dev->has_dma) { const struct ddb_regmap *rm0 = io_regmap(output, 0); u32 base = rm0->irq_base_odma; dev->handler[0][nr + base] = output_handler; - dev->handler_data[0][nr + base] = (unsigned long) output; + dev->handler_data[0][nr + base] = (unsigned long)output; ddb_dma_init(output, nr, 1); } } @@ -2606,7 +2610,7 @@ void ddb_ports_init(struct ddb *dev) port->dvb[0].adap = &dev->adap[2 * p]; port->dvb[1].adap = &dev->adap[2 * p + 1]; - if ((port->class == DDB_PORT_NONE) && i && p && + if (port->class == DDB_PORT_NONE && i && p && dev->port[p - 1].type == DDB_CI_EXTERNAL_XO2) { port->class = DDB_PORT_CI; port->type = DDB_CI_EXTERNAL_XO2_B; @@ -2615,8 +2619,8 @@ void ddb_ports_init(struct ddb *dev) } dev_info(dev->dev, "Port %u: Link %u, Link Port %u (TAB %u): %s\n", - port->pnr, port->lnr, port->nr, port->nr + 1, - port->name); + port->pnr, port->lnr, port->nr, port->nr + 1, + port->name); if (port->class == DDB_PORT_CI && port->type == DDB_CI_EXTERNAL_XO2) { @@ -2738,7 +2742,7 @@ static void irq_handle_io(struct ddb *dev, u32 s) irqreturn_t ddb_irq_handler0(int irq, void *dev_id) { - struct ddb *dev = (struct ddb *) dev_id; + struct ddb *dev = (struct ddb *)dev_id; u32 s = ddbreadl(dev, INTERRUPT_STATUS); do { @@ -2755,7 +2759,7 @@ irqreturn_t ddb_irq_handler0(int irq, void *dev_id) irqreturn_t ddb_irq_handler1(int irq, void *dev_id) { - struct ddb *dev = (struct ddb *) dev_id; + struct ddb *dev = (struct ddb *)dev_id; u32 s = ddbreadl(dev, INTERRUPT_STATUS); do { @@ -2772,7 +2776,7 @@ irqreturn_t ddb_irq_handler1(int irq, void *dev_id) irqreturn_t ddb_irq_handler(int irq, void *dev_id) { - struct ddb *dev = (struct ddb *) dev_id; + struct ddb *dev = (struct ddb *)dev_id; u32 s = ddbreadl(dev, INTERRUPT_STATUS); int ret = IRQ_HANDLED; @@ -2809,7 +2813,7 @@ static int reg_wait(struct ddb *dev, u32 reg, u32 bit) } static int flashio(struct ddb *dev, u32 lnr, u8 *wbuf, u32 wlen, u8 *rbuf, - u32 rlen) + u32 rlen) { u32 data, shift; u32 tag = DDB_LINK_TAG(lnr); @@ -2820,7 +2824,7 @@ static int flashio(struct ddb *dev, u32 lnr, u8 *wbuf, u32 wlen, u8 *rbuf, ddbwritel(dev, 1, tag | SPI_CONTROL); while (wlen > 4) { /* FIXME: check for big-endian */ - data = swab32(*(u32 *) wbuf); + data = swab32(*(u32 *)wbuf); wbuf += 4; wlen -= 4; ddbwritel(dev, data, tag | SPI_DATA); @@ -2860,12 +2864,12 @@ static int flashio(struct ddb *dev, u32 lnr, u8 *wbuf, u32 wlen, u8 *rbuf, if (reg_wait(dev, tag | SPI_CONTROL, 4)) goto fail; data = ddbreadl(dev, tag | SPI_DATA); - *(u32 *) rbuf = swab32(data); + *(u32 *)rbuf = swab32(data); rbuf += 4; rlen -= 4; } ddbwritel(dev, 0x0003 | ((rlen << (8 + 3)) & 0x1F00), - tag | SPI_CONTROL); + tag | SPI_CONTROL); ddbwritel(dev, 0xffffffff, tag | SPI_DATA); if (reg_wait(dev, tag | SPI_CONTROL, 4)) goto fail; @@ -3008,7 +3012,7 @@ static ssize_t fan_store(struct device *device, struct device_attribute *d, } static ssize_t fanspeed_show(struct device *device, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ddb *dev = dev_get_drvdata(device); int num = attr->attr.name[8] - 0x30; @@ -3046,7 +3050,7 @@ static ssize_t temp_show(struct device *device, } static ssize_t ctemp_show(struct device *device, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ddb *dev = dev_get_drvdata(device); struct i2c_adapter *adap; @@ -3073,7 +3077,6 @@ static ssize_t led_show(struct device *device, return sprintf(buf, "%d\n", dev->leds & (1 << num) ? 1 : 0); } - static void ddb_set_led(struct ddb *dev, int num, int val) { if (!dev->link[0].info->led_num) @@ -3160,7 +3163,7 @@ static ssize_t bsnr_show(struct device *device, } static ssize_t bpsnr_show(struct device *device, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ddb *dev = dev_get_drvdata(device); unsigned char snr[32]; @@ -3205,7 +3208,6 @@ static ssize_t gap_show(struct device *device, int num = attr->attr.name[3] - 0x30; return sprintf(buf, "%d\n", dev->port[num].gap); - } static ssize_t gap_store(struct device *device, struct device_attribute *attr, @@ -3251,7 +3253,7 @@ static ssize_t regmap_show(struct device *device, } static ssize_t fmode_show(struct device *device, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { int num = attr->attr.name[5] - 0x30; struct ddb *dev = dev_get_drvdata(device); @@ -3269,7 +3271,7 @@ static ssize_t devid_show(struct device *device, } static ssize_t fmode_store(struct device *device, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct ddb *dev = dev_get_drvdata(device); int num = attr->attr.name[5] - 0x30; @@ -3384,7 +3386,7 @@ static void ddb_device_attrs_del(struct ddb *dev) device_remove_file(dev->ddb_dev, &ddb_attrs_snr[i]); device_remove_file(dev->ddb_dev, &ddb_attrs_ctemp[i]); } - for (i = 0; ddb_attrs[i].attr.name != NULL; i++) + for (i = 0; ddb_attrs[i].attr.name; i++) device_remove_file(dev->ddb_dev, &ddb_attrs[i]); } @@ -3392,7 +3394,7 @@ static int ddb_device_attrs_add(struct ddb *dev) { int i; - for (i = 0; ddb_attrs[i].attr.name != NULL; i++) + for (i = 0; ddb_attrs[i].attr.name; i++) if (device_create_file(dev->ddb_dev, &ddb_attrs[i])) goto fail; for (i = 0; i < dev->link[0].info->temp_num; i++) @@ -3444,8 +3446,9 @@ int ddb_device_create(struct ddb *dev) device_destroy(&ddb_class, MKDEV(ddb_major, dev->nr)); ddbs[dev->nr] = NULL; dev->ddb_dev = ERR_PTR(-ENODEV); - } else + } else { ddb_num++; + } fail: mutex_unlock(&ddb_mutex); return res; @@ -3497,7 +3500,7 @@ static void tempmon_setfan(struct ddb_link *link) static void temp_handler(unsigned long data) { - struct ddb_link *link = (struct ddb_link *) data; + struct ddb_link *link = (struct ddb_link *)data; spin_lock(&link->temp_lock); tempmon_setfan(link); @@ -3516,10 +3519,10 @@ static int tempmon_init(struct ddb_link *link, int first_time) 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80 }; memcpy(link->temp_tab, temperature_table, - sizeof(temperature_table)); + sizeof(temperature_table)); } dev->handler[l][link->info->tempmon_irq] = temp_handler; - dev->handler_data[l][link->info->tempmon_irq] = (unsigned long) link; + dev->handler_data[l][link->info->tempmon_irq] = (unsigned long)link; ddblwritel(link, (TEMPMON_CONTROL_OVERTEMP | TEMPMON_CONTROL_AUTOSCAN | TEMPMON_CONTROL_INTENABLE), TEMPMON_CONTROL); @@ -3571,11 +3574,11 @@ static int ddb_init_boards(struct ddb *dev) ddbwritel(dev, 0, DDB_LINK_TAG(l) | BOARD_CONTROL); msleep(100); ddbwritel(dev, info->board_control_2, - DDB_LINK_TAG(l) | BOARD_CONTROL); + DDB_LINK_TAG(l) | BOARD_CONTROL); usleep_range(2000, 3000); ddbwritel(dev, - info->board_control_2 | info->board_control, - DDB_LINK_TAG(l) | BOARD_CONTROL); + info->board_control_2 | info->board_control, + DDB_LINK_TAG(l) | BOARD_CONTROL); usleep_range(2000, 3000); } ddb_init_tempmon(link); diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c b/drivers/media/pci/ddbridge/ddbridge-hw.c index 48248bcd59c29..c6d14925e2fc2 100644 --- a/drivers/media/pci/ddbridge/ddbridge-hw.c +++ b/drivers/media/pci/ddbridge/ddbridge-hw.c @@ -185,7 +185,7 @@ static const struct ddb_info ddb_ctv7 = { .board_control_2 = 4, }; -static const struct ddb_info ddb_satixS2v3 = { +static const struct ddb_info ddb_satixs2v3 = { .type = DDB_OCTOPUS, .name = "Mystique SaTiX-S2 V3 DVB adapter", .regmap = &octopus_map, @@ -336,7 +336,7 @@ static const struct ddb_device_id ddb_device_ids[] = { DDB_DEVID(0x0006, 0x0022, ddb_v7), DDB_DEVID(0x0006, 0x0024, ddb_v7a), DDB_DEVID(0x0003, 0x0030, ddb_dvbct), - DDB_DEVID(0x0003, 0xdb03, ddb_satixS2v3), + DDB_DEVID(0x0003, 0xdb03, ddb_satixs2v3), DDB_DEVID(0x0006, 0x0031, ddb_ctv7), DDB_DEVID(0x0006, 0x0032, ddb_ctv7), DDB_DEVID(0x0006, 0x0033, ddb_ctv7), @@ -367,8 +367,8 @@ const struct ddb_info *get_ddb_info(u16 vendor, u16 device, if (vendor == id->vendor && device == id->device && subvendor == id->subvendor && - ((subdevice == id->subdevice) || - (id->subdevice == 0xffff))) + (subdevice == id->subdevice || + id->subdevice == 0xffff)) return id->info; } diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c b/drivers/media/pci/ddbridge/ddbridge-i2c.c index e4d39c3270ae2..82a9a0e806fc2 100644 --- a/drivers/media/pci/ddbridge/ddbridge-i2c.c +++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c @@ -81,7 +81,7 @@ static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd) static int ddb_i2c_master_xfer(struct i2c_adapter *adapter, struct i2c_msg msg[], int num) { - struct ddb_i2c *i2c = (struct ddb_i2c *) i2c_get_adapdata(adapter); + struct ddb_i2c *i2c = (struct ddb_i2c *)i2c_get_adapdata(adapter); struct ddb *dev = i2c->dev; u8 addr = 0; @@ -149,7 +149,7 @@ void ddb_i2c_release(struct ddb *dev) static void i2c_handler(unsigned long priv) { - struct ddb_i2c *i2c = (struct ddb_i2c *) priv; + struct ddb_i2c *i2c = (struct ddb_i2c *)priv; complete(&i2c->completion); } @@ -171,20 +171,20 @@ static int ddb_i2c_add(struct ddb *dev, struct ddb_i2c *i2c, (regmap->i2c->base + regmap->i2c->size * i); ddbwritel(dev, I2C_SPEED_100, i2c->regs + I2C_TIMING); ddbwritel(dev, ((i2c->rbuf & 0xffff) << 16) | (i2c->wbuf & 0xffff), - i2c->regs + I2C_TASKADDRESS); + i2c->regs + I2C_TASKADDRESS); init_completion(&i2c->completion); adap = &i2c->adap; i2c_set_adapdata(adap, i2c); #ifdef I2C_ADAP_CLASS_TV_DIGITAL - adap->class = I2C_ADAP_CLASS_TV_DIGITAL|I2C_CLASS_TV_ANALOG; + adap->class = I2C_ADAP_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG; #else #ifdef I2C_CLASS_TV_ANALOG adap->class = I2C_CLASS_TV_ANALOG; #endif #endif snprintf(adap->name, I2C_NAME_SIZE, "ddbridge_%02x.%x.%x", - dev->nr, i2c->link, i); + dev->nr, i2c->link, i); adap->algo = &ddb_i2c_algo; adap->algo_data = (void *)i2c; adap->dev.parent = dev->dev; @@ -210,7 +210,7 @@ int ddb_i2c_init(struct ddb *dev) if (!(dev->link[l].info->i2c_mask & (1 << i))) continue; i2c = &dev->i2c[num]; - dev->handler_data[l][i + base] = (unsigned long) i2c; + dev->handler_data[l][i + base] = (unsigned long)i2c; dev->handler[l][i + base] = i2c_handler; stat = ddb_i2c_add(dev, i2c, regmap, l, i, num); if (stat) @@ -224,7 +224,9 @@ int ddb_i2c_init(struct ddb *dev) adap = &i2c->adap; i2c_del_adapter(adap); } - } else + } else { dev->i2c_num = num; + } + return stat; } diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index ccac7fe313369..26497d6b13958 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -107,7 +107,7 @@ static void ddb_irq_exit(struct ddb *dev) static void ddb_remove(struct pci_dev *pdev) { - struct ddb *dev = (struct ddb *) pci_get_drvdata(pdev); + struct ddb *dev = (struct ddb *)pci_get_drvdata(pdev); ddb_device_destroy(dev); ddb_ports_detach(dev); @@ -132,9 +132,10 @@ static void ddb_irq_msi(struct ddb *dev, int nr) if (stat >= 1) { dev->msi = stat; dev_info(dev->dev, "using %d MSI interrupt(s)\n", - dev->msi); - } else + dev->msi); + } else { dev_info(dev->dev, "MSI not available.\n"); + } } } #endif @@ -160,11 +161,11 @@ static int ddb_irq_init(struct ddb *dev) irq_flag = 0; if (dev->msi == 2) { stat = request_irq(dev->pdev->irq, ddb_irq_handler0, - irq_flag, "ddbridge", (void *) dev); + irq_flag, "ddbridge", (void *)dev); if (stat < 0) return stat; stat = request_irq(dev->pdev->irq + 1, ddb_irq_handler1, - irq_flag, "ddbridge", (void *) dev); + irq_flag, "ddbridge", (void *)dev); if (stat < 0) { free_irq(dev->pdev->irq, dev); return stat; @@ -173,7 +174,7 @@ static int ddb_irq_init(struct ddb *dev) #endif { stat = request_irq(dev->pdev->irq, ddb_irq_handler, - irq_flag, "ddbridge", (void *) dev); + irq_flag, "ddbridge", (void *)dev); if (stat < 0) return stat; } @@ -188,7 +189,7 @@ static int ddb_irq_init(struct ddb *dev) } static int ddb_probe(struct pci_dev *pdev, - const struct pci_device_id *id) + const struct pci_device_id *id) { struct ddb *dev; int stat = 0; @@ -202,8 +203,8 @@ static int ddb_probe(struct pci_dev *pdev, if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) return -ENODEV; - dev = vzalloc(sizeof(struct ddb)); - if (dev == NULL) + dev = vzalloc(sizeof(*dev)); + if (!dev) return -ENOMEM; mutex_init(&dev->mutex); @@ -242,7 +243,7 @@ static int ddb_probe(struct pci_dev *pdev, dev->link[0].ids.regmapid = ddbreadl(dev, 4); dev_info(&pdev->dev, "HW %08x REGMAP %08x\n", - dev->link[0].ids.hwid, dev->link[0].ids.regmapid); + dev->link[0].ids.hwid, dev->link[0].ids.regmapid); ddbwritel(dev, 0, DMA_BASE_READ); ddbwritel(dev, 0, DMA_BASE_WRITE); @@ -317,7 +318,7 @@ static __init int module_init_ddbridge(void) if (ddb_class_create() < 0) return -1; ddb_wq = create_workqueue("ddbridge"); - if (ddb_wq == NULL) + if (!ddb_wq) goto exit1; stat = pci_register_driver(&ddb_pci_driver); if (stat < 0) diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.c b/drivers/media/pci/ddbridge/ddbridge-maxs8.c index f8a53bc7c86c5..06d57a4772fa3 100644 --- a/drivers/media/pci/ddbridge/ddbridge-maxs8.c +++ b/drivers/media/pci/ddbridge/ddbridge-maxs8.c @@ -68,7 +68,7 @@ static int lnb_command(struct ddb *dev, u32 link, u32 lnb, u32 cmd) } if (c == 10) dev_info(dev->dev, "%s lnb = %08x cmd = %08x\n", - __func__, lnb, cmd); + __func__, lnb, cmd); return 0; } @@ -123,7 +123,7 @@ static int lnb_set_sat(struct ddb *dev, u32 link, u32 input, u32 sat, u32 band, } static int lnb_set_tone(struct ddb *dev, u32 link, u32 input, - enum fe_sec_tone_mode tone) + enum fe_sec_tone_mode tone) { int s = 0; u32 mask = (1ULL << input); @@ -149,7 +149,7 @@ static int lnb_set_tone(struct ddb *dev, u32 link, u32 input, } static int lnb_set_voltage(struct ddb *dev, u32 link, u32 input, - enum fe_sec_voltage voltage) + enum fe_sec_voltage voltage) { int s = 0; @@ -291,34 +291,45 @@ static int max_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage) if (nv != ov) { if (nv) { - lnb_set_voltage(dev, - port->lnr, 0, SEC_VOLTAGE_13); + lnb_set_voltage( + dev, port->lnr, + 0, SEC_VOLTAGE_13); if (fmode == 1) { - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 0, SEC_VOLTAGE_13); if (old_quattro) { - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 1, SEC_VOLTAGE_18); - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 2, SEC_VOLTAGE_13); } else { - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 1, SEC_VOLTAGE_13); - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 2, SEC_VOLTAGE_18); } - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 3, SEC_VOLTAGE_18); } } else { - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 0, SEC_VOLTAGE_OFF); if (fmode == 1) { - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 1, SEC_VOLTAGE_OFF); - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 2, SEC_VOLTAGE_OFF); - lnb_set_voltage(dev, port->lnr, + lnb_set_voltage( + dev, port->lnr, 3, SEC_VOLTAGE_OFF); } } @@ -331,7 +342,6 @@ static int max_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage) static int max_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) { - return 0; } @@ -414,7 +424,7 @@ int fe_attach_mxl5xx(struct ddb_input *input) tuner = 0; dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg, - demod, tuner, &dvb->set_input); + demod, tuner, &dvb->set_input); if (!dvb->fe) { dev_err(dev->dev, "No MXL5XX found!\n"); diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h b/drivers/media/pci/ddbridge/ddbridge-regs.h index 9d44f8d3af753..23d74ff83fe47 100644 --- a/drivers/media/pci/ddbridge/ddbridge-regs.h +++ b/drivers/media/pci/ddbridge/ddbridge-regs.h @@ -95,27 +95,27 @@ #define DMA_BASE_WRITE (0x100) #define DMA_BASE_READ (0x140) -#define TS_CONTROL(_io) (_io->regs + 0x00) -#define TS_CONTROL2(_io) (_io->regs + 0x04) +#define TS_CONTROL(_io) ((_io)->regs + 0x00) +#define TS_CONTROL2(_io) ((_io)->regs + 0x04) /* ------------------------------------------------------------------------- */ /* DMA Buffer */ -#define DMA_BUFFER_CONTROL(_dma) (_dma->regs + 0x00) -#define DMA_BUFFER_ACK(_dma) (_dma->regs + 0x04) -#define DMA_BUFFER_CURRENT(_dma) (_dma->regs + 0x08) -#define DMA_BUFFER_SIZE(_dma) (_dma->regs + 0x0c) +#define DMA_BUFFER_CONTROL(_dma) ((_dma)->regs + 0x00) +#define DMA_BUFFER_ACK(_dma) ((_dma)->regs + 0x04) +#define DMA_BUFFER_CURRENT(_dma) ((_dma)->regs + 0x08) +#define DMA_BUFFER_SIZE(_dma) ((_dma)->regs + 0x0c) /* ------------------------------------------------------------------------- */ /* CI Interface (only CI-Bridge) */ -#define CI_BASE (0x400) -#define CI_CONTROL(i) (CI_BASE + (i) * 32 + 0x00) +#define CI_BASE (0x400) +#define CI_CONTROL(i) (CI_BASE + (i) * 32 + 0x00) -#define CI_DO_ATTRIBUTE_RW(i) (CI_BASE + (i) * 32 + 0x04) -#define CI_DO_IO_RW(i) (CI_BASE + (i) * 32 + 0x08) -#define CI_READDATA(i) (CI_BASE + (i) * 32 + 0x0c) -#define CI_DO_READ_ATTRIBUTES(i) (CI_BASE + (i) * 32 + 0x10) +#define CI_DO_ATTRIBUTE_RW(i) (CI_BASE + (i) * 32 + 0x04) +#define CI_DO_IO_RW(i) (CI_BASE + (i) * 32 + 0x08) +#define CI_READDATA(i) (CI_BASE + (i) * 32 + 0x0c) +#define CI_DO_READ_ATTRIBUTES(i) (CI_BASE + (i) * 32 + 0x10) #define CI_RESET_CAM (0x00000001) #define CI_POWER_ON (0x00000002) @@ -132,7 +132,7 @@ #define CI_BUFFER_BASE (0x3000) #define CI_BUFFER_SIZE (0x0800) -#define CI_BUFFER(i) (CI_BUFFER_BASE + (i) * CI_BUFFER_SIZE) +#define CI_BUFFER(i) (CI_BUFFER_BASE + (i) * CI_BUFFER_SIZE) /* ------------------------------------------------------------------------- */ /* LNB commands (mxl5xx / Max S8) */ @@ -140,7 +140,7 @@ #define LNB_BASE (0x400) #define LNB_CONTROL(i) (LNB_BASE + (i) * 0x20 + 0x00) -#define LNB_CMD (7ULL << 0) +#define LNB_CMD (7ULL << 0) #define LNB_CMD_NOP 0 #define LNB_CMD_INIT 1 #define LNB_CMD_LOW 3 @@ -148,8 +148,8 @@ #define LNB_CMD_OFF 5 #define LNB_CMD_DISEQC 6 -#define LNB_BUSY (1ULL << 4) -#define LNB_TONE (1ULL << 15) +#define LNB_BUSY BIT_ULL(4) +#define LNB_TONE BIT_ULL(15) #define LNB_BUF_LEVEL(i) (LNB_BASE + (i) * 0x20 + 0x10) #define LNB_BUF_WRITE(i) (LNB_BASE + (i) * 0x20 + 0x14) diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index e9afa96bd9df3..e8432e49564c7 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -143,11 +143,11 @@ struct ddb_info { #define DMA_MAX_BUFS 32 /* hardware table limit */ #define INPUT_DMA_BUFS 8 -#define INPUT_DMA_SIZE (128*47*21) +#define INPUT_DMA_SIZE (128 * 47 * 21) #define INPUT_DMA_IRQ_DIV 1 #define OUTPUT_DMA_BUFS 8 -#define OUTPUT_DMA_SIZE (128*47*21) +#define OUTPUT_DMA_SIZE (128 * 47 * 21) #define OUTPUT_DMA_IRQ_DIV 1 struct ddb; @@ -166,7 +166,7 @@ struct ddb_dma { u32 bufval; struct work_struct work; - spinlock_t lock; + spinlock_t lock; /* DMA lock */ wait_queue_head_t wq; int running; u32 stat; @@ -196,17 +196,16 @@ struct ddb_dvb { int (*i2c_gate_ctrl)(struct dvb_frontend *, int); int (*set_voltage)(struct dvb_frontend *fe, - enum fe_sec_voltage voltage); + enum fe_sec_voltage voltage); int (*set_input)(struct dvb_frontend *fe, int input); int (*diseqc_send_master_cmd)(struct dvb_frontend *fe, - struct dvb_diseqc_master_cmd *cmd); + struct dvb_diseqc_master_cmd *cmd); }; struct ddb_ci { struct dvb_ca_en50221 en; struct ddb_port *port; u32 nr; - struct mutex lock; }; struct ddb_io { @@ -240,7 +239,7 @@ struct ddb_port { u32 regs; u32 lnr; struct ddb_i2c *i2c; - struct mutex i2c_gate_lock; + struct mutex i2c_gate_lock; /* I2C access lock */ u32 class; #define DDB_PORT_NONE 0 #define DDB_PORT_CI 1 @@ -297,7 +296,7 @@ struct ddb_port { #define TS_CAPTURE_LEN (4096) struct ddb_lnb { - struct mutex lock; + struct mutex lock; /* lock lnb access */ u32 tone; enum fe_sec_voltage oldvoltage[4]; u32 voltage[4]; @@ -310,54 +309,54 @@ struct ddb_link { const struct ddb_info *info; u32 nr; u32 regs; - spinlock_t lock; - struct mutex flash_mutex; + spinlock_t lock; /* lock link access */ + struct mutex flash_mutex; /* lock flash access */ struct ddb_lnb lnb; struct tasklet_struct tasklet; struct ddb_ids ids; - spinlock_t temp_lock; + spinlock_t temp_lock; /* lock temp chip access */ int overtemperature_error; u8 temp_tab[11]; }; struct ddb { - struct pci_dev *pdev; - struct platform_device *pfdev; - struct device *dev; + struct pci_dev *pdev; + struct platform_device *pfdev; + struct device *dev; - int msi; + int msi; struct workqueue_struct *wq; - u32 has_dma; - - struct ddb_link link[DDB_MAX_LINK]; - unsigned char __iomem *regs; - u32 regs_len; - u32 port_num; - struct ddb_port port[DDB_MAX_PORT]; - u32 i2c_num; - struct ddb_i2c i2c[DDB_MAX_I2C]; - struct ddb_input input[DDB_MAX_INPUT]; - struct ddb_output output[DDB_MAX_OUTPUT]; - struct dvb_adapter adap[DDB_MAX_INPUT]; - struct ddb_dma idma[DDB_MAX_INPUT]; - struct ddb_dma odma[DDB_MAX_OUTPUT]; - - void (*handler[4][256])(unsigned long); - unsigned long handler_data[4][256]; - - struct device *ddb_dev; - u32 ddb_dev_users; - u32 nr; - u8 iobuf[1028]; - - u8 leds; - u32 ts_irq; - u32 i2c_irq; - - struct mutex mutex; - - u8 tsbuf[TS_CAPTURE_LEN]; + u32 has_dma; + + struct ddb_link link[DDB_MAX_LINK]; + unsigned char __iomem *regs; + u32 regs_len; + u32 port_num; + struct ddb_port port[DDB_MAX_PORT]; + u32 i2c_num; + struct ddb_i2c i2c[DDB_MAX_I2C]; + struct ddb_input input[DDB_MAX_INPUT]; + struct ddb_output output[DDB_MAX_OUTPUT]; + struct dvb_adapter adap[DDB_MAX_INPUT]; + struct ddb_dma idma[DDB_MAX_INPUT]; + struct ddb_dma odma[DDB_MAX_OUTPUT]; + + void (*handler[4][256])(unsigned long); + unsigned long handler_data[4][256]; + + struct device *ddb_dev; + u32 ddb_dev_users; + u32 nr; + u8 iobuf[1028]; + + u8 leds; + u32 ts_irq; + u32 i2c_irq; + + struct mutex mutex; /* lock access to global ddb array */ + + u8 tsbuf[TS_CAPTURE_LEN]; }; /****************************************************************************/ -- GitLab From 70d3ae1bea1037e27686ff704f5c8b3941e66c47 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:52 -0400 Subject: [PATCH 0095/1190] media: ddbridge: split off CI (common interface) from ddbridge-core Move all CI device support related code from ddbridge-core to ddbridge-ci, following the previously split off MaxS4/8 support. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/Makefile | 4 +- drivers/media/pci/ddbridge/ddbridge-ci.c | 349 +++++++++++++++++++++ drivers/media/pci/ddbridge/ddbridge-ci.h | 30 ++ drivers/media/pci/ddbridge/ddbridge-core.c | 330 +------------------ 4 files changed, 383 insertions(+), 330 deletions(-) create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.c create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.h diff --git a/drivers/media/pci/ddbridge/Makefile b/drivers/media/pci/ddbridge/Makefile index 7453b65104ff7..1d370418d105d 100644 --- a/drivers/media/pci/ddbridge/Makefile +++ b/drivers/media/pci/ddbridge/Makefile @@ -3,8 +3,8 @@ # Makefile for the ddbridge device driver # -ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-hw.o \ - ddbridge-i2c.o ddbridge-maxs8.o +ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \ + ddbridge-hw.o ddbridge-i2c.o ddbridge-maxs8.o obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c new file mode 100644 index 0000000000000..c775b17c32289 --- /dev/null +++ b/drivers/media/pci/ddbridge/ddbridge-ci.c @@ -0,0 +1,349 @@ +/* + * ddbridge-ci.c: Digital Devices bridge CI (DuoFlex, CI Bridge) support + * + * Copyright (C) 2010-2017 Digital Devices GmbH + * Marcus Metzler + * Ralph Metzler + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 only, as published by the Free Software Foundation. + * + * 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. + * + * To obtain the license, point your browser to + * http://www.gnu.org/copyleft/gpl.html + */ + +#include "ddbridge.h" +#include "ddbridge-regs.h" +#include "ddbridge-io.h" +#include "ddbridge-i2c.h" + +#include "cxd2099.h" + +/* Octopus CI internal CI interface */ + +static int wait_ci_ready(struct ddb_ci *ci) +{ + u32 count = 10; + + ndelay(500); + do { + if (ddbreadl(ci->port->dev, + CI_CONTROL(ci->nr)) & CI_READY) + break; + usleep_range(1, 2); + if ((--count) == 0) + return -1; + } while (1); + return 0; +} + +static int read_attribute_mem(struct dvb_ca_en50221 *ca, + int slot, int address) +{ + struct ddb_ci *ci = ca->data; + u32 val, off = (address >> 1) & (CI_BUFFER_SIZE - 1); + + if (address > CI_BUFFER_SIZE) + return -1; + ddbwritel(ci->port->dev, CI_READ_CMD | (1 << 16) | address, + CI_DO_READ_ATTRIBUTES(ci->nr)); + wait_ci_ready(ci); + val = 0xff & ddbreadl(ci->port->dev, CI_BUFFER(ci->nr) + off); + return val; +} + +static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, + int address, u8 value) +{ + struct ddb_ci *ci = ca->data; + + ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address, + CI_DO_ATTRIBUTE_RW(ci->nr)); + wait_ci_ready(ci); + return 0; +} + +static int read_cam_control(struct dvb_ca_en50221 *ca, + int slot, u8 address) +{ + u32 count = 100; + struct ddb_ci *ci = ca->data; + u32 res; + + ddbwritel(ci->port->dev, CI_READ_CMD | address, + CI_DO_IO_RW(ci->nr)); + ndelay(500); + do { + res = ddbreadl(ci->port->dev, CI_READDATA(ci->nr)); + if (res & CI_READY) + break; + usleep_range(1, 2); + if ((--count) == 0) + return -1; + } while (1); + return 0xff & res; +} + +static int write_cam_control(struct dvb_ca_en50221 *ca, int slot, + u8 address, u8 value) +{ + struct ddb_ci *ci = ca->data; + + ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address, + CI_DO_IO_RW(ci->nr)); + wait_ci_ready(ci); + return 0; +} + +static int slot_reset(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + + ddbwritel(ci->port->dev, CI_POWER_ON, + CI_CONTROL(ci->nr)); + msleep(100); + ddbwritel(ci->port->dev, CI_POWER_ON | CI_RESET_CAM, + CI_CONTROL(ci->nr)); + ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON | CI_RESET_CAM, + CI_CONTROL(ci->nr)); + usleep_range(20, 25); + ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON, + CI_CONTROL(ci->nr)); + return 0; +} + +static int slot_shutdown(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + + ddbwritel(ci->port->dev, 0, CI_CONTROL(ci->nr)); + msleep(300); + return 0; +} + +static int slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr)); + + ddbwritel(ci->port->dev, val | CI_BYPASS_DISABLE, + CI_CONTROL(ci->nr)); + return 0; +} + +static int poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) +{ + struct ddb_ci *ci = ca->data; + u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr)); + int stat = 0; + + if (val & CI_CAM_DETECT) + stat |= DVB_CA_EN50221_POLL_CAM_PRESENT; + if (val & CI_CAM_READY) + stat |= DVB_CA_EN50221_POLL_CAM_READY; + return stat; +} + +static struct dvb_ca_en50221 en_templ = { + .read_attribute_mem = read_attribute_mem, + .write_attribute_mem = write_attribute_mem, + .read_cam_control = read_cam_control, + .write_cam_control = write_cam_control, + .slot_reset = slot_reset, + .slot_shutdown = slot_shutdown, + .slot_ts_enable = slot_ts_enable, + .poll_slot_status = poll_slot_status, +}; + +static void ci_attach(struct ddb_port *port) +{ + struct ddb_ci *ci = NULL; + + ci = kzalloc(sizeof(*ci), GFP_KERNEL); + if (!ci) + return; + memcpy(&ci->en, &en_templ, sizeof(en_templ)); + ci->en.data = ci; + port->en = &ci->en; + ci->port = port; + ci->nr = port->nr - 2; +} + +/* DuoFlex Dual CI support */ + +static int write_creg(struct ddb_ci *ci, u8 data, u8 mask) +{ + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + + ci->port->creg = (ci->port->creg & ~mask) | data; + return i2c_write_reg(i2c, adr, 0x02, ci->port->creg); +} + +static int read_attribute_mem_xo2(struct dvb_ca_en50221 *ca, + int slot, int address) +{ + struct ddb_ci *ci = ca->data; + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + int res; + u8 val; + + res = i2c_read_reg16(i2c, adr, 0x8000 | address, &val); + return res ? res : val; +} + +static int write_attribute_mem_xo2(struct dvb_ca_en50221 *ca, int slot, + int address, u8 value) +{ + struct ddb_ci *ci = ca->data; + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + + return i2c_write_reg16(i2c, adr, 0x8000 | address, value); +} + +static int read_cam_control_xo2(struct dvb_ca_en50221 *ca, + int slot, u8 address) +{ + struct ddb_ci *ci = ca->data; + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + u8 val; + int res; + + res = i2c_read_reg(i2c, adr, 0x20 | (address & 3), &val); + return res ? res : val; +} + +static int write_cam_control_xo2(struct dvb_ca_en50221 *ca, int slot, + u8 address, u8 value) +{ + struct ddb_ci *ci = ca->data; + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + + return i2c_write_reg(i2c, adr, 0x20 | (address & 3), value); +} + +static int slot_reset_xo2(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + + dev_dbg(ci->port->dev->dev, "%s\n", __func__); + write_creg(ci, 0x01, 0x01); + write_creg(ci, 0x04, 0x04); + msleep(20); + write_creg(ci, 0x02, 0x02); + write_creg(ci, 0x00, 0x04); + write_creg(ci, 0x18, 0x18); + return 0; +} + +static int slot_shutdown_xo2(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + + dev_dbg(ci->port->dev->dev, "%s\n", __func__); + write_creg(ci, 0x10, 0xff); + write_creg(ci, 0x08, 0x08); + return 0; +} + +static int slot_ts_enable_xo2(struct dvb_ca_en50221 *ca, int slot) +{ + struct ddb_ci *ci = ca->data; + + dev_info(ci->port->dev->dev, "%s\n", __func__); + write_creg(ci, 0x00, 0x10); + return 0; +} + +static int poll_slot_status_xo2(struct dvb_ca_en50221 *ca, int slot, int open) +{ + struct ddb_ci *ci = ca->data; + struct i2c_adapter *i2c = &ci->port->i2c->adap; + u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; + u8 val = 0; + int stat = 0; + + i2c_read_reg(i2c, adr, 0x01, &val); + + if (val & 2) + stat |= DVB_CA_EN50221_POLL_CAM_PRESENT; + if (val & 1) + stat |= DVB_CA_EN50221_POLL_CAM_READY; + return stat; +} + +static struct dvb_ca_en50221 en_xo2_templ = { + .read_attribute_mem = read_attribute_mem_xo2, + .write_attribute_mem = write_attribute_mem_xo2, + .read_cam_control = read_cam_control_xo2, + .write_cam_control = write_cam_control_xo2, + .slot_reset = slot_reset_xo2, + .slot_shutdown = slot_shutdown_xo2, + .slot_ts_enable = slot_ts_enable_xo2, + .poll_slot_status = poll_slot_status_xo2, +}; + +static void ci_xo2_attach(struct ddb_port *port) +{ + struct ddb_ci *ci; + + ci = kzalloc(sizeof(*ci), GFP_KERNEL); + if (!ci) + return; + memcpy(&ci->en, &en_xo2_templ, sizeof(en_xo2_templ)); + ci->en.data = ci; + port->en = &ci->en; + ci->port = port; + ci->nr = port->nr - 2; + ci->port->creg = 0; + write_creg(ci, 0x10, 0xff); + write_creg(ci, 0x08, 0x08); +} + +static struct cxd2099_cfg cxd_cfg = { + .bitrate = 72000, + .adr = 0x40, + .polarity = 1, + .clock_mode = 1, + .max_i2c = 512, +}; + +int ddb_ci_attach(struct ddb_port *port, u32 bitrate) +{ + switch (port->type) { + case DDB_CI_EXTERNAL_SONY: + cxd_cfg.bitrate = bitrate; + port->en = cxd2099_attach(&cxd_cfg, port, &port->i2c->adap); + if (!port->en) + return -ENODEV; + dvb_ca_en50221_init(port->dvb[0].adap, + port->en, 0, 1); + break; + + case DDB_CI_EXTERNAL_XO2: + case DDB_CI_EXTERNAL_XO2_B: + ci_xo2_attach(port); + if (!port->en) + return -ENODEV; + dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1); + break; + + case DDB_CI_INTERNAL: + ci_attach(port); + if (!port->en) + return -ENODEV; + dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1); + break; + } + return 0; +} diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.h b/drivers/media/pci/ddbridge/ddbridge-ci.h new file mode 100644 index 0000000000000..3a5d7ffab7b78 --- /dev/null +++ b/drivers/media/pci/ddbridge/ddbridge-ci.h @@ -0,0 +1,30 @@ +/* + * ddbridge-ci.h: Digital Devices bridge CI (DuoFlex, CI Bridge) support + * + * Copyright (C) 2010-2017 Digital Devices GmbH + * Marcus Metzler + * Ralph Metzler + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 only, as published by the Free Software Foundation. + * + * 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. + * + * To obtain the license, point your browser to + * http://www.gnu.org/copyleft/gpl.html + */ + +#ifndef __DDBRIDGE_CI_H__ +#define __DDBRIDGE_CI_H__ + +#include "ddbridge.h" + +/******************************************************************************/ + +int ddb_ci_attach(struct ddb_port *port, u32 bitrate); + +#endif /* __DDBRIDGE_CI_H__ */ diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 0eaa2efdcc54f..6354e00f4c9be 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -38,6 +38,7 @@ #include "ddbridge-i2c.h" #include "ddbridge-regs.h" #include "ddbridge-maxs8.h" +#include "ddbridge-ci.h" #include "ddbridge-io.h" #include "tda18271c2dd.h" @@ -1917,333 +1918,6 @@ static void ddb_port_probe(struct ddb_port *port) /****************************************************************************/ /****************************************************************************/ -static int wait_ci_ready(struct ddb_ci *ci) -{ - u32 count = 10; - - ndelay(500); - do { - if (ddbreadl(ci->port->dev, - CI_CONTROL(ci->nr)) & CI_READY) - break; - usleep_range(1, 2); - if ((--count) == 0) - return -1; - } while (1); - return 0; -} - -static int read_attribute_mem(struct dvb_ca_en50221 *ca, - int slot, int address) -{ - struct ddb_ci *ci = ca->data; - u32 val, off = (address >> 1) & (CI_BUFFER_SIZE - 1); - - if (address > CI_BUFFER_SIZE) - return -1; - ddbwritel(ci->port->dev, CI_READ_CMD | (1 << 16) | address, - CI_DO_READ_ATTRIBUTES(ci->nr)); - wait_ci_ready(ci); - val = 0xff & ddbreadl(ci->port->dev, CI_BUFFER(ci->nr) + off); - return val; -} - -static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, - int address, u8 value) -{ - struct ddb_ci *ci = ca->data; - - ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address, - CI_DO_ATTRIBUTE_RW(ci->nr)); - wait_ci_ready(ci); - return 0; -} - -static int read_cam_control(struct dvb_ca_en50221 *ca, - int slot, u8 address) -{ - u32 count = 100; - struct ddb_ci *ci = ca->data; - u32 res; - - ddbwritel(ci->port->dev, CI_READ_CMD | address, - CI_DO_IO_RW(ci->nr)); - ndelay(500); - do { - res = ddbreadl(ci->port->dev, CI_READDATA(ci->nr)); - if (res & CI_READY) - break; - usleep_range(1, 2); - if ((--count) == 0) - return -1; - } while (1); - return 0xff & res; -} - -static int write_cam_control(struct dvb_ca_en50221 *ca, int slot, - u8 address, u8 value) -{ - struct ddb_ci *ci = ca->data; - - ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address, - CI_DO_IO_RW(ci->nr)); - wait_ci_ready(ci); - return 0; -} - -static int slot_reset(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - - ddbwritel(ci->port->dev, CI_POWER_ON, - CI_CONTROL(ci->nr)); - msleep(100); - ddbwritel(ci->port->dev, CI_POWER_ON | CI_RESET_CAM, - CI_CONTROL(ci->nr)); - ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON | CI_RESET_CAM, - CI_CONTROL(ci->nr)); - usleep_range(20, 25); - ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON, - CI_CONTROL(ci->nr)); - return 0; -} - -static int slot_shutdown(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - - ddbwritel(ci->port->dev, 0, CI_CONTROL(ci->nr)); - msleep(300); - return 0; -} - -static int slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr)); - - ddbwritel(ci->port->dev, val | CI_BYPASS_DISABLE, - CI_CONTROL(ci->nr)); - return 0; -} - -static int poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) -{ - struct ddb_ci *ci = ca->data; - u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr)); - int stat = 0; - - if (val & CI_CAM_DETECT) - stat |= DVB_CA_EN50221_POLL_CAM_PRESENT; - if (val & CI_CAM_READY) - stat |= DVB_CA_EN50221_POLL_CAM_READY; - return stat; -} - -static struct dvb_ca_en50221 en_templ = { - .read_attribute_mem = read_attribute_mem, - .write_attribute_mem = write_attribute_mem, - .read_cam_control = read_cam_control, - .write_cam_control = write_cam_control, - .slot_reset = slot_reset, - .slot_shutdown = slot_shutdown, - .slot_ts_enable = slot_ts_enable, - .poll_slot_status = poll_slot_status, -}; - -static void ci_attach(struct ddb_port *port) -{ - struct ddb_ci *ci = NULL; - - ci = kzalloc(sizeof(*ci), GFP_KERNEL); - if (!ci) - return; - memcpy(&ci->en, &en_templ, sizeof(en_templ)); - ci->en.data = ci; - port->en = &ci->en; - ci->port = port; - ci->nr = port->nr - 2; -} - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -static int write_creg(struct ddb_ci *ci, u8 data, u8 mask) -{ - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - - ci->port->creg = (ci->port->creg & ~mask) | data; - return i2c_write_reg(i2c, adr, 0x02, ci->port->creg); -} - -static int read_attribute_mem_xo2(struct dvb_ca_en50221 *ca, - int slot, int address) -{ - struct ddb_ci *ci = ca->data; - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - int res; - u8 val; - - res = i2c_read_reg16(i2c, adr, 0x8000 | address, &val); - return res ? res : val; -} - -static int write_attribute_mem_xo2(struct dvb_ca_en50221 *ca, int slot, - int address, u8 value) -{ - struct ddb_ci *ci = ca->data; - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - - return i2c_write_reg16(i2c, adr, 0x8000 | address, value); -} - -static int read_cam_control_xo2(struct dvb_ca_en50221 *ca, - int slot, u8 address) -{ - struct ddb_ci *ci = ca->data; - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - u8 val; - int res; - - res = i2c_read_reg(i2c, adr, 0x20 | (address & 3), &val); - return res ? res : val; -} - -static int write_cam_control_xo2(struct dvb_ca_en50221 *ca, int slot, - u8 address, u8 value) -{ - struct ddb_ci *ci = ca->data; - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - - return i2c_write_reg(i2c, adr, 0x20 | (address & 3), value); -} - -static int slot_reset_xo2(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - - dev_dbg(ci->port->dev->dev, "%s\n", __func__); - write_creg(ci, 0x01, 0x01); - write_creg(ci, 0x04, 0x04); - msleep(20); - write_creg(ci, 0x02, 0x02); - write_creg(ci, 0x00, 0x04); - write_creg(ci, 0x18, 0x18); - return 0; -} - -static int slot_shutdown_xo2(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - - dev_dbg(ci->port->dev->dev, "%s\n", __func__); - write_creg(ci, 0x10, 0xff); - write_creg(ci, 0x08, 0x08); - return 0; -} - -static int slot_ts_enable_xo2(struct dvb_ca_en50221 *ca, int slot) -{ - struct ddb_ci *ci = ca->data; - - dev_info(ci->port->dev->dev, "%s\n", __func__); - write_creg(ci, 0x00, 0x10); - return 0; -} - -static int poll_slot_status_xo2(struct dvb_ca_en50221 *ca, int slot, int open) -{ - struct ddb_ci *ci = ca->data; - struct i2c_adapter *i2c = &ci->port->i2c->adap; - u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13; - u8 val = 0; - int stat = 0; - - i2c_read_reg(i2c, adr, 0x01, &val); - - if (val & 2) - stat |= DVB_CA_EN50221_POLL_CAM_PRESENT; - if (val & 1) - stat |= DVB_CA_EN50221_POLL_CAM_READY; - return stat; -} - -static struct dvb_ca_en50221 en_xo2_templ = { - .read_attribute_mem = read_attribute_mem_xo2, - .write_attribute_mem = write_attribute_mem_xo2, - .read_cam_control = read_cam_control_xo2, - .write_cam_control = write_cam_control_xo2, - .slot_reset = slot_reset_xo2, - .slot_shutdown = slot_shutdown_xo2, - .slot_ts_enable = slot_ts_enable_xo2, - .poll_slot_status = poll_slot_status_xo2, -}; - -static void ci_xo2_attach(struct ddb_port *port) -{ - struct ddb_ci *ci; - - ci = kzalloc(sizeof(*ci), GFP_KERNEL); - if (!ci) - return; - memcpy(&ci->en, &en_xo2_templ, sizeof(en_xo2_templ)); - ci->en.data = ci; - port->en = &ci->en; - ci->port = port; - ci->nr = port->nr - 2; - ci->port->creg = 0; - write_creg(ci, 0x10, 0xff); - write_creg(ci, 0x08, 0x08); -} - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -static struct cxd2099_cfg cxd_cfg = { - .bitrate = 72000, - .adr = 0x40, - .polarity = 1, - .clock_mode = 1, - .max_i2c = 512, -}; - -static int ddb_ci_attach(struct ddb_port *port) -{ - switch (port->type) { - case DDB_CI_EXTERNAL_SONY: - cxd_cfg.bitrate = ci_bitrate; - port->en = cxd2099_attach(&cxd_cfg, port, &port->i2c->adap); - if (!port->en) - return -ENODEV; - dvb_ca_en50221_init(port->dvb[0].adap, - port->en, 0, 1); - break; - - case DDB_CI_EXTERNAL_XO2: - case DDB_CI_EXTERNAL_XO2_B: - ci_xo2_attach(port); - if (!port->en) - return -ENODEV; - dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1); - break; - - case DDB_CI_INTERNAL: - ci_attach(port); - if (!port->en) - return -ENODEV; - dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1); - break; - } - return 0; -} - static int ddb_port_attach(struct ddb_port *port) { int ret = 0; @@ -2260,7 +1934,7 @@ static int ddb_port_attach(struct ddb_port *port) port->input[1]->redi = port->input[1]; break; case DDB_PORT_CI: - ret = ddb_ci_attach(port); + ret = ddb_ci_attach(port, ci_bitrate); if (ret < 0) break; /* fall-through */ -- GitLab From 04bdf863606fbedb41a94d006cd19e9f2ae69c3b Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:53 -0400 Subject: [PATCH 0096/1190] media: ddbridge/ci: change debug printing to debug severity slot_ts_enable_xo2() logged debug output to info instead of debug, so fix this up. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-ci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c index c775b17c32289..457c711aaced4 100644 --- a/drivers/media/pci/ddbridge/ddbridge-ci.c +++ b/drivers/media/pci/ddbridge/ddbridge-ci.c @@ -260,7 +260,7 @@ static int slot_ts_enable_xo2(struct dvb_ca_en50221 *ca, int slot) { struct ddb_ci *ci = ca->data; - dev_info(ci->port->dev->dev, "%s\n", __func__); + dev_dbg(ci->port->dev->dev, "%s\n", __func__); write_creg(ci, 0x00, 0x10); return 0; } -- GitLab From 2d8c98b8200d04cef573642036c213e1841fe551 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:54 -0400 Subject: [PATCH 0097/1190] media: ddbridge/max: rename ddbridge-maxs8.[c|h] to ddbridge-max.[c|h] Rename the MaxS4/8 support files following upstream. References to these files and descriptions have been updated aswell. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/Makefile | 2 +- drivers/media/pci/ddbridge/ddbridge-core.c | 2 +- .../pci/ddbridge/{ddbridge-maxs8.c => ddbridge-max.c} | 4 ++-- .../pci/ddbridge/{ddbridge-maxs8.h => ddbridge-max.h} | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) rename drivers/media/pci/ddbridge/{ddbridge-maxs8.c => ddbridge-max.c} (99%) rename drivers/media/pci/ddbridge/{ddbridge-maxs8.h => ddbridge-max.h} (85%) diff --git a/drivers/media/pci/ddbridge/Makefile b/drivers/media/pci/ddbridge/Makefile index 1d370418d105d..ec5238870fdb4 100644 --- a/drivers/media/pci/ddbridge/Makefile +++ b/drivers/media/pci/ddbridge/Makefile @@ -4,7 +4,7 @@ # ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \ - ddbridge-hw.o ddbridge-i2c.o ddbridge-maxs8.o + ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 6354e00f4c9be..e2e793b749f2b 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -37,7 +37,7 @@ #include "ddbridge.h" #include "ddbridge-i2c.h" #include "ddbridge-regs.h" -#include "ddbridge-maxs8.h" +#include "ddbridge-max.h" #include "ddbridge-ci.h" #include "ddbridge-io.h" diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.c b/drivers/media/pci/ddbridge/ddbridge-max.c similarity index 99% rename from drivers/media/pci/ddbridge/ddbridge-maxs8.c rename to drivers/media/pci/ddbridge/ddbridge-max.c index 06d57a4772fa3..67ab4e300a36c 100644 --- a/drivers/media/pci/ddbridge/ddbridge-maxs8.c +++ b/drivers/media/pci/ddbridge/ddbridge-max.c @@ -1,5 +1,5 @@ /* - * ddbridge-maxs8.c: Digital Devices bridge MaxS4/8 support + * ddbridge-max.c: Digital Devices bridge MAX card support * * Copyright (C) 2010-2017 Digital Devices GmbH * Ralph Metzler @@ -34,7 +34,7 @@ #include "ddbridge-regs.h" #include "ddbridge-io.h" -#include "ddbridge-maxs8.h" +#include "ddbridge-max.h" #include "mxl5xx.h" /******************************************************************************/ diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.h b/drivers/media/pci/ddbridge/ddbridge-max.h similarity index 85% rename from drivers/media/pci/ddbridge/ddbridge-maxs8.h rename to drivers/media/pci/ddbridge/ddbridge-max.h index bb8884811a460..b1bfbbea4337c 100644 --- a/drivers/media/pci/ddbridge/ddbridge-maxs8.h +++ b/drivers/media/pci/ddbridge/ddbridge-max.h @@ -1,5 +1,5 @@ /* - * ddbridge-maxs8.h: Digital Devices bridge MaxS4/8 support + * ddbridge-max.h: Digital Devices bridge MAX card support * * Copyright (C) 2010-2017 Digital Devices GmbH * Ralph Metzler @@ -16,8 +16,8 @@ * */ -#ifndef _DDBRIDGE_MAXS8_H_ -#define _DDBRIDGE_MAXS8_H_ +#ifndef _DDBRIDGE_MAX_H_ +#define _DDBRIDGE_MAX_H_ #include "ddbridge.h" @@ -26,4 +26,4 @@ int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm); int fe_attach_mxl5xx(struct ddb_input *input); -#endif /* _DDBRIDGE_MAXS8_H */ +#endif /* _DDBRIDGE_MAX_H */ -- GitLab From 1c71450151c488bffe3de31af317113a036aa7ad Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:55 -0400 Subject: [PATCH 0098/1190] media: ddbridge/max: prefix lnb_init_fmode() and fe_attach_mxl5xx() Add a ddb_ prefix to the two functions to better avoid conflicts in the global namespace, ie. when building everything into the kernel image. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++-- drivers/media/pci/ddbridge/ddbridge-max.c | 6 +++--- drivers/media/pci/ddbridge/ddbridge-max.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index e2e793b749f2b..348cc8b3d1f93 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1442,7 +1442,7 @@ static int dvb_input_attach(struct ddb_input *input) dvb->fe2 = NULL; switch (port->type) { case DDB_TUNER_MXL5XX: - if (fe_attach_mxl5xx(input) < 0) + if (ddb_fe_attach_mxl5xx(input) < 0) return -ENODEV; break; case DDB_TUNER_DVBS_ST: @@ -2955,7 +2955,7 @@ static ssize_t fmode_store(struct device *device, struct device_attribute *attr, return -EINVAL; if (val > 3) return -EINVAL; - lnb_init_fmode(dev, &dev->link[num], val); + ddb_lnb_init_fmode(dev, &dev->link[num], val); return count; } diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c b/drivers/media/pci/ddbridge/ddbridge-max.c index 67ab4e300a36c..dc6b814887466 100644 --- a/drivers/media/pci/ddbridge/ddbridge-max.c +++ b/drivers/media/pci/ddbridge/ddbridge-max.c @@ -360,7 +360,7 @@ static int mxl_fw_read(void *priv, u8 *buf, u32 len) return ddbridge_flashread(dev, link->nr, buf, 0xc0000, len); } -int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm) +int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm) { u32 l = link->nr; @@ -404,7 +404,7 @@ static struct mxl5xx_cfg mxl5xx = { .fw_read = mxl_fw_read, }; -int fe_attach_mxl5xx(struct ddb_input *input) +int ddb_fe_attach_mxl5xx(struct ddb_input *input) { struct ddb *dev = input->port->dev; struct i2c_adapter *i2c = &input->port->i2c->adap; @@ -440,7 +440,7 @@ int fe_attach_mxl5xx(struct ddb_input *input) lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT); lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF); } - lnb_init_fmode(dev, link, fmode); + ddb_lnb_init_fmode(dev, link, fmode); dvb->fe->ops.set_voltage = max_set_voltage; dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage; diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h b/drivers/media/pci/ddbridge/ddbridge-max.h index b1bfbbea4337c..bf8bf38739f6d 100644 --- a/drivers/media/pci/ddbridge/ddbridge-max.h +++ b/drivers/media/pci/ddbridge/ddbridge-max.h @@ -23,7 +23,7 @@ /******************************************************************************/ -int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm); -int fe_attach_mxl5xx(struct ddb_input *input); +int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm); +int ddb_fe_attach_mxl5xx(struct ddb_input *input); #endif /* _DDBRIDGE_MAX_H */ -- GitLab From 9cc6544718b738bd7dd2c3c885814304bab2d253 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:56 -0400 Subject: [PATCH 0099/1190] media: stv0910: read and update mod_cod in read_status() Add missing state->modcod update from upstream driver which needs to be done when manage_matype_info() sets is_vcm on certain S2 transponders. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 8bf855c301f55..73f6df0abbfe1 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -1498,6 +1498,19 @@ static int read_status(struct dvb_frontend *fe, enum fe_status *status) enable_puncture_rate(state, state->puncture_rate); } + + /* Use highest signaled ModCod for quality */ + if (state->is_vcm) { + u8 tmp; + enum fe_stv0910_mod_cod mod_cod; + + read_reg(state, RSTV0910_P2_DMDMODCOD + state->regoff, + &tmp); + mod_cod = (enum fe_stv0910_mod_cod)((tmp & 0x7c) >> 2); + + if (mod_cod > state->mod_cod) + state->mod_cod = mod_cod; + } } /* read signal statistics */ -- GitLab From 40f80610e8f68133e2283ef3cda3f26639d32f86 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 15 Oct 2017 16:51:57 -0400 Subject: [PATCH 0100/1190] media: ddbridge: update driver version number Update the driver version number/string to 0.9.32-integrated. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index e8432e49564c7..70ac9e576c749 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -63,7 +63,7 @@ #include "dvb_ca_en50221.h" #include "dvb_net.h" -#define DDBRIDGE_VERSION "0.9.31intermediate-integrated" +#define DDBRIDGE_VERSION "0.9.32-integrated" #define DDB_MAX_I2C 32 #define DDB_MAX_PORT 32 -- GitLab From 7b303d2cae8ae546d00fb6f673849fd27370bb3a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 11 Dec 2017 12:18:46 -0500 Subject: [PATCH 0101/1190] media: ddbridge: shut up a new warning drivers/media/pci/ddbridge/ddbridge-ci.c:321:5: warning: no previous prototype for 'ddb_ci_attach' [-Wmissing-prototypes] int ddb_ci_attach(struct ddb_port *port, u32 bitrate) ^~~~~~~~~~~~~ Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-ci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c index 457c711aaced4..a4fd747763a06 100644 --- a/drivers/media/pci/ddbridge/ddbridge-ci.c +++ b/drivers/media/pci/ddbridge/ddbridge-ci.c @@ -20,6 +20,7 @@ #include "ddbridge.h" #include "ddbridge-regs.h" +#include "ddbridge-ci.h" #include "ddbridge-io.h" #include "ddbridge-i2c.h" -- GitLab From 9ea57316a5da7d3c203e7a82d1a9a4055515b212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= Date: Tue, 17 Oct 2017 02:12:25 -0400 Subject: [PATCH 0102/1190] media: i.MX6: Fix MIPI CSI-2 LP-11 check Bitmask for the MIPI CSI-2 data PHY status doesn't seem to be correct. Fix it. Signed-off-by: Krzysztof Ha?asa Reviewed-by: Philipp Zabel Reviewed-by: Steve Longerbeam Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx6-mipi-csi2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index 5061f3f524fd5..477d191c568bd 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -252,8 +252,8 @@ static int csi2_dphy_wait_stopstate(struct csi2_dev *csi2) u32 mask, reg; int ret; - mask = PHY_STOPSTATECLK | - ((csi2->bus.num_data_lanes - 1) << PHY_STOPSTATEDATA_BIT); + mask = PHY_STOPSTATECLK | (((1 << csi2->bus.num_data_lanes) - 1) << + PHY_STOPSTATEDATA_BIT); ret = readl_poll_timeout(csi2->base + CSI2_PHY_STATE, reg, (reg & mask) == mask, 0, 500000); -- GitLab From 910b0797fa9e8af09c44a3fa36cb310ba7a7218d Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Mon, 30 Oct 2017 06:07:29 -0400 Subject: [PATCH 0103/1190] media: em28xx: Fix use-after-free when disconnecting Fix bug by moving the i2c_unregister_device calls after deregistration of dvb frontend. The new style i2c drivers already destroys the frontend object at i2c_unregister_device time. When the dvb frontend is unregistered afterwards it leads to this oops: [ 6058.866459] BUG: unable to handle kernel NULL pointer dereference at 00000000000001f8 [ 6058.866578] IP: dvb_frontend_stop+0x30/0xd0 [dvb_core] [ 6058.866644] PGD 0 [ 6058.866646] P4D 0 [ 6058.866726] Oops: 0000 [#1] SMP [ 6058.866768] Modules linked in: rc_pinnacle_pctv_hd(O) em28xx_rc(O) si2157(O) si2168(O) em28xx_dvb(O) em28xx(O) si2165(O) a8293(O) tda10071(O) tea5767(O) tuner(O) cx23885(O) tda18271(O) videobuf2_dvb(O) videobuf2_dma_sg(O) m88ds3103(O) tveeprom(O) cx2341x(O) v4l2_common(O) dvb_core(O) rc_core(O) videobuf2_memops(O) videobuf2_v4l2(O) videobuf2_core(O) videodev(O) media(O) bluetooth ecdh_generic ums_realtek uas rtl8192cu rtl_usb rtl8192c_common rtlwifi usb_storage snd_hda_codec_realtek snd_hda_codec_hdmi snd_hda_codec_generic i2c_mux snd_hda_intel snd_hda_codec snd_hwdep x86_pkg_temp_thermal snd_hda_core kvm_intel kvm irqbypass [last unloaded: videobuf2_memops] [ 6058.867497] CPU: 2 PID: 7349 Comm: kworker/2:0 Tainted: G W O 4.13.9-gentoo #1 [ 6058.867595] Hardware name: MEDION E2050 2391/H81H3-EM2, BIOS H81EM2W08.308 08/25/2014 [ 6058.867692] Workqueue: usb_hub_wq hub_event [ 6058.867746] task: ffff88011a15e040 task.stack: ffffc90003074000 [ 6058.867825] RIP: 0010:dvb_frontend_stop+0x30/0xd0 [dvb_core] [ 6058.867896] RSP: 0018:ffffc90003077b58 EFLAGS: 00010293 [ 6058.867964] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000010040001f [ 6058.868056] RDX: ffff88011a15e040 RSI: ffffea000464e400 RDI: ffff88001cbe3028 [ 6058.868150] RBP: ffffc90003077b68 R08: ffff880119390380 R09: 000000010040001f [ 6058.868241] R10: ffffc90003077b18 R11: 000000000001e200 R12: ffff88001cbe3028 [ 6058.868330] R13: ffff88001cbe68d0 R14: ffff8800cf734000 R15: ffff8800cf734098 [ 6058.868419] FS: 0000000000000000(0000) GS:ffff88011fb00000(0000) knlGS:0000000000000000 [ 6058.868511] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6058.868578] CR2: 00000000000001f8 CR3: 00000001113c5000 CR4: 00000000001406e0 [ 6058.868662] Call Trace: [ 6058.868705] dvb_unregister_frontend+0x2a/0x80 [dvb_core] [ 6058.868774] em28xx_dvb_fini+0x132/0x220 [em28xx_dvb] [ 6058.868840] em28xx_close_extension+0x34/0x90 [em28xx] [ 6058.868902] em28xx_usb_disconnect+0x4e/0x70 [em28xx] [ 6058.868968] usb_unbind_interface+0x6d/0x260 [ 6058.869025] device_release_driver_internal+0x150/0x210 [ 6058.869094] device_release_driver+0xd/0x10 [ 6058.869150] bus_remove_device+0xe4/0x160 [ 6058.869204] device_del+0x1ce/0x2f0 [ 6058.869253] usb_disable_device+0x99/0x270 [ 6058.869306] usb_disconnect+0x8d/0x260 [ 6058.869359] hub_event+0x93d/0x1520 [ 6058.869408] ? dequeue_task_fair+0xae5/0xd20 [ 6058.869467] process_one_work+0x1d9/0x3e0 [ 6058.869522] worker_thread+0x43/0x3e0 [ 6058.869576] kthread+0x104/0x140 [ 6058.869602] ? trace_event_raw_event_workqueue_work+0x80/0x80 [ 6058.869640] ? kthread_create_on_node+0x40/0x40 [ 6058.869673] ret_from_fork+0x22/0x30 [ 6058.869698] Code: 54 49 89 fc 53 48 8b 9f 18 03 00 00 0f 1f 44 00 00 41 83 bc 24 04 05 00 00 02 74 0c 41 c7 84 24 04 05 00 00 01 00 00 00 0f ae f0 <48> 8b bb f8 01 00 00 48 85 ff 74 5c e8 df 40 f0 e0 48 8b 93 f8 [ 6058.869850] RIP: dvb_frontend_stop+0x30/0xd0 [dvb_core] RSP: ffffc90003077b58 [ 6058.869894] CR2: 00000000000001f8 [ 6058.875880] ---[ end trace 717eecf7193b3fc6 ]--- Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-dvb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 9950a740e04e9..c4abf516c4ffc 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -2105,6 +2105,8 @@ static int em28xx_dvb_fini(struct em28xx *dev) } } + em28xx_unregister_dvb(dvb); + /* remove I2C SEC */ client = dvb->i2c_client_sec; if (client) { @@ -2126,7 +2128,6 @@ static int em28xx_dvb_fini(struct em28xx *dev) i2c_unregister_device(client); } - em28xx_unregister_dvb(dvb); kfree(dvb); dev->dvb = NULL; kref_put(&dev->ref, em28xx_free_device); -- GitLab From 79c5453d3e3e7de9e5ce5c88af29b34688dd0469 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 08:54:58 -0400 Subject: [PATCH 0104/1190] media: atmel-isc: avoid returning a random value at isc_parse_dt() As warned by smatch: drivers/media/platform/atmel/atmel-isc.c:2097 isc_parse_dt() error: uninitialized symbol 'ret'. The problem here is that of_graph_get_next_endpoint() can potentially return NULL on its first pass, with would make it return a random value, as ret is not initialized. While here, use while(1) instead of for(; ;), as while is the preferred syntax for such kind of loops. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/atmel/atmel-isc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index 13f1c1c797b06..0c2635647f69b 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -2039,10 +2039,10 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) INIT_LIST_HEAD(&isc->subdev_entities); - for (; ;) { + while (1) { epn = of_graph_get_next_endpoint(np, epn); if (!epn) - break; + return 0; rem = of_graph_get_remote_port_parent(epn); if (!rem) { -- GitLab From 01a26ff99ca4cec8dcb246683b4b44f5728f75c0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:41 -0400 Subject: [PATCH 0105/1190] media: tda8290: initialize agc gain The tuning logic at tda8290 relies on agc_stat and adc_sat to be initialized. However, as warned by smatch: drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'agc_stat'. drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'adc_sat'. drivers/media/tuners/tda8290.c:262 tda8290_set_params() error: uninitialized symbol 'adc_sat'. That could cause an erratic behavior if PLL is not locked, as the code will only work if !(pll_stat & 0x80) && (adc_sat < 20) So, initialize it to zero, in order to let the code below to be called, with should give more chances to adjust the tuner gain, in order to get a PLL lock. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/tda8290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c index a59c567c55d6a..f226e6ecc1754 100644 --- a/drivers/media/tuners/tda8290.c +++ b/drivers/media/tuners/tda8290.c @@ -196,7 +196,7 @@ static void tda8290_set_params(struct dvb_frontend *fe, unsigned char addr_adc_sat = 0x1a; unsigned char addr_agc_stat = 0x1d; unsigned char addr_pll_stat = 0x1b; - unsigned char adc_sat, agc_stat, + unsigned char adc_sat = 0, agc_stat = 0, pll_stat; int i; -- GitLab From bc3cad2b9261de7a5fa7632d30271e6d8418cb8f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:48 -0400 Subject: [PATCH 0106/1190] media: qt1010: fix bogus warnings The logic at qt1010_init_meas1() and qt1010_init_meas2() are too complex for static analizers to identify that some vars are always be initialized. That causes smatch to produce the following warnings: drivers/media/tuners/qt1010.c:248 qt1010_init_meas1() error: uninitialized symbol 'val2'. drivers/media/tuners/qt1010.c:282 qt1010_init_meas2() error: uninitialized symbol 'val'. So, add annotations to prevent those bogus warnings. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/qt1010.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/tuners/qt1010.c b/drivers/media/tuners/qt1010.c index ee33b7cc76824..b92be882ab3c1 100644 --- a/drivers/media/tuners/qt1010.c +++ b/drivers/media/tuners/qt1010.c @@ -224,7 +224,7 @@ static int qt1010_set_params(struct dvb_frontend *fe) static int qt1010_init_meas1(struct qt1010_priv *priv, u8 oper, u8 reg, u8 reg_init_val, u8 *retval) { - u8 i, val1, val2; + u8 i, val1, uninitialized_var(val2); int err; qt1010_i2c_oper_t i2c_data[] = { @@ -259,7 +259,7 @@ static int qt1010_init_meas1(struct qt1010_priv *priv, static int qt1010_init_meas2(struct qt1010_priv *priv, u8 reg_init_val, u8 *retval) { - u8 i, val; + u8 i, uninitialized_var(val); int err; qt1010_i2c_oper_t i2c_data[] = { { QT1010_WR, 0x07, reg_init_val }, -- GitLab From 02d7324337c0223f3775d539380e32f603646a52 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:44 -0400 Subject: [PATCH 0107/1190] media: radio-si476x: fix behavior when seek->range* are defined The logic at si476x_radio_s_hw_freq_seek() checks if the frequency range that will be used to handle hardware seek has the minimal frequency under rangelow. That works fine if userspace zeros both fields. However, if userspace fills either seek->rangelow or seek-rangehigh, it won't read the corresponding range from the device, causing the values to be unitialized, as warned by smatch: drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangelow'. drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangehigh'. Fix it by initializing those vars from the values present at the struct v4l2_hw_freq_seek. While here, simplify the logic which reads such values from the hardware limits. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-si476x.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c index 540ac887a63cd..d1355ac2df2f7 100644 --- a/drivers/media/radio/radio-si476x.c +++ b/drivers/media/radio/radio-si476x.c @@ -759,7 +759,7 @@ static int si476x_radio_s_hw_freq_seek(struct file *file, void *priv, { int err; enum si476x_func func; - u32 rangelow, rangehigh; + u32 rangelow = seek->rangelow, rangehigh = seek->rangehigh; struct si476x_radio *radio = video_drvdata(file); if (file->f_flags & O_NONBLOCK) @@ -771,23 +771,21 @@ static int si476x_radio_s_hw_freq_seek(struct file *file, void *priv, si476x_core_lock(radio->core); - if (!seek->rangelow) { + if (!rangelow) { err = regmap_read(radio->core->regmap, SI476X_PROP_SEEK_BAND_BOTTOM, &rangelow); - if (!err) - rangelow = si476x_to_v4l2(radio->core, rangelow); - else + if (err) goto unlock; + rangelow = si476x_to_v4l2(radio->core, rangelow); } - if (!seek->rangehigh) { + if (!rangehigh) { err = regmap_read(radio->core->regmap, SI476X_PROP_SEEK_BAND_TOP, &rangehigh); - if (!err) - rangehigh = si476x_to_v4l2(radio->core, rangehigh); - else + if (err) goto unlock; + rangehigh = si476x_to_v4l2(radio->core, rangehigh); } if (rangelow > rangehigh) { -- GitLab From 8a08ef08fb132b3184e99fa8c1a007bcfadd9942 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:47 -0400 Subject: [PATCH 0108/1190] media: xc4000: don't ignore error if hwmodel fails If, for some reason, reading the hwmodel register on xc4000 fails, it will cause the following logig to use a random value, as reported by smatch: drivers/media/tuners/xc4000.c:1047 check_firmware() error: uninitialized symbol 'hwmodel'. drivers/media/tuners/xc4000.c:1060 check_firmware() error: uninitialized symbol 'hwmodel'. drivers/media/tuners/xc4000.c:1064 check_firmware() error: uninitialized symbol 'hwmodel'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/xc4000.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c index e30948e4ff87e..2113ce594f75e 100644 --- a/drivers/media/tuners/xc4000.c +++ b/drivers/media/tuners/xc4000.c @@ -1036,7 +1036,10 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, dprintk(1, "load scode failed %d\n", rc); check_device: - rc = xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel); + if (xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel) < 0) { + printk(KERN_ERR "Unable to read tuner registers.\n"); + goto fail; + } if (xc_get_version(priv, &hw_major, &hw_minor, &fw_major, &fw_minor) != 0) { -- GitLab From ab0625f021f83ecb19c969188ba2af3d154c054e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:06:01 -0400 Subject: [PATCH 0109/1190] media: stv090x: Only print tuner lock if get_status is available The current code doesn't report tuner lock properly if the tuner get_status callback is not available, as reported by smatch: drivers/media/dvb-frontends/stv090x.c:2220 stv090x_get_coldlock() error: uninitialized symbol 'reg'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv090x.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index 7ef469c0c8668..0f375df13fbeb 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c @@ -2215,13 +2215,12 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) if (state->config->tuner_get_status) { if (state->config->tuner_get_status(fe, ®) < 0) goto err_gateoff; + if (reg) + dprintk(FE_DEBUG, 1, "Tuner phase locked"); + else + dprintk(FE_DEBUG, 1, "Tuner unlocked"); } - if (reg) - dprintk(FE_DEBUG, 1, "Tuner phase locked"); - else - dprintk(FE_DEBUG, 1, "Tuner unlocked"); - if (stv090x_i2c_gate_ctrl(state, 0) < 0) goto err; -- GitLab From 00b4bac78f6f607c5882bfdc03008b7acf802349 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:57 -0400 Subject: [PATCH 0110/1190] media: imx274: don't randomly return if range_count is zero As smatch reported: drivers/media/i2c/imx274.c:659 imx274_regmap_util_write_table_8() error: uninitialized symbol 'err'. There is a bug at imx274_regmap_util_write_table_8() with causes it to randomly return a random error if range_count is zero. Worse than that, the logic there starts with range_count equal to zero, and periodically resets it to zero again. As it is a way more likely that err assumes a non-zero value, I suspect that the chance of this code to run is very small, so, it would be worth to review the entire function. Anyway, clearly it shouldn't be returning error if range_count is zero. So, let's fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/imx274.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c index 2f71af2f90bf9..59d077b979102 100644 --- a/drivers/media/i2c/imx274.c +++ b/drivers/media/i2c/imx274.c @@ -655,6 +655,8 @@ static int imx274_regmap_util_write_table_8(struct regmap *regmap, err = regmap_bulk_write(regmap, range_start, &range_vals[0], range_count); + else + err = 0; if (err) return err; -- GitLab From 452c6446948e32018014ddadf93c525bf1f907ac Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:06:00 -0400 Subject: [PATCH 0111/1190] media: drxj: better handle errors as reported by smatch: drivers/media/dvb-frontends/drx39xyj/drxj.c:2157 drxj_dap_atomic_read_write_block() error: uninitialized symbol 'word'. The driver doesn't check if a read error occurred. Add such check. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drx39xyj/drxj.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index 8cbd8cc21059d..77d3a44177ba0 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c @@ -2151,9 +2151,13 @@ int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr, if (read_flag) { /* read data from buffer */ for (i = 0; i < (datasize / 2); i++) { - drxj_dap_read_reg16(dev_addr, - (DRXJ_HI_ATOMIC_BUF_START + i), - &word, 0); + rc = drxj_dap_read_reg16(dev_addr, + (DRXJ_HI_ATOMIC_BUF_START + i), + &word, 0); + if (rc) { + pr_err("error %d\n", rc); + goto rw_error; + } data[2 * i] = (u8) (word & 0xFF); data[(2 * i) + 1] = (u8) (word >> 8); } -- GitLab From 15e3145a709978db777bd60d07552da06ae0e407 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:06:02 -0400 Subject: [PATCH 0112/1190] media: mb86a16: be more resilient if I2C fails on sync If the I2C read fails while check for sync, there's no point on doing adjusting the tuner due to a random value that might be at VIRM var. So, set VIRM to zero, as that makes the caller for check_sync() to return an error. Fix those smatch warnings: drivers/media/dvb-frontends/mb86a16.c:1460 mb86a16_set_fe() error: uninitialized symbol 'VIRM'. drivers/media/dvb-frontends/mb86a16.c:1461 mb86a16_set_fe() error: uninitialized symbol 'VIRM'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/mb86a16.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c index dfe322eccaa1a..f1aad52094c3d 100644 --- a/drivers/media/dvb-frontends/mb86a16.c +++ b/drivers/media/dvb-frontends/mb86a16.c @@ -635,6 +635,7 @@ static int sync_chk(struct mb86a16_state *state, return sync; err: dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error"); + *VIRM = 0; return -EREMOTEIO; } -- GitLab From f303810cf189144a613a7efa991816655e6467ea Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:06:03 -0400 Subject: [PATCH 0113/1190] media: mb86a16: avoid division by zero As warned by smatch: drivers/media/dvb-frontends/mb86a16.c:1690 mb86a16_read_ber() error: uninitialized symbol 'timer'. drivers/media/dvb-frontends/mb86a16.c:1706 mb86a16_read_ber() error: uninitialized symbol 'timer'. There is a potential risk of doing a division by zero if timer is not handled well. Enforce it by setting a bit mask for the values used to select the timer. It should be noticed that I don't have mb86a16 datasheet. So, the bitmask was guessed based on the existing checks for the field. At worse case scenario, it will just show a badly calculated bit error rate, but it won't crash. While here, optimize the logic to prevent uneeded tests. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/mb86a16.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c index f1aad52094c3d..5d2bb76bc07aa 100644 --- a/drivers/media/dvb-frontends/mb86a16.c +++ b/drivers/media/dvb-frontends/mb86a16.c @@ -1677,15 +1677,15 @@ static int mb86a16_read_ber(struct dvb_frontend *fe, u32 *ber) * the deinterleaver output. * monitored BER is expressed as a 20 bit output in total */ - ber_rst = ber_mon >> 3; + ber_rst = (ber_mon >> 3) & 0x03; *ber = (((ber_msb << 8) | ber_mid) << 8) | ber_lsb; if (ber_rst == 0) timer = 12500000; - if (ber_rst == 1) + else if (ber_rst == 1) timer = 25000000; - if (ber_rst == 2) + else if (ber_rst == 2) timer = 50000000; - if (ber_rst == 3) + else /* ber_rst == 3 */ timer = 100000000; *ber /= timer; @@ -1697,11 +1697,11 @@ static int mb86a16_read_ber(struct dvb_frontend *fe, u32 *ber) * QPSK demodulator output. * monitored BER is expressed as a 24 bit output in total */ - ber_tim = ber_mon >> 1; + ber_tim = (ber_mon >> 1) & 0x01; *ber = (((ber_msb << 8) | ber_mid) << 8) | ber_lsb; if (ber_tim == 0) timer = 16; - if (ber_tim == 1) + else /* ber_tim == 1 */ timer = 24; *ber /= 2 ^ timer; -- GitLab From 29236349aa7dfc5556424261240be9050187b49d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:56 -0400 Subject: [PATCH 0114/1190] media: ov9650: fix bogus warnings The smatch logic gets confused with the syntax used to check if the ov9650x_read() reads succedded: drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg2'. drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg1'. There's nothing wrong with the original logic, except that it is a little more harder to review. So, let's stick with the syntax that won't cause read issues. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Nicholas Mc Guire Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov9650.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index 69433e1e25335..e519f278d5f97 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -886,10 +886,12 @@ static int __g_volatile_ctrl(struct ov965x *ov965x, struct v4l2_ctrl *ctrl) if (ctrl->val == V4L2_EXPOSURE_MANUAL) return 0; ret = ov965x_read(client, REG_COM1, ®0); - if (!ret) - ret = ov965x_read(client, REG_AECH, ®1); - if (!ret) - ret = ov965x_read(client, REG_AECHM, ®2); + if (ret < 0) + return ret; + ret = ov965x_read(client, REG_AECH, ®1); + if (ret < 0) + return ret; + ret = ov965x_read(client, REG_AECHM, ®2); if (ret < 0) return ret; exposure = ((reg2 & 0x3f) << 10) | (reg1 << 2) | -- GitLab From e639c869558cc1172cacf7477819c7e9db60e3a4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:52 -0400 Subject: [PATCH 0115/1190] media: pt1: fix logic when pt1_nr_tables is zero or negative pt1_nr_tables is a modprobe parameter. The way the logic handles it, it can't be negative. However, user can set it to zero. If set to zero, however, it will cause troubles at pt1_init_tables(), as reported by smatch: drivers/media/pci/pt1/pt1.c:468 pt1_init_tables() error: uninitialized symbol 'first_pfn'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/pt1/pt1.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index b6b1a8d20d86b..acc3afeb62246 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c @@ -116,8 +116,8 @@ static u32 pt1_read_reg(struct pt1 *pt1, int reg) return readl(pt1->regs + reg * 4); } -static int pt1_nr_tables = 8; -module_param_named(nr_tables, pt1_nr_tables, int, 0); +static unsigned int pt1_nr_tables = 8; +module_param_named(nr_tables, pt1_nr_tables, uint, 0); static void pt1_increment_table_count(struct pt1 *pt1) { @@ -443,6 +443,9 @@ static int pt1_init_tables(struct pt1 *pt1) int i, ret; u32 first_pfn, pfn; + if (!pt1_nr_tables) + return 0; + tables = vmalloc(sizeof(struct pt1_table) * pt1_nr_tables); if (tables == NULL) return -ENOMEM; @@ -450,12 +453,10 @@ static int pt1_init_tables(struct pt1 *pt1) pt1_init_table_count(pt1); i = 0; - if (pt1_nr_tables) { - ret = pt1_init_table(pt1, &tables[0], &first_pfn); - if (ret) - goto err; - i++; - } + ret = pt1_init_table(pt1, &tables[0], &first_pfn); + if (ret) + goto err; + i++; while (i < pt1_nr_tables) { ret = pt1_init_table(pt1, &tables[i], &pfn); -- GitLab From 74a6799ca9823690046091361ce062d3ccfeac8d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:58 -0400 Subject: [PATCH 0116/1190] media: m88rs2000: handle the case where tuner doesn't have get_frequency If the tuner doesn't have get_frequency() callback, the current code will place a random value as the frequency offset. That doesn't seem right! The better is to just assume that, on such case, the tuner was able to set the exact frequency that was requested. Fixes a smatch warning: drivers/media/dvb-frontends/m88rs2000.c:639 m88rs2000_set_frontend() error: uninitialized symbol 'tuner_freq'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/m88rs2000.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c index ce6c21d405ee4..e34dab41d104b 100644 --- a/drivers/media/dvb-frontends/m88rs2000.c +++ b/drivers/media/dvb-frontends/m88rs2000.c @@ -630,13 +630,16 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe) if (ret < 0) return -ENODEV; - if (fe->ops.tuner_ops.get_frequency) + if (fe->ops.tuner_ops.get_frequency) { ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_freq); - if (ret < 0) - return -ENODEV; + if (ret < 0) + return -ENODEV; - offset = (s16)((s32)tuner_freq - c->frequency); + offset = (s16)((s32)tuner_freq - c->frequency); + } else { + offset = 0; + } /* default mclk value 96.4285 * 2 * 1000 = 192857 */ if (((c->frequency % 192857) >= (192857 - 3000)) || -- GitLab From 021c01d3dc8291105338b455b994a48b807f26c3 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:55 -0400 Subject: [PATCH 0117/1190] media: dvbsky: shut up a bogus warning Smatch gives two bogus warnings on this driver: drivers/media/usb/dvb-usb-v2/dvbsky.c:336 dvbsky_s960_attach() error: uninitialized symbol 'i2c_adapter'. drivers/media/usb/dvb-usb-v2/dvbsky.c:459 dvbsky_s960c_attach() error: uninitialized symbol 'i2c_adapter'. Shut them up. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/dvbsky.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c index 131b6c08e199d..f90540f947f8c 100644 --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c @@ -309,7 +309,7 @@ static int dvbsky_s960_attach(struct dvb_usb_adapter *adap) struct dvb_usb_device *d = adap_to_d(adap); int ret = 0; /* demod I2C adapter */ - struct i2c_adapter *i2c_adapter; + struct i2c_adapter *i2c_adapter = NULL; struct i2c_client *client; struct i2c_board_info info; struct ts2020_config ts2020_config = {}; @@ -431,7 +431,7 @@ static int dvbsky_s960c_attach(struct dvb_usb_adapter *adap) struct dvb_usb_device *d = adap_to_d(adap); int ret = 0; /* demod I2C adapter */ - struct i2c_adapter *i2c_adapter; + struct i2c_adapter *i2c_adapter = NULL; struct i2c_client *client_tuner, *client_ci; struct i2c_board_info info; struct sp2_config sp2_config; -- GitLab From 04f849c00cf6228092d37876896fbd541a0f3393 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:46 -0400 Subject: [PATCH 0118/1190] media: cx25821-alsa: fix usage of a pointer printk As warned by smatch: drivers/media/pci/cx25821/cx25821-alsa.c:155 cx25821_alsa_dma_init() warn: argument 3 to %08lx specifier is cast from pointer Use the standard %p to print a pointer. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx25821/cx25821-alsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index 2b34990e86f23..a45bf0331eebf 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c @@ -152,8 +152,8 @@ static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages) return -ENOMEM; } - dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n", - (unsigned long)buf->vaddr, + dprintk(1, "vmalloc is at addr 0x%p, size=%d\n", + buf->vaddr, nr_pages << PAGE_SHIFT); memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); -- GitLab From 07ade2d0f680864ba0c93553d008900dd3e1a421 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:59 -0400 Subject: [PATCH 0119/1190] media: cxd2841er: ensure that status will always be available The loop with read status use a dynamic timeout value, calculated from symbol rate. It should run the loop at least one time for the status to be handled after the loop. While this should, in practice, happen every time, it doesn't hurt to change the logic to make it explicit. This solves a smatch warning: drivers/media/dvb-frontends/cxd2841er.c:3350 cxd2841er_set_frontend_s() error: uninitialized symbol 'status'. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/cxd2841er.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 2cb97a3130be7..17e4db7900e5b 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -3339,13 +3339,17 @@ static int cxd2841er_set_frontend_s(struct dvb_frontend *fe) cxd2841er_tune_done(priv); timeout = ((3000000 + (symbol_rate - 1)) / symbol_rate) + 150; - for (i = 0; i < timeout / CXD2841ER_DVBS_POLLING_INVL; i++) { + + i = 0; + do { usleep_range(CXD2841ER_DVBS_POLLING_INVL*1000, (CXD2841ER_DVBS_POLLING_INVL + 2) * 1000); cxd2841er_read_status_s(fe, &status); if (status & FE_HAS_LOCK) break; - } + i++; + } while (i < timeout / CXD2841ER_DVBS_POLLING_INVL); + if (status & FE_HAS_LOCK) { if (cxd2841er_get_carrier_offset_s_s2( priv, &carr_offset)) { -- GitLab From f161544d9d7d8e617c13fe30504317c417ed49e9 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:53 -0400 Subject: [PATCH 0120/1190] media: drxd_hard: better handle I2C errors As warned by smatch: drivers/media/dvb-frontends/drxd_hard.c:989 HI_Command() error: uninitialized symbol 'waitCmd'. drivers/media/dvb-frontends/drxd_hard.c:1306 SC_WaitForReady() error: uninitialized symbol 'curCmd'. drivers/media/dvb-frontends/drxd_hard.c:1322 SC_SendCommand() error: uninitialized symbol 'errCode'. drivers/media/dvb-frontends/drxd_hard.c:1339 SC_ProcStartCommand() error: uninitialized symbol 'scExec'. The error handling on several places are somewhat flawed, as they don't check if Read16() returns an error. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxd_hard.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c index 0696bc62dcc90..3215d003b2a1d 100644 --- a/drivers/media/dvb-frontends/drxd_hard.c +++ b/drivers/media/dvb-frontends/drxd_hard.c @@ -972,7 +972,6 @@ static int DownloadMicrocode(struct drxd_state *state, static int HI_Command(struct drxd_state *state, u16 cmd, u16 * pResult) { u32 nrRetries = 0; - u16 waitCmd; int status; status = Write16(state, HI_RA_RAM_SRV_CMD__A, cmd, 0); @@ -985,8 +984,8 @@ static int HI_Command(struct drxd_state *state, u16 cmd, u16 * pResult) status = -1; break; } - status = Read16(state, HI_RA_RAM_SRV_CMD__A, &waitCmd, 0); - } while (waitCmd != 0); + status = Read16(state, HI_RA_RAM_SRV_CMD__A, NULL, 0); + } while (status != 0); if (status >= 0) status = Read16(state, HI_RA_RAM_SRV_RES__A, pResult, 0); @@ -1298,12 +1297,11 @@ static int InitFT(struct drxd_state *state) static int SC_WaitForReady(struct drxd_state *state) { - u16 curCmd; int i; for (i = 0; i < DRXD_MAX_RETRIES; i += 1) { - int status = Read16(state, SC_RA_RAM_CMD__A, &curCmd, 0); - if (status == 0 || curCmd == 0) + int status = Read16(state, SC_RA_RAM_CMD__A, NULL, 0); + if (status == 0) return status; } return -1; @@ -1311,15 +1309,15 @@ static int SC_WaitForReady(struct drxd_state *state) static int SC_SendCommand(struct drxd_state *state, u16 cmd) { - int status = 0; + int status = 0, ret; u16 errCode; Write16(state, SC_RA_RAM_CMD__A, cmd, 0); SC_WaitForReady(state); - Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); + ret = Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); - if (errCode == 0xFFFF) { + if (ret < 0 || errCode == 0xFFFF) { printk(KERN_ERR "Command Error\n"); status = -1; } @@ -1330,13 +1328,13 @@ static int SC_SendCommand(struct drxd_state *state, u16 cmd) static int SC_ProcStartCommand(struct drxd_state *state, u16 subCmd, u16 param0, u16 param1) { - int status = 0; + int ret, status = 0; u16 scExec; mutex_lock(&state->mutex); do { - Read16(state, SC_COMM_EXEC__A, &scExec, 0); - if (scExec != 1) { + ret = Read16(state, SC_COMM_EXEC__A, &scExec, 0); + if (ret < 0 || scExec != 1) { status = -1; break; } -- GitLab From ad7b57d58d16666f607914bf9ff6950e1c5532a4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:54 -0400 Subject: [PATCH 0121/1190] media: mxl111sf: improve error handling logic As reported by smatch: drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c:485 mxl111sf_demod_read_signal_strength() error: uninitialized symbol 'modulation'. The mxl111sf_demod_read_signal_strength() just ignores if something gets wrong while reading snr or modulation. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c index f0ed37da73d42..221cf46b4140a 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c @@ -477,10 +477,15 @@ static int mxl111sf_demod_read_signal_strength(struct dvb_frontend *fe, { struct mxl111sf_demod_state *state = fe->demodulator_priv; enum fe_modulation modulation; + int ret; u16 snr; - mxl111sf_demod_calc_snr(state, &snr); - mxl1x1sf_demod_get_tps_modulation(state, &modulation); + ret = mxl111sf_demod_calc_snr(state, &snr); + if (ret < 0) + return ret; + ret = mxl1x1sf_demod_get_tps_modulation(state, &modulation); + if (ret < 0) + return ret; switch (modulation) { case QPSK: -- GitLab From 7621b8c4c06bd6414c438f9e50781af1cd88d063 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:43 -0400 Subject: [PATCH 0122/1190] media: xc5000: better handle I2C error messages As warned by smatch, there are several places where the I2C transfer may fail, leading into inconsistent behavior: drivers/media/tuners/xc5000.c:689 xc_debug_dump() error: uninitialized symbol 'regval'. drivers/media/tuners/xc5000.c:841 xc5000_is_firmware_loaded() error: uninitialized symbol 'id'. drivers/media/tuners/xc5000.c:939 xc5000_set_tv_freq() error: uninitialized symbol 'pll_lock_status'. drivers/media/tuners/xc5000.c:1195 xc_load_fw_and_init_tuner() error: uninitialized symbol 'pll_lock_status'. Handle the return codes from the I2C transfer, in order to address those issues. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/xc5000.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c index 0e7e4fdf9e50b..98ba177dbc29b 100644 --- a/drivers/media/tuners/xc5000.c +++ b/drivers/media/tuners/xc5000.c @@ -685,8 +685,8 @@ static void xc_debug_dump(struct xc5000_priv *priv) (totalgain % 256) * 100 / 256); if (priv->pll_register_no) { - xc5000_readreg(priv, priv->pll_register_no, ®val); - dprintk(1, "*** PLL lock status = 0x%04x\n", regval); + if (!xc5000_readreg(priv, priv->pll_register_no, ®val)) + dprintk(1, "*** PLL lock status = 0x%04x\n", regval); } } @@ -831,15 +831,16 @@ static int xc5000_is_firmware_loaded(struct dvb_frontend *fe) u16 id; ret = xc5000_readreg(priv, XREG_PRODUCT_ID, &id); - if (ret == 0) { + if (!ret) { if (id == XC_PRODUCT_ID_FW_NOT_LOADED) ret = -ENOENT; else ret = 0; + dprintk(1, "%s() returns id = 0x%x\n", __func__, id); + } else { + dprintk(1, "%s() returns error %d\n", __func__, ret); } - dprintk(1, "%s() returns %s id = 0x%x\n", __func__, - ret == 0 ? "True" : "False", id); return ret; } @@ -935,7 +936,10 @@ static int xc5000_set_tv_freq(struct dvb_frontend *fe) if (priv->pll_register_no != 0) { msleep(20); - xc5000_readreg(priv, priv->pll_register_no, &pll_lock_status); + ret = xc5000_readreg(priv, priv->pll_register_no, + &pll_lock_status); + if (ret) + return ret; if (pll_lock_status > 63) { /* PLL is unlocked, force reload of the firmware */ dprintk(1, "xc5000: PLL not locked (0x%x). Reloading...\n", @@ -1190,8 +1194,10 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) } if (priv->pll_register_no) { - xc5000_readreg(priv, priv->pll_register_no, - &pll_lock_status); + ret = xc5000_readreg(priv, priv->pll_register_no, + &pll_lock_status); + if (ret) + continue; if (pll_lock_status > 63) { /* PLL is unlocked, force reload of the firmware */ printk(KERN_ERR -- GitLab From a9cb97c3e628902e37583d8a40bb28cf76522cf1 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:39 -0400 Subject: [PATCH 0123/1190] media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code As smatch warned: drivers/media/dvb-core/dvb_frontend.c:2468 dvb_frontend_handle_ioctl() error: uninitialized symbol 'err'. The ioctl handler actually got a regression here: before changeset d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic"), the code used to return -EOPNOTSUPP if an ioctl handler was not implemented on a driver. After the change, it may return a random value. Fixes: d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic") Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab Tested-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 2afaa82263421..46f977177fafb 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2110,7 +2110,7 @@ static int dvb_frontend_handle_ioctl(struct file *file, struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend_private *fepriv = fe->frontend_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; - int i, err; + int i, err = -EOPNOTSUPP; dev_dbg(fe->dvb->device, "%s:\n", __func__); @@ -2145,6 +2145,7 @@ static int dvb_frontend_handle_ioctl(struct file *file, } } kfree(tvp); + err = 0; break; } case FE_GET_PROPERTY: { @@ -2196,6 +2197,7 @@ static int dvb_frontend_handle_ioctl(struct file *file, return -EFAULT; } kfree(tvp); + err = 0; break; } -- GitLab From 09db1a462a03a1177a768406451405e4e0dcaf9a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:40 -0400 Subject: [PATCH 0124/1190] media: led-class-flash: better handle NULL flash struct The logic at V4L2 led core assumes that the flash struct can be null. However, it doesn't check for null while trying to set, causing some smatch to warn: drivers/media/v4l2-core/v4l2-flash-led-class.c:210 v4l2_flash_s_ctrl() error: we previously assumed 'fled_cdev' could be null (see line 200) Signed-off-by: Mauro Carvalho Chehab Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/linux/led-class-flash.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index e97966d1fb8da..700efaa9e1154 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -121,6 +121,8 @@ extern void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev); static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev, bool state) { + if (!fled_cdev) + return -EINVAL; return fled_cdev->ops->strobe_set(fled_cdev, state); } @@ -136,6 +138,8 @@ static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev, static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev, bool *state) { + if (!fled_cdev) + return -EINVAL; if (fled_cdev->ops->strobe_get) return fled_cdev->ops->strobe_get(fled_cdev, state); -- GitLab From 72c27a68a2a3f650f0dc7891ee98f02283fc11af Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Thu, 2 Nov 2017 09:52:27 -0400 Subject: [PATCH 0125/1190] media: pvrusb2: properly check endpoint types As syzkaller detected, pvrusb2 driver submits bulk urb withount checking the the endpoint type is actually blunk. Add a check. usb 1-1: BOGUS urb xfer, pipe 3 != type 1 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 2713 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0 Modules linked in: CPU: 1 PID: 2713 Comm: pvrusb2-context Not tainted 4.14.0-rc1-42251-gebb2c2437d80 #210 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88006b7a18c0 task.stack: ffff880069978000 RIP: 0010:usb_submit_urb+0xf8a/0x11d0 drivers/usb/core/urb.c:448 RSP: 0018:ffff88006997f990 EFLAGS: 00010286 RAX: 0000000000000029 RBX: ffff880063661900 RCX: 0000000000000000 RDX: 0000000000000029 RSI: ffffffff86876d60 RDI: ffffed000d32ff24 RBP: ffff88006997fa90 R08: 1ffff1000d32fdca R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1000d32ff39 R13: 0000000000000001 R14: 0000000000000003 R15: ffff880068bbed68 FS: 0000000000000000(0000) GS:ffff88006c600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000001032000 CR3: 000000006a0ff000 CR4: 00000000000006f0 Call Trace: pvr2_send_request_ex+0xa57/0x1d80 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3645 pvr2_hdw_check_firmware drivers/media/usb/pvrusb2/pvrusb2-hdw.c:1812 pvr2_hdw_setup_low drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2107 pvr2_hdw_setup drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2250 pvr2_hdw_initialize+0x548/0x3c10 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2327 pvr2_context_check drivers/media/usb/pvrusb2/pvrusb2-context.c:118 pvr2_context_thread_func+0x361/0x8c0 drivers/media/usb/pvrusb2/pvrusb2-context.c:167 kthread+0x3a1/0x470 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Code: 48 8b 85 30 ff ff ff 48 8d b8 98 00 00 00 e8 ee 82 89 fe 45 89 e8 44 89 f1 4c 89 fa 48 89 c6 48 c7 c7 40 c0 ea 86 e8 30 1b dc fc <0f> ff e9 9b f7 ff ff e8 aa 95 25 fd e9 80 f7 ff ff e8 50 74 f3 ---[ end trace 6919030503719da6 ]--- Signed-off-by: Andrey Konovalov Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index 8289ee482f495..09bd6c6c176cb 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -3648,6 +3648,12 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw, hdw); hdw->ctl_write_urb->actual_length = 0; hdw->ctl_write_pend_flag = !0; + if (usb_urb_ep_type_check(hdw->ctl_write_urb)) { + pvr2_trace( + PVR2_TRACE_ERROR_LEGS, + "Invalid write control endpoint"); + return -EINVAL; + } status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); if (status < 0) { pvr2_trace(PVR2_TRACE_ERROR_LEGS, @@ -3672,6 +3678,12 @@ status); hdw); hdw->ctl_read_urb->actual_length = 0; hdw->ctl_read_pend_flag = !0; + if (usb_urb_ep_type_check(hdw->ctl_read_urb)) { + pvr2_trace( + PVR2_TRACE_ERROR_LEGS, + "Invalid read control endpoint"); + return -EINVAL; + } status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); if (status < 0) { pvr2_trace(PVR2_TRACE_ERROR_LEGS, -- GitLab From 1c3fdf125ef416227e43fdedf6b5097c41e8c467 Mon Sep 17 00:00:00 2001 From: "Darren Hart (VMware)" Date: Fri, 8 Dec 2017 14:57:54 -0800 Subject: [PATCH 0126/1190] platform/x86: intel-vbtn: Simplify autorelease logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new notify_handler logic determining if autorelease should be used or not is a bit awkward, and can result in more than one call to sparse_keymap_report_event for the same event (scancode). The nesting and long lines also made it difficult to read. Simplify the logic by eliminating a level of nesting with a goto and always calculate autorelease and val so we can make a single call to sparse_keymap_report_event. Signed-off-by: Darren Hart (VMware) Reviewed-by: Stefan Brüns Tested-by: Stefan Brüns Cc: AceLan Kao --- drivers/platform/x86/intel-vbtn.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index 0861efe490d02..5fc4315f73823 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -80,6 +80,7 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) { struct platform_device *device = context; struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); + unsigned int val = !(event & 1); /* Even=press, Odd=release */ const struct key_entry *ke_rel; bool autorelease; @@ -88,20 +89,20 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) pm_wakeup_hard_event(&device->dev); return; } - } else { - /* Use the fact press/release come in even/odd pairs */ - if ((event & 1) && sparse_keymap_report_event(priv->input_dev, - event, 0, false)) - return; + goto out_unknown; + } - ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev, - event | 1); - autorelease = !ke_rel || ke_rel->type == KE_IGNORE; + /* + * Even press events are autorelease if there is no corresponding odd + * release event, or if the odd event is KE_IGNORE. + */ + ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev, event | 1); + autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE); - if (sparse_keymap_report_event(priv->input_dev, event, 1, - autorelease)) - return; - } + if (sparse_keymap_report_event(priv->input_dev, event, val, autorelease)) + return; + +out_unknown: dev_dbg(&device->dev, "unknown event index 0x%x\n", event); } -- GitLab From ba3a33876e92e000d7aa37eaf6581a7333c58560 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Sat, 2 Dec 2017 21:45:31 +0800 Subject: [PATCH 0127/1190] platform/x86: ideapad-laptop: Remove unnecessary else Address the following checkpatch warning by removing unnecessary else blocks: WARNING: else is not generally useful after a break or return Signed-off-by: Jiaxun Yang Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/ideapad-laptop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 53ab4e0f89625..9f2a4bc58df0d 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -124,10 +124,10 @@ static int read_method_int(acpi_handle handle, const char *method, int *val) if (ACPI_FAILURE(status)) { *val = -1; return -1; - } else { - *val = result; - return 0; } + *val = result; + return 0; + } static int method_gbmd(acpi_handle handle, unsigned long *ret) @@ -164,10 +164,10 @@ static int method_vpcr(acpi_handle handle, int cmd, int *ret) if (ACPI_FAILURE(status)) { *ret = -1; return -1; - } else { - *ret = result; - return 0; } + *ret = result; + return 0; + } static int method_vpcw(acpi_handle handle, int cmd, int data) -- GitLab From f1395edbcec81dafa1c5fff3ef9c0ab04c6fe78d Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Sat, 2 Dec 2017 21:45:32 +0800 Subject: [PATCH 0128/1190] platform/x86: ideapad-laptop: Use __func__ instead of write_ec_cmd in pr_err Address the following checkpatch warning by using __func__ instead: WARNING: Prefer using '"%s...", __func__' to using 'write_ec_cmd', this function's name, in a string Signed-off-by: Jiaxun Yang Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/ideapad-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9f2a4bc58df0d..37a88938bbaae 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -231,7 +231,7 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) if (val == 0) return 0; } - pr_err("timeout in write_ec_cmd\n"); + pr_err("timeout in %s\n", __func__); return -1; } -- GitLab From ae7c8cba32218592657130b34dc28f4d82aa755f Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Sat, 2 Dec 2017 21:45:34 +0800 Subject: [PATCH 0129/1190] platform/x86: ideapad-laptop: add lenovo RESCUER R720-15IKBN to no_hw_rfkill_list This model does not have a hardware rfkill switch, add it to the no_hw_rfkill_list to prevent the radio always being blocked. Reported-by: Roger Jargoyhen Signed-off-by: Jiaxun Yang Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/ideapad-laptop.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 37a88938bbaae..5ab638d4d2439 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -963,6 +963,13 @@ static void ideapad_wmi_notify(u32 value, void *context) * report all radios as hardware-blocked. */ static const struct dmi_system_id no_hw_rfkill_list[] = { + { + .ident = "Lenovo RESCUER R720-15IKBN", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_BOARD_NAME, "80WW"), + }, + }, { .ident = "Lenovo G40-30", .matches = { -- GitLab From 960652046899ff2fb4bd37e1e38836e3a67c27bf Mon Sep 17 00:00:00 2001 From: "Darren Hart (VMware)" Date: Fri, 8 Dec 2017 15:52:49 -0800 Subject: [PATCH 0130/1190] MAINTAINERS: Update tree for platform-drivers-x86 Update the tree listed for X86 PLATFORM DRIVERS to its new top level reposority at infradead. The old one is an alias to the new one, but we prefer to remove the "user/dvhart" from the URL. Signed-off-by: Darren Hart (VMware) --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index aa71ab52fd76d..825acf165c2dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14863,7 +14863,7 @@ X86 PLATFORM DRIVERS M: Darren Hart M: Andy Shevchenko L: platform-driver-x86@vger.kernel.org -T: git git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git +T: git git://git.infradead.org/linux-platform-drivers-x86.git S: Maintained F: drivers/platform/x86/ F: drivers/platform/olpc/ -- GitLab From 9cd5cf3710a04e6bab8efac08c241bfce2795c02 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 4 Dec 2017 10:26:17 +1000 Subject: [PATCH 0131/1190] platform/x86: asus-wireless: send an EV_SYN/SYN_REPORT between state changes Sending the switch state change twice within the same frame is invalid evdev protocol and only works if the client handles keys immediately as well. Processing events immediately is incorrect, it forces a fake order of events that does not exist on the device. Recent versions of libinput changed to only process the device state and SYN_REPORT time, so now the key event is lost. https://bugs.freedesktop.org/show_bug.cgi?id=104041 Signed-off-by: Peter Hutterer Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/asus-wireless.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c index f3796164329ef..d4aeac3477f55 100644 --- a/drivers/platform/x86/asus-wireless.c +++ b/drivers/platform/x86/asus-wireless.c @@ -118,6 +118,7 @@ static void asus_wireless_notify(struct acpi_device *adev, u32 event) return; } input_report_key(data->idev, KEY_RFKILL, 1); + input_sync(data->idev); input_report_key(data->idev, KEY_RFKILL, 0); input_sync(data->idev); } -- GitLab From 91c73e809233e8f93278458b2818fd577c3deb02 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 11 Dec 2017 13:54:27 +0300 Subject: [PATCH 0132/1190] platform/x86: dell-wmi: check for kmalloc() errors This allocation won't fail in the current kernel because it's small but not checking for kmalloc() failures introduces static checker warnings so let's fix it. Signed-off-by: Dan Carpenter Reviewed-by: Mario Limonciello Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/dell-wmi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 39d2f45184833..fb25b20df316f 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -639,6 +639,8 @@ static int dell_wmi_events_set_enabled(bool enable) int ret; buffer = kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL); + if (!buffer) + return -ENOMEM; buffer->cmd_class = CLASS_INFO; buffer->cmd_select = SELECT_APP_REGISTRATION; buffer->input[0] = 0x10000; -- GitLab From c454a99d4ce1cebb5b4dc742309187c05b4b17ee Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 7 Dec 2017 11:40:23 +0800 Subject: [PATCH 0133/1190] intel-hid: add a DMI quirk to support Wacom MobileStudio Pro HEBC method reports capabilities of 5 button array but Wacom MobileStudio Pro does not have this control method. A DMI quirk was created to enable 5 button array for this system. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=197991 Reported-by: Jason Gerecke Signed-off-by: Alex Hung Tested-by: Jason Gerecke Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/intel-hid.c | 41 +++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c index f470279c4c100..d1a01311c1a29 100644 --- a/drivers/platform/x86/intel-hid.c +++ b/drivers/platform/x86/intel-hid.c @@ -25,6 +25,7 @@ #include #include #include +#include MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alex Hung"); @@ -73,6 +74,24 @@ static const struct key_entry intel_array_keymap[] = { { KE_END }, }; +static const struct dmi_system_id button_array_table[] = { + { + .ident = "Wacom MobileStudio Pro 13", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Wacom Co.,Ltd"), + DMI_MATCH(DMI_PRODUCT_NAME, "Wacom MobileStudio Pro 13"), + }, + }, + { + .ident = "Wacom MobileStudio Pro 16", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Wacom Co.,Ltd"), + DMI_MATCH(DMI_PRODUCT_NAME, "Wacom MobileStudio Pro 16"), + }, + }, + { } +}; + struct intel_hid_priv { struct input_dev *input_dev; struct input_dev *array; @@ -263,10 +282,27 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) ev_index); } +static bool button_array_present(struct platform_device *device) +{ + acpi_handle handle = ACPI_HANDLE(&device->dev); + unsigned long long event_cap; + acpi_status status; + bool supported = false; + + status = acpi_evaluate_integer(handle, "HEBC", NULL, &event_cap); + if (ACPI_SUCCESS(status) && (event_cap & 0x20000)) + supported = true; + + if (dmi_check_system(button_array_table)) + supported = true; + + return supported; +} + static int intel_hid_probe(struct platform_device *device) { acpi_handle handle = ACPI_HANDLE(&device->dev); - unsigned long long event_cap, mode; + unsigned long long mode; struct intel_hid_priv *priv; acpi_status status; int err; @@ -299,8 +335,7 @@ static int intel_hid_probe(struct platform_device *device) } /* Setup 5 button array */ - status = acpi_evaluate_integer(handle, "HEBC", NULL, &event_cap); - if (ACPI_SUCCESS(status) && (event_cap & 0x20000)) { + if (button_array_present(device)) { dev_info(&device->dev, "platform supports 5 button array\n"); err = intel_button_array_input_setup(device); if (err) -- GitLab From 77f887cdcda8d34e21647a8e6bff6b5630036feb Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:24:57 -0500 Subject: [PATCH 0134/1190] media: si2165: Remove redundant KBUILD_MODNAME from dev_* logging Remove redundant repeated module name from messages. Before: si2165 8-0064: si2165: fw load finished After: si2165 8-0064: fw load finished Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 69 +++++++++++++--------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 528b82a5dd468..9471846ad424c 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -1,7 +1,7 @@ /* * Driver for Silicon Labs Si2161 DVB-T and Si2165 DVB-C/-T Demodulator * - * Copyright (C) 2013-2014 Matthias Schwarzott + * Copyright (C) 2013-2017 Matthias Schwarzott * * 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 @@ -314,8 +314,7 @@ static int si2165_wait_init_done(struct si2165_state *state) return 0; usleep_range(1000, 50000); } - dev_err(&state->client->dev, "%s: init_done was not set\n", - KBUILD_MODNAME); + dev_err(&state->client->dev, "init_done was not set\n"); return ret; } @@ -344,15 +343,15 @@ static int si2165_upload_firmware_block(struct si2165_state *state, if (wordcount < 1 || data[offset+1] || data[offset+2] || data[offset+3]) { dev_warn(&state->client->dev, - "%s: bad fw data[0..3] = %*ph\n", - KBUILD_MODNAME, 4, data); + "bad fw data[0..3] = %*ph\n", + 4, data); return -EINVAL; } if (offset + 8 + wordcount * 4 > len) { dev_warn(&state->client->dev, - "%s: len is too small for block len=%d, wordcount=%d\n", - KBUILD_MODNAME, len, wordcount); + "len is too small for block len=%d, wordcount=%d\n", + len, wordcount); return -EINVAL; } @@ -413,43 +412,40 @@ static int si2165_upload_firmware(struct si2165_state *state) fw_file = SI2165_FIRMWARE_REV_D; break; default: - dev_info(&state->client->dev, "%s: no firmware file for revision=%d\n", - KBUILD_MODNAME, state->chip_revcode); + dev_info(&state->client->dev, "no firmware file for revision=%d\n", + state->chip_revcode); return 0; } /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_file, &state->client->dev); if (ret) { - dev_warn(&state->client->dev, "%s: firmware file '%s' not found\n", - KBUILD_MODNAME, fw_file); + dev_warn(&state->client->dev, "firmware file '%s' not found\n", + fw_file); goto error; } data = fw->data; len = fw->size; - dev_info(&state->client->dev, "%s: downloading firmware from file '%s' size=%d\n", - KBUILD_MODNAME, fw_file, len); + dev_info(&state->client->dev, "downloading firmware from file '%s' size=%d\n", + fw_file, len); if (len % 4 != 0) { - dev_warn(&state->client->dev, "%s: firmware size is not multiple of 4\n", - KBUILD_MODNAME); + dev_warn(&state->client->dev, "firmware size is not multiple of 4\n"); ret = -EINVAL; goto error; } /* check header (8 bytes) */ if (len < 8) { - dev_warn(&state->client->dev, "%s: firmware header is missing\n", - KBUILD_MODNAME); + dev_warn(&state->client->dev, "firmware header is missing\n"); ret = -EINVAL; goto error; } if (data[0] != 1 || data[1] != 0) { - dev_warn(&state->client->dev, "%s: firmware file version is wrong\n", - KBUILD_MODNAME); + dev_warn(&state->client->dev, "firmware file version is wrong\n"); ret = -EINVAL; goto error; } @@ -486,8 +482,8 @@ static int si2165_upload_firmware(struct si2165_state *state) /* start right after the header */ offset = 8; - dev_info(&state->client->dev, "%s: si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n", - KBUILD_MODNAME, patch_version, block_count, crc_expected); + dev_info(&state->client->dev, "si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n", + patch_version, block_count, crc_expected); ret = si2165_upload_firmware_block(state, data, len, &offset, 1); if (ret < 0) @@ -506,8 +502,7 @@ static int si2165_upload_firmware(struct si2165_state *state) &offset, block_count); if (ret < 0) { dev_err(&state->client->dev, - "%s: firmware could not be uploaded\n", - KBUILD_MODNAME); + "firmware could not be uploaded\n"); goto error; } @@ -518,8 +513,8 @@ static int si2165_upload_firmware(struct si2165_state *state) if (val16 != crc_expected) { dev_err(&state->client->dev, - "%s: firmware crc mismatch %04x != %04x\n", - KBUILD_MODNAME, val16, crc_expected); + "firmware crc mismatch %04x != %04x\n", + val16, crc_expected); ret = -EINVAL; goto error; } @@ -530,8 +525,8 @@ static int si2165_upload_firmware(struct si2165_state *state) if (len != offset) { dev_err(&state->client->dev, - "%s: firmware len mismatch %04x != %04x\n", - KBUILD_MODNAME, len, offset); + "firmware len mismatch %04x != %04x\n", + len, offset); ret = -EINVAL; goto error; } @@ -546,7 +541,7 @@ static int si2165_upload_firmware(struct si2165_state *state) if (ret < 0) goto error; - dev_info(&state->client->dev, "%s: fw load finished\n", KBUILD_MODNAME); + dev_info(&state->client->dev, "fw load finished\n"); ret = 0; state->firmware_loaded = true; @@ -580,8 +575,7 @@ static int si2165_init(struct dvb_frontend *fe) if (ret < 0) goto error; if (val != state->config.chip_mode) { - dev_err(&state->client->dev, "%s: could not set chip_mode\n", - KBUILD_MODNAME); + dev_err(&state->client->dev, "could not set chip_mode\n"); return -EINVAL; } @@ -742,8 +736,7 @@ static int si2165_set_if_freq_shift(struct si2165_state *state) if (!fe->ops.tuner_ops.get_if_frequency) { dev_err(&state->client->dev, - "%s: Error: get_if_frequency() not defined at tuner. Can't work without it!\n", - KBUILD_MODNAME); + "Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); return -EINVAL; } @@ -1054,8 +1047,8 @@ static int si2165_probe(struct i2c_client *client, if (state->config.ref_freq_Hz < 4000000 || state->config.ref_freq_Hz > 27000000) { - dev_err(&state->client->dev, "%s: ref_freq of %d Hz not supported by this driver\n", - KBUILD_MODNAME, state->config.ref_freq_Hz); + dev_err(&state->client->dev, "ref_freq of %d Hz not supported by this driver\n", + state->config.ref_freq_Hz); ret = -EINVAL; goto error; } @@ -1107,14 +1100,14 @@ static int si2165_probe(struct i2c_client *client, state->has_dvbc = true; break; default: - dev_err(&state->client->dev, "%s: Unsupported Silicon Labs chip (type %d, rev %d)\n", - KBUILD_MODNAME, state->chip_type, state->chip_revcode); + dev_err(&state->client->dev, "Unsupported Silicon Labs chip (type %d, rev %d)\n", + state->chip_type, state->chip_revcode); goto nodev_error; } dev_info(&state->client->dev, - "%s: Detected Silicon Labs %s-%c (type %d, rev %d)\n", - KBUILD_MODNAME, chip_name, rev_char, state->chip_type, + "Detected Silicon Labs %s-%c (type %d, rev %d)\n", + chip_name, rev_char, state->chip_type, state->chip_revcode); strlcat(state->fe.ops.info.name, chip_name, -- GitLab From 1b54da77f32a88104d45e7d3d9b274fea619e0d6 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:24:58 -0500 Subject: [PATCH 0135/1190] media: si2165: Convert debug printk to dev_dbg Removed module parameter debug and the conditions based on it. Now it can be configured via dynamic debug. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 79 ++++++---------------------- 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 9471846ad424c..7110b3b37f239 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -62,58 +62,12 @@ struct si2165_state { bool firmware_loaded; }; -#define DEBUG_OTHER 0x01 -#define DEBUG_I2C_WRITE 0x02 -#define DEBUG_I2C_READ 0x04 -#define DEBUG_REG_READ 0x08 -#define DEBUG_REG_WRITE 0x10 -#define DEBUG_FW_LOAD 0x20 - -static int debug = 0x00; - -#define dprintk(args...) \ - do { \ - if (debug & DEBUG_OTHER) \ - printk(KERN_DEBUG "si2165: " args); \ - } while (0) - -#define deb_i2c_write(args...) \ - do { \ - if (debug & DEBUG_I2C_WRITE) \ - printk(KERN_DEBUG "si2165: i2c write: " args); \ - } while (0) - -#define deb_i2c_read(args...) \ - do { \ - if (debug & DEBUG_I2C_READ) \ - printk(KERN_DEBUG "si2165: i2c read: " args); \ - } while (0) - -#define deb_readreg(args...) \ - do { \ - if (debug & DEBUG_REG_READ) \ - printk(KERN_DEBUG "si2165: reg read: " args); \ - } while (0) - -#define deb_writereg(args...) \ - do { \ - if (debug & DEBUG_REG_WRITE) \ - printk(KERN_DEBUG "si2165: reg write: " args); \ - } while (0) - -#define deb_fw_load(args...) \ - do { \ - if (debug & DEBUG_FW_LOAD) \ - printk(KERN_DEBUG "si2165: fw load: " args); \ - } while (0) - static int si2165_write(struct si2165_state *state, const u16 reg, const u8 *src, const int count) { int ret; - if (debug & DEBUG_I2C_WRITE) - deb_i2c_write("reg: 0x%04x, data: %*ph\n", reg, count, src); + dev_dbg(&state->client->dev, "i2c write: reg: 0x%04x, data: %*ph\n", reg, count, src); ret = regmap_bulk_write(state->regmap, reg, src, count); @@ -134,8 +88,7 @@ static int si2165_read(struct si2165_state *state, return ret; } - if (debug & DEBUG_I2C_READ) - deb_i2c_read("reg: 0x%04x, data: %*ph\n", reg, count, val); + dev_dbg(&state->client->dev, "i2c read: reg: 0x%04x, data: %*ph\n", reg, count, val); return 0; } @@ -146,7 +99,7 @@ static int si2165_readreg8(struct si2165_state *state, unsigned int val_tmp; int ret = regmap_read(state->regmap, reg, &val_tmp); *val = (u8)val_tmp; - deb_readreg("R(0x%04x)=0x%02x\n", reg, *val); + dev_dbg(&state->client->dev, "reg read: R(0x%04x)=0x%02x\n", reg, *val); return ret; } @@ -157,7 +110,7 @@ static int si2165_readreg16(struct si2165_state *state, int ret = si2165_read(state, reg, buf, 2); *val = buf[0] | buf[1] << 8; - deb_readreg("R(0x%04x)=0x%04x\n", reg, *val); + dev_dbg(&state->client->dev, "reg read: R(0x%04x)=0x%04x\n", reg, *val); return ret; } @@ -332,12 +285,12 @@ static int si2165_upload_firmware_block(struct si2165_state *state, if (len % 4 != 0) return -EINVAL; - deb_fw_load( - "si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n", + dev_dbg(&state->client->dev, + "fw load: si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n", len, offset, block_count); while (offset+12 <= len && cur_block < block_count) { - deb_fw_load( - "si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", + dev_dbg(&state->client->dev, + "fw load: si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", len, offset, cur_block, block_count); wordcount = data[offset]; if (wordcount < 1 || data[offset+1] || @@ -376,14 +329,15 @@ static int si2165_upload_firmware_block(struct si2165_state *state, cur_block++; } - deb_fw_load( - "si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", + dev_dbg(&state->client->dev, + "fw load: si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", len, offset, cur_block, block_count); if (poffset) *poffset = offset; - deb_fw_load("si2165_upload_firmware_block returned offset=0x%x\n", + dev_dbg(&state->client->dev, + "fw load: si2165_upload_firmware_block returned offset=0x%x\n", offset); return 0; @@ -561,7 +515,7 @@ static int si2165_init(struct dvb_frontend *fe) u8 val; u8 patch_version = 0x00; - dprintk("%s: called\n", __func__); + dev_dbg(&state->client->dev, "%s: called\n", __func__); /* powerup */ ret = si2165_writereg8(state, 0x0000, state->config.chip_mode); @@ -722,7 +676,7 @@ static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate) do_div(oversamp, dvb_rate); reg_value = oversamp & 0x3fffffff; - dprintk("%s: Write oversamp=%#x\n", __func__, reg_value); + dev_dbg(&state->client->dev, "Write oversamp=%#x\n", reg_value); return si2165_writereg32(state, 0x00e4, reg_value); } @@ -791,7 +745,7 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe) u16 bw10k; u32 bw_hz = p->bandwidth_hz; - dprintk("%s: called\n", __func__); + dev_dbg(&state->client->dev, "%s: called\n", __func__); if (!state->has_dvbt) return -EINVAL; @@ -1166,9 +1120,6 @@ static struct i2c_driver si2165_driver = { module_i2c_driver(si2165_driver); -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); - MODULE_DESCRIPTION("Silicon Labs Si2165 DVB-C/-T Demodulator driver"); MODULE_AUTHOR("Matthias Schwarzott "); MODULE_LICENSE("GPL"); -- GitLab From 7dbbb4bf1e00bbd4612f84047906d781a370611d Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:24:59 -0500 Subject: [PATCH 0136/1190] media: si2165: Make checkpatch happy Fix almost all of checkpatch --strict warnings. The remaining warnings are about: * macro REG16 (should be enclosed in parentheses) * macro REG16 (Macro argument reuse) Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 87 ++++++++++++----------- drivers/media/dvb-frontends/si2165.h | 37 +++++----- drivers/media/dvb-frontends/si2165_priv.h | 35 ++++----- drivers/media/pci/cx23885/cx23885-dvb.c | 2 +- drivers/media/usb/cx231xx/cx231xx-dvb.c | 4 +- 5 files changed, 86 insertions(+), 79 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 7110b3b37f239..6b22d079ecef5 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -63,11 +63,12 @@ struct si2165_state { }; static int si2165_write(struct si2165_state *state, const u16 reg, - const u8 *src, const int count) + const u8 *src, const int count) { int ret; - dev_dbg(&state->client->dev, "i2c write: reg: 0x%04x, data: %*ph\n", reg, count, src); + dev_dbg(&state->client->dev, "i2c write: reg: 0x%04x, data: %*ph\n", + reg, count, src); ret = regmap_bulk_write(state->regmap, reg, src, count); @@ -88,13 +89,14 @@ static int si2165_read(struct si2165_state *state, return ret; } - dev_dbg(&state->client->dev, "i2c read: reg: 0x%04x, data: %*ph\n", reg, count, val); + dev_dbg(&state->client->dev, "i2c read: reg: 0x%04x, data: %*ph\n", + reg, count, val); return 0; } static int si2165_readreg8(struct si2165_state *state, - const u16 reg, u8 *val) + const u16 reg, u8 *val) { unsigned int val_tmp; int ret = regmap_read(state->regmap, reg, &val_tmp); @@ -104,7 +106,7 @@ static int si2165_readreg8(struct si2165_state *state, } static int si2165_readreg16(struct si2165_state *state, - const u16 reg, u16 *val) + const u16 reg, u16 *val) { u8 buf[2]; @@ -161,7 +163,9 @@ static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg, return si2165_writereg8(state, reg, val); } -#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff } +#define REG16(reg, val) \ + { (reg), (val) & 0xff }, \ + { (reg) + 1, (val) >> 8 & 0xff } struct si2165_reg_value_pair { u16 reg; u8 val; @@ -191,7 +195,7 @@ static int si2165_get_tune_settings(struct dvb_frontend *fe, static int si2165_init_pll(struct si2165_state *state) { - u32 ref_freq_Hz = state->config.ref_freq_Hz; + u32 ref_freq_hz = state->config.ref_freq_hz; u8 divr = 1; /* 1..7 */ u8 divp = 1; /* only 1 or 4 */ u8 divn = 56; /* 1..63 */ @@ -203,7 +207,7 @@ static int si2165_init_pll(struct si2165_state *state) * hardcoded values can be deleted if calculation is verified * or it yields the same values as the windows driver */ - switch (ref_freq_Hz) { + switch (ref_freq_hz) { case 16000000u: divn = 56; break; @@ -214,23 +218,23 @@ static int si2165_init_pll(struct si2165_state *state) break; default: /* ref_freq / divr must be between 4 and 16 MHz */ - if (ref_freq_Hz > 16000000u) + if (ref_freq_hz > 16000000u) divr = 2; /* * now select divn and divp such that * fvco is in 1624..1824 MHz */ - if (1624000000u * divr > ref_freq_Hz * 2u * 63u) + if (1624000000u * divr > ref_freq_hz * 2u * 63u) divp = 4; /* is this already correct regarding rounding? */ - divn = 1624000000u * divr / (ref_freq_Hz * 2u * divp); + divn = 1624000000u * divr / (ref_freq_hz * 2u * divp); break; } /* adc_clk and sys_clk depend on xtal and pll settings */ - state->fvco_hz = ref_freq_Hz / divr + state->fvco_hz = ref_freq_hz / divr * 2u * divn * divp; state->adc_clk = state->fvco_hz / (divm * 4u); state->sys_clk = state->fvco_hz / (divl * 2u); @@ -272,7 +276,8 @@ static int si2165_wait_init_done(struct si2165_state *state) } static int si2165_upload_firmware_block(struct si2165_state *state, - const u8 *data, u32 len, u32 *poffset, u32 block_count) + const u8 *data, u32 len, u32 *poffset, + u32 block_count) { int ret; u8 buf_ctrl[4] = { 0x00, 0x00, 0x00, 0xc0 }; @@ -286,15 +291,15 @@ static int si2165_upload_firmware_block(struct si2165_state *state, return -EINVAL; dev_dbg(&state->client->dev, - "fw load: si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n", - len, offset, block_count); - while (offset+12 <= len && cur_block < block_count) { + "fw load: %s: called with len=0x%x offset=0x%x blockcount=0x%x\n", + __func__, len, offset, block_count); + while (offset + 12 <= len && cur_block < block_count) { dev_dbg(&state->client->dev, - "fw load: si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", - len, offset, cur_block, block_count); + "fw load: %s: in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", + __func__, len, offset, cur_block, block_count); wordcount = data[offset]; - if (wordcount < 1 || data[offset+1] || - data[offset+2] || data[offset+3]) { + if (wordcount < 1 || data[offset + 1] || + data[offset + 2] || data[offset + 3]) { dev_warn(&state->client->dev, "bad fw data[0..3] = %*ph\n", 4, data); @@ -313,14 +318,14 @@ static int si2165_upload_firmware_block(struct si2165_state *state, ret = si2165_write(state, 0x0364, buf_ctrl, 4); if (ret < 0) goto error; - ret = si2165_write(state, 0x0368, data+offset+4, 4); + ret = si2165_write(state, 0x0368, data + offset + 4, 4); if (ret < 0) goto error; offset += 8; while (wordcount > 0) { - ret = si2165_write(state, 0x36c, data+offset, 4); + ret = si2165_write(state, 0x36c, data + offset, 4); if (ret < 0) goto error; wordcount--; @@ -330,15 +335,15 @@ static int si2165_upload_firmware_block(struct si2165_state *state, } dev_dbg(&state->client->dev, - "fw load: si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", - len, offset, cur_block, block_count); + "fw load: %s: after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", + __func__, len, offset, cur_block, block_count); if (poffset) *poffset = offset; dev_dbg(&state->client->dev, - "fw load: si2165_upload_firmware_block returned offset=0x%x\n", - offset); + "fw load: %s: returned offset=0x%x\n", + __func__, offset); return 0; error: @@ -367,7 +372,7 @@ static int si2165_upload_firmware(struct si2165_state *state) break; default: dev_info(&state->client->dev, "no firmware file for revision=%d\n", - state->chip_revcode); + state->chip_revcode); return 0; } @@ -375,7 +380,7 @@ static int si2165_upload_firmware(struct si2165_state *state) ret = request_firmware(&fw, fw_file, &state->client->dev); if (ret) { dev_warn(&state->client->dev, "firmware file '%s' not found\n", - fw_file); + fw_file); goto error; } @@ -383,7 +388,7 @@ static int si2165_upload_firmware(struct si2165_state *state) len = fw->size; dev_info(&state->client->dev, "downloading firmware from file '%s' size=%d\n", - fw_file, len); + fw_file, len); if (len % 4 != 0) { dev_warn(&state->client->dev, "firmware size is not multiple of 4\n"); @@ -436,8 +441,8 @@ static int si2165_upload_firmware(struct si2165_state *state) /* start right after the header */ offset = 8; - dev_info(&state->client->dev, "si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n", - patch_version, block_count, crc_expected); + dev_info(&state->client->dev, "%s: extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n", + __func__, patch_version, block_count, crc_expected); ret = si2165_upload_firmware_block(state, data, len, &offset, 1); if (ret < 0) @@ -963,7 +968,7 @@ static const struct dvb_frontend_ops si2165_ops = { }; static int si2165_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct si2165_state *state = NULL; struct si2165_platform_data *pdata = client->dev.platform_data; @@ -979,8 +984,8 @@ static int si2165_probe(struct i2c_client *client, }; /* allocate memory for the internal state */ - state = kzalloc(sizeof(struct si2165_state), GFP_KERNEL); - if (state == NULL) { + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) { ret = -ENOMEM; goto error; } @@ -996,20 +1001,20 @@ static int si2165_probe(struct i2c_client *client, state->client = client; state->config.i2c_addr = client->addr; state->config.chip_mode = pdata->chip_mode; - state->config.ref_freq_Hz = pdata->ref_freq_Hz; + state->config.ref_freq_hz = pdata->ref_freq_hz; state->config.inversion = pdata->inversion; - if (state->config.ref_freq_Hz < 4000000 - || state->config.ref_freq_Hz > 27000000) { + if (state->config.ref_freq_hz < 4000000 || + state->config.ref_freq_hz > 27000000) { dev_err(&state->client->dev, "ref_freq of %d Hz not supported by this driver\n", - state->config.ref_freq_Hz); + state->config.ref_freq_hz); ret = -EINVAL; goto error; } /* create dvb_frontend */ memcpy(&state->fe.ops, &si2165_ops, - sizeof(struct dvb_frontend_ops)); + sizeof(struct dvb_frontend_ops)); state->fe.ops.release = NULL; state->fe.demodulator_priv = state; i2c_set_clientdata(client, state); @@ -1060,12 +1065,12 @@ static int si2165_probe(struct i2c_client *client, } dev_info(&state->client->dev, - "Detected Silicon Labs %s-%c (type %d, rev %d)\n", + "Detected Silicon Labs %s-%c (type %d, rev %d)\n", chip_name, rev_char, state->chip_type, state->chip_revcode); strlcat(state->fe.ops.info.name, chip_name, - sizeof(state->fe.ops.info.name)); + sizeof(state->fe.ops.info.name)); n = 0; if (state->has_dvbt) { diff --git a/drivers/media/dvb-frontends/si2165.h b/drivers/media/dvb-frontends/si2165.h index 76c2ca7d7edb7..74a57b7ecd262 100644 --- a/drivers/media/dvb-frontends/si2165.h +++ b/drivers/media/dvb-frontends/si2165.h @@ -1,21 +1,22 @@ /* - Driver for Silicon Labs SI2165 DVB-C/-T Demodulator - - Copyright (C) 2013-2014 Matthias Schwarzott - - 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. - - References: - http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf -*/ + * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator + * + * Copyright (C) 2013-2017 Matthias Schwarzott + * + * 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. + * + * References: + * http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf + * + */ #ifndef _DVB_SI2165_H #define _DVB_SI2165_H @@ -44,7 +45,7 @@ struct si2165_platform_data { /* frequency of external clock or xtal in Hz * possible values: 4000000, 16000000, 20000000, 240000000, 27000000 */ - u32 ref_freq_Hz; + u32 ref_freq_hz; /* invert the spectrum */ bool inversion; diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h index e5932118834be..3d10cb4486c51 100644 --- a/drivers/media/dvb-frontends/si2165_priv.h +++ b/drivers/media/dvb-frontends/si2165_priv.h @@ -1,19 +1,19 @@ /* - Driver for Silicon Labs SI2165 DVB-C/-T Demodulator - - Copyright (C) 2013-2014 Matthias Schwarzott - - 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. - -*/ + * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator + * + * Copyright (C) 2013-2017 Matthias Schwarzott + * + * 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. + * + */ #ifndef _DVB_SI2165_PRIV #define _DVB_SI2165_PRIV @@ -22,7 +22,8 @@ struct si2165_config { /* i2c addr - * possible values: 0x64,0x65,0x66,0x67 */ + * possible values: 0x64,0x65,0x66,0x67 + */ u8 i2c_addr; /* external clock or XTAL */ @@ -31,7 +32,7 @@ struct si2165_config { /* frequency of external clock or xtal in Hz * possible values: 4000000, 16000000, 20000000, 240000000, 27000000 */ - u32 ref_freq_Hz; + u32 ref_freq_hz; /* invert the spectrum */ bool inversion; diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index e795ddeb7fe28..b33ded4613089 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -1853,7 +1853,7 @@ static int dvb_register(struct cx23885_tsport *port) memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &fe0->dvb.frontend; si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, - si2165_pdata.ref_freq_Hz = 16000000, + si2165_pdata.ref_freq_hz = 16000000, memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); info.addr = 0x64; diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index 54abc1a7c8e17..716c9e09f462b 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -763,7 +763,7 @@ static int dvb_init(struct cx231xx *dev) memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &dev->dvb->frontend; si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, - si2165_pdata.ref_freq_Hz = 16000000, + si2165_pdata.ref_freq_hz = 16000000, memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); @@ -810,7 +810,7 @@ static int dvb_init(struct cx231xx *dev) memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &dev->dvb->frontend; si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT, - si2165_pdata.ref_freq_Hz = 24000000, + si2165_pdata.ref_freq_hz = 24000000, memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); -- GitLab From 814f86c9e2d6512e6b48dc4c8177cfbab0a4ae32 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:00 -0500 Subject: [PATCH 0137/1190] media: si2165: define register macros Convert register numbers to macros. Correctness verified by comparing the disassembly before and after. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 206 +++++++++++----------- drivers/media/dvb-frontends/si2165_priv.h | 65 +++++++ 2 files changed, 169 insertions(+), 102 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 6b22d079ecef5..0f5325798bd2c 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -239,18 +239,18 @@ static int si2165_init_pll(struct si2165_state *state) state->adc_clk = state->fvco_hz / (divm * 4u); state->sys_clk = state->fvco_hz / (divl * 2u); - /* write pll registers 0x00a0..0x00a3 at once */ + /* write all 4 pll registers 0x00a0..0x00a3 at once */ buf[0] = divl; buf[1] = divm; buf[2] = (divn & 0x3f) | ((divp == 1) ? 0x40 : 0x00) | 0x80; buf[3] = divr; - return si2165_write(state, 0x00a0, buf, 4); + return si2165_write(state, REG_PLL_DIVL, buf, 4); } static int si2165_adjust_pll_divl(struct si2165_state *state, u8 divl) { state->sys_clk = state->fvco_hz / (divl * 2u); - return si2165_writereg8(state, 0x00a0, divl); /* pll_divl */ + return si2165_writereg8(state, REG_PLL_DIVL, divl); } static u32 si2165_get_fe_clk(struct si2165_state *state) @@ -266,7 +266,7 @@ static int si2165_wait_init_done(struct si2165_state *state) int i; for (i = 0; i < 3; ++i) { - si2165_readreg8(state, 0x0054, &val); + si2165_readreg8(state, REG_INIT_DONE, &val); if (val == 0x01) return 0; usleep_range(1000, 50000); @@ -315,17 +315,18 @@ static int si2165_upload_firmware_block(struct si2165_state *state, buf_ctrl[0] = wordcount - 1; - ret = si2165_write(state, 0x0364, buf_ctrl, 4); + ret = si2165_write(state, REG_DCOM_CONTROL_BYTE, buf_ctrl, 4); if (ret < 0) goto error; - ret = si2165_write(state, 0x0368, data + offset + 4, 4); + ret = si2165_write(state, REG_DCOM_ADDR, data + offset + 4, 4); if (ret < 0) goto error; offset += 8; while (wordcount > 0) { - ret = si2165_write(state, 0x36c, data + offset, 4); + ret = si2165_write(state, REG_DCOM_DATA, + data + offset, 4); if (ret < 0) goto error; wordcount--; @@ -415,26 +416,26 @@ static int si2165_upload_firmware(struct si2165_state *state) /* start uploading fw */ /* boot/wdog status */ - ret = si2165_writereg8(state, 0x0341, 0x00); + ret = si2165_writereg8(state, REG_WDOG_AND_BOOT, 0x00); if (ret < 0) goto error; /* reset */ - ret = si2165_writereg8(state, 0x00c0, 0x00); + ret = si2165_writereg8(state, REG_RST_ALL, 0x00); if (ret < 0) goto error; /* boot/wdog status */ - ret = si2165_readreg8(state, 0x0341, val); + ret = si2165_readreg8(state, REG_WDOG_AND_BOOT, val); if (ret < 0) goto error; /* enable reset on error */ - ret = si2165_readreg8(state, 0x035c, val); + ret = si2165_readreg8(state, REG_EN_RST_ERROR, val); if (ret < 0) goto error; - ret = si2165_readreg8(state, 0x035c, val); + ret = si2165_readreg8(state, REG_EN_RST_ERROR, val); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x035c, 0x02); + ret = si2165_writereg8(state, REG_EN_RST_ERROR, 0x02); if (ret < 0) goto error; @@ -448,12 +449,12 @@ static int si2165_upload_firmware(struct si2165_state *state) if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x0344, patch_version); + ret = si2165_writereg8(state, REG_PATCH_VERSION, patch_version); if (ret < 0) goto error; /* reset crc */ - ret = si2165_writereg8(state, 0x0379, 0x01); + ret = si2165_writereg8(state, REG_RST_CRC, 0x01); if (ret) goto error; @@ -466,7 +467,7 @@ static int si2165_upload_firmware(struct si2165_state *state) } /* read crc */ - ret = si2165_readreg16(state, 0x037a, &val16); + ret = si2165_readreg16(state, REG_CRC, &val16); if (ret) goto error; @@ -491,12 +492,12 @@ static int si2165_upload_firmware(struct si2165_state *state) } /* reset watchdog error register */ - ret = si2165_writereg_mask8(state, 0x0341, 0x02, 0x02); + ret = si2165_writereg_mask8(state, REG_WDOG_AND_BOOT, 0x02, 0x02); if (ret < 0) goto error; /* enable reset on error */ - ret = si2165_writereg_mask8(state, 0x035c, 0x01, 0x01); + ret = si2165_writereg_mask8(state, REG_EN_RST_ERROR, 0x01, 0x01); if (ret < 0) goto error; @@ -523,14 +524,15 @@ static int si2165_init(struct dvb_frontend *fe) dev_dbg(&state->client->dev, "%s: called\n", __func__); /* powerup */ - ret = si2165_writereg8(state, 0x0000, state->config.chip_mode); + ret = si2165_writereg8(state, REG_CHIP_MODE, state->config.chip_mode); if (ret < 0) goto error; /* dsp_clock_enable */ - ret = si2165_writereg8(state, 0x0104, 0x01); + ret = si2165_writereg8(state, REG_DSP_CLOCK, 0x01); if (ret < 0) goto error; - ret = si2165_readreg8(state, 0x0000, &val); /* verify chip_mode */ + /* verify chip_mode */ + ret = si2165_readreg8(state, REG_CHIP_MODE, &val); if (ret < 0) goto error; if (val != state->config.chip_mode) { @@ -539,23 +541,23 @@ static int si2165_init(struct dvb_frontend *fe) } /* agc */ - ret = si2165_writereg8(state, 0x018b, 0x00); + ret = si2165_writereg8(state, REG_AGC_IF_TRI, 0x00); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x0190, 0x01); + ret = si2165_writereg8(state, REG_AGC_IF_SLR, 0x01); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x0170, 0x00); + ret = si2165_writereg8(state, REG_AGC2_OUTPUT, 0x00); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x0171, 0x07); + ret = si2165_writereg8(state, REG_AGC2_CLKDIV, 0x07); if (ret < 0) goto error; /* rssi pad */ - ret = si2165_writereg8(state, 0x0646, 0x00); + ret = si2165_writereg8(state, REG_RSSI_PAD_CTRL, 0x00); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x0641, 0x00); + ret = si2165_writereg8(state, REG_RSSI_ENABLE, 0x00); if (ret < 0) goto error; @@ -564,11 +566,11 @@ static int si2165_init(struct dvb_frontend *fe) goto error; /* enable chip_init */ - ret = si2165_writereg8(state, 0x0050, 0x01); + ret = si2165_writereg8(state, REG_CHIP_INIT, 0x01); if (ret < 0) goto error; /* set start_init */ - ret = si2165_writereg8(state, 0x0096, 0x01); + ret = si2165_writereg8(state, REG_START_INIT, 0x01); if (ret < 0) goto error; ret = si2165_wait_init_done(state); @@ -576,29 +578,29 @@ static int si2165_init(struct dvb_frontend *fe) goto error; /* disable chip_init */ - ret = si2165_writereg8(state, 0x0050, 0x00); + ret = si2165_writereg8(state, REG_CHIP_INIT, 0x00); if (ret < 0) goto error; /* ber_pkt */ - ret = si2165_writereg16(state, 0x0470, 0x7530); + ret = si2165_writereg16(state, REG_BER_PKT, 0x7530); if (ret < 0) goto error; - ret = si2165_readreg8(state, 0x0344, &patch_version); + ret = si2165_readreg8(state, REG_PATCH_VERSION, &patch_version); if (ret < 0) goto error; - ret = si2165_writereg8(state, 0x00cb, 0x00); + ret = si2165_writereg8(state, REG_AUTO_RESET, 0x00); if (ret < 0) goto error; /* dsp_addr_jump */ - ret = si2165_writereg32(state, 0x0348, 0xf4000000); + ret = si2165_writereg32(state, REG_ADDR_JUMP, 0xf4000000); if (ret < 0) goto error; /* boot/wdog status */ - ret = si2165_readreg8(state, 0x0341, &val); + ret = si2165_readreg8(state, REG_WDOG_AND_BOOT, &val); if (ret < 0) goto error; @@ -609,16 +611,16 @@ static int si2165_init(struct dvb_frontend *fe) } /* ts output config */ - ret = si2165_writereg8(state, 0x04e4, 0x20); + ret = si2165_writereg8(state, REG_TS_DATA_MODE, 0x20); if (ret < 0) return ret; - ret = si2165_writereg16(state, 0x04ef, 0x00fe); + ret = si2165_writereg16(state, REG_TS_TRI, 0x00fe); if (ret < 0) return ret; - ret = si2165_writereg24(state, 0x04f4, 0x555555); + ret = si2165_writereg24(state, REG_TS_SLR, 0x555555); if (ret < 0) return ret; - ret = si2165_writereg8(state, 0x04e5, 0x01); + ret = si2165_writereg8(state, REG_TS_CLK_MODE, 0x01); if (ret < 0) return ret; @@ -633,11 +635,11 @@ static int si2165_sleep(struct dvb_frontend *fe) struct si2165_state *state = fe->demodulator_priv; /* dsp clock disable */ - ret = si2165_writereg8(state, 0x0104, 0x00); + ret = si2165_writereg8(state, REG_DSP_CLOCK, 0x00); if (ret < 0) return ret; /* chip mode */ - ret = si2165_writereg8(state, 0x0000, SI2165_MODE_OFF); + ret = si2165_writereg8(state, REG_CHIP_MODE, SI2165_MODE_OFF); if (ret < 0) return ret; return 0; @@ -653,7 +655,7 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) return -EINVAL; /* check fec_lock */ - ret = si2165_readreg8(state, 0x4e0, &fec_lock); + ret = si2165_readreg8(state, REG_FEC_LOCK, &fec_lock); if (ret < 0) return ret; *status = 0; @@ -682,7 +684,7 @@ static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate) reg_value = oversamp & 0x3fffffff; dev_dbg(&state->client->dev, "Write oversamp=%#x\n", reg_value); - return si2165_writereg32(state, 0x00e4, reg_value); + return si2165_writereg32(state, REG_OVERSAMP, reg_value); } static int si2165_set_if_freq_shift(struct si2165_state *state) @@ -715,30 +717,30 @@ static int si2165_set_if_freq_shift(struct si2165_state *state) reg_value = reg_value & 0x1fffffff; /* if_freq_shift, usbdump contained 0x023ee08f; */ - return si2165_writereg32(state, 0x00e8, reg_value); + return si2165_writereg32(state, REG_IF_FREQ_SHIFT, reg_value); } static const struct si2165_reg_value_pair dvbt_regs[] = { /* standard = DVB-T */ - { 0x00ec, 0x01 }, - { 0x08f8, 0x00 }, + { REG_DVB_STANDARD, 0x01 }, + { REG_TS_PARALLEL_MODE, 0x00 }, /* impulsive_noise_remover */ - { 0x031c, 0x01 }, - { 0x00cb, 0x00 }, + { REG_IMPULSIVE_NOISE_REM, 0x01 }, + { REG_AUTO_RESET, 0x00 }, /* agc2 */ - { 0x016e, 0x41 }, - { 0x016c, 0x0e }, - { 0x016d, 0x10 }, + { REG_AGC2_MIN, 0x41 }, + { REG_AGC2_KACQ, 0x0e }, + { REG_AGC2_KLOC, 0x10 }, /* agc */ - { 0x015b, 0x03 }, - { 0x0150, 0x78 }, + { REG_AGC_UNFREEZE_THR, 0x03 }, + { REG_AGC_CRESTF_DBX8, 0x78 }, /* agc */ - { 0x01a0, 0x78 }, - { 0x01c8, 0x68 }, + { REG_AAF_CRESTF_DBX8, 0x78 }, + { REG_ACI_CRESTF_DBX8, 0x68 }, /* freq_sync_range */ - REG16(0x030c, 0x0064), + REG16(REG_FREQ_SYNC_RANGE, 0x0064), /* gp_reg0 */ - { 0x0387, 0x00 } + { REG_GP_REG0_MSB, 0x00 } }; static int si2165_set_frontend_dvbt(struct dvb_frontend *fe) @@ -767,7 +769,7 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe) return ret; /* bandwidth in 10KHz steps */ - ret = si2165_writereg16(state, 0x0308, bw10k); + ret = si2165_writereg16(state, REG_T_BANDWIDTH, bw10k); if (ret < 0) return ret; ret = si2165_set_oversamp(state, dvb_rate); @@ -783,33 +785,33 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe) static const struct si2165_reg_value_pair dvbc_regs[] = { /* standard = DVB-C */ - { 0x00ec, 0x05 }, - { 0x08f8, 0x00 }, + { REG_DVB_STANDARD, 0x05 }, + { REG_TS_PARALLEL_MODE, 0x00 }, /* agc2 */ - { 0x016e, 0x50 }, - { 0x016c, 0x0e }, - { 0x016d, 0x10 }, + { REG_AGC2_MIN, 0x50 }, + { REG_AGC2_KACQ, 0x0e }, + { REG_AGC2_KLOC, 0x10 }, /* agc */ - { 0x015b, 0x03 }, - { 0x0150, 0x68 }, + { REG_AGC_UNFREEZE_THR, 0x03 }, + { REG_AGC_CRESTF_DBX8, 0x68 }, /* agc */ - { 0x01a0, 0x68 }, - { 0x01c8, 0x50 }, - - { 0x0278, 0x0d }, - - { 0x023a, 0x05 }, - { 0x0261, 0x09 }, - REG16(0x0350, 0x3e80), - { 0x02f4, 0x00 }, - - { 0x00cb, 0x01 }, - REG16(0x024c, 0x0000), - REG16(0x027c, 0x0000), - { 0x0232, 0x03 }, - { 0x02f4, 0x0b }, - { 0x018b, 0x00 }, + { REG_AAF_CRESTF_DBX8, 0x68 }, + { REG_ACI_CRESTF_DBX8, 0x50 }, + + { REG_EQ_AUTO_CONTROL, 0x0d }, + + { REG_KP_LOCK, 0x05 }, + { REG_CENTRAL_TAP, 0x09 }, + REG16(REG_UNKNOWN_350, 0x3e80), + { REG_REQ_CONSTELLATION, 0x00 }, + + { REG_AUTO_RESET, 0x01 }, + REG16(REG_UNKNOWN_24C, 0x0000), + REG16(REG_UNKNOWN_27C, 0x0000), + { REG_SWEEP_STEP, 0x03 }, + { REG_REQ_CONSTELLATION, 0x0b }, + { REG_AGC_IF_TRI, 0x00 }, }; static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) @@ -835,7 +837,7 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) if (ret < 0) return ret; - ret = si2165_writereg32(state, 0x00c4, bw_hz); + ret = si2165_writereg32(state, REG_LOCK_TIMEOUT, bw_hz); if (ret < 0) return ret; @@ -846,12 +848,12 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) return 0; } -static const struct si2165_reg_value_pair agc_rewrite[] = { - { 0x012a, 0x46 }, - { 0x012c, 0x00 }, - { 0x012e, 0x0a }, - { 0x012f, 0xff }, - { 0x0123, 0x70 } +static const struct si2165_reg_value_pair adc_rewrite[] = { + { REG_ADC_RI1, 0x46 }, + { REG_ADC_RI3, 0x00 }, + { REG_ADC_RI5, 0x0a }, + { REG_ADC_RI6, 0xff }, + { REG_ADC_RI8, 0x70 } }; static int si2165_set_frontend(struct dvb_frontend *fe) @@ -883,7 +885,7 @@ static int si2165_set_frontend(struct dvb_frontend *fe) } /* dsp_addr_jump */ - ret = si2165_writereg32(state, 0x0348, 0xf4000000); + ret = si2165_writereg32(state, REG_ADDR_JUMP, 0xf4000000); if (ret < 0) return ret; @@ -896,34 +898,34 @@ static int si2165_set_frontend(struct dvb_frontend *fe) return ret; /* boot/wdog status */ - ret = si2165_readreg8(state, 0x0341, val); + ret = si2165_readreg8(state, REG_WDOG_AND_BOOT, val); if (ret < 0) return ret; - ret = si2165_writereg8(state, 0x0341, 0x00); + ret = si2165_writereg8(state, REG_WDOG_AND_BOOT, 0x00); if (ret < 0) return ret; /* reset all */ - ret = si2165_writereg8(state, 0x00c0, 0x00); + ret = si2165_writereg8(state, REG_RST_ALL, 0x00); if (ret < 0) return ret; /* gp_reg0 */ - ret = si2165_writereg32(state, 0x0384, 0x00000000); + ret = si2165_writereg32(state, REG_GP_REG0_LSB, 0x00000000); if (ret < 0) return ret; /* write adc values after each reset*/ - ret = si2165_write_reg_list(state, agc_rewrite, - ARRAY_SIZE(agc_rewrite)); + ret = si2165_write_reg_list(state, adc_rewrite, + ARRAY_SIZE(adc_rewrite)); if (ret < 0) return ret; /* start_synchro */ - ret = si2165_writereg8(state, 0x02e0, 0x01); + ret = si2165_writereg8(state, REG_START_SYNCHRO, 0x01); if (ret < 0) return ret; /* boot/wdog status */ - ret = si2165_readreg8(state, 0x0341, val); + ret = si2165_readreg8(state, REG_WDOG_AND_BOOT, val); if (ret < 0) return ret; @@ -1020,26 +1022,26 @@ static int si2165_probe(struct i2c_client *client, i2c_set_clientdata(client, state); /* powerup */ - ret = si2165_writereg8(state, 0x0000, state->config.chip_mode); + ret = si2165_writereg8(state, REG_CHIP_MODE, state->config.chip_mode); if (ret < 0) goto nodev_error; - ret = si2165_readreg8(state, 0x0000, &val); + ret = si2165_readreg8(state, REG_CHIP_MODE, &val); if (ret < 0) goto nodev_error; if (val != state->config.chip_mode) goto nodev_error; - ret = si2165_readreg8(state, 0x0023, &state->chip_revcode); + ret = si2165_readreg8(state, REG_CHIP_REVCODE, &state->chip_revcode); if (ret < 0) goto nodev_error; - ret = si2165_readreg8(state, 0x0118, &state->chip_type); + ret = si2165_readreg8(state, REV_CHIP_TYPE, &state->chip_type); if (ret < 0) goto nodev_error; /* powerdown */ - ret = si2165_writereg8(state, 0x0000, SI2165_MODE_OFF); + ret = si2165_writereg8(state, REG_CHIP_MODE, SI2165_MODE_OFF); if (ret < 0) goto nodev_error; diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h index 3d10cb4486c51..da8bbda8a4e38 100644 --- a/drivers/media/dvb-frontends/si2165_priv.h +++ b/drivers/media/dvb-frontends/si2165_priv.h @@ -38,4 +38,69 @@ struct si2165_config { bool inversion; }; +#define REG_CHIP_MODE 0x0000 +#define REG_CHIP_REVCODE 0x0023 +#define REV_CHIP_TYPE 0x0118 +#define REG_CHIP_INIT 0x0050 +#define REG_INIT_DONE 0x0054 +#define REG_START_INIT 0x0096 +#define REG_PLL_DIVL 0x00a0 +#define REG_RST_ALL 0x00c0 +#define REG_LOCK_TIMEOUT 0x00c4 +#define REG_AUTO_RESET 0x00cb +#define REG_OVERSAMP 0x00e4 +#define REG_IF_FREQ_SHIFT 0x00e8 +#define REG_DVB_STANDARD 0x00ec +#define REG_DSP_CLOCK 0x0104 +#define REG_ADC_RI8 0x0123 +#define REG_ADC_RI1 0x012a +#define REG_ADC_RI2 0x012b +#define REG_ADC_RI3 0x012c +#define REG_ADC_RI4 0x012d +#define REG_ADC_RI5 0x012e +#define REG_ADC_RI6 0x012f +#define REG_AGC_CRESTF_DBX8 0x0150 +#define REG_AGC_UNFREEZE_THR 0x015b +#define REG_AGC2_MIN 0x016e +#define REG_AGC2_KACQ 0x016c +#define REG_AGC2_KLOC 0x016d +#define REG_AGC2_OUTPUT 0x0170 +#define REG_AGC2_CLKDIV 0x0171 +#define REG_AGC_IF_TRI 0x018b +#define REG_AGC_IF_SLR 0x0190 +#define REG_AAF_CRESTF_DBX8 0x01a0 +#define REG_ACI_CRESTF_DBX8 0x01c8 +#define REG_SWEEP_STEP 0x0232 +#define REG_KP_LOCK 0x023a +#define REG_UNKNOWN_24C 0x024c +#define REG_CENTRAL_TAP 0x0261 +#define REG_EQ_AUTO_CONTROL 0x0278 +#define REG_UNKNOWN_27C 0x027c +#define REG_START_SYNCHRO 0x02e0 +#define REG_REQ_CONSTELLATION 0x02f4 +#define REG_T_BANDWIDTH 0x0308 +#define REG_FREQ_SYNC_RANGE 0x030c +#define REG_IMPULSIVE_NOISE_REM 0x031c +#define REG_WDOG_AND_BOOT 0x0341 +#define REG_PATCH_VERSION 0x0344 +#define REG_ADDR_JUMP 0x0348 +#define REG_UNKNOWN_350 0x0350 +#define REG_EN_RST_ERROR 0x035c +#define REG_DCOM_CONTROL_BYTE 0x0364 +#define REG_DCOM_ADDR 0x0368 +#define REG_DCOM_DATA 0x036c +#define REG_RST_CRC 0x0379 +#define REG_GP_REG0_LSB 0x0384 +#define REG_GP_REG0_MSB 0x0387 +#define REG_CRC 0x037a +#define REG_BER_PKT 0x0470 +#define REG_FEC_LOCK 0x04e0 +#define REG_TS_DATA_MODE 0x04e4 +#define REG_TS_CLK_MODE 0x04e5 +#define REG_TS_TRI 0x04ef +#define REG_TS_SLR 0x04f4 +#define REG_RSSI_ENABLE 0x0641 +#define REG_RSSI_PAD_CTRL 0x0646 +#define REG_TS_PARALLEL_MODE 0x08f8 + #endif /* _DVB_SI2165_PRIV */ -- GitLab From ec278f879a004db8865bdb53ef8e2b0ba6382435 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:01 -0500 Subject: [PATCH 0138/1190] media: si2165: move ts parallel mode setting to the ts init code The TS parallel mode setting should be where all other TS settings are written. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 0f5325798bd2c..b2541c1fe554e 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -621,6 +621,9 @@ static int si2165_init(struct dvb_frontend *fe) if (ret < 0) return ret; ret = si2165_writereg8(state, REG_TS_CLK_MODE, 0x01); + if (ret < 0) + return ret; + ret = si2165_writereg8(state, REG_TS_PARALLEL_MODE, 0x00); if (ret < 0) return ret; @@ -723,7 +726,6 @@ static int si2165_set_if_freq_shift(struct si2165_state *state) static const struct si2165_reg_value_pair dvbt_regs[] = { /* standard = DVB-T */ { REG_DVB_STANDARD, 0x01 }, - { REG_TS_PARALLEL_MODE, 0x00 }, /* impulsive_noise_remover */ { REG_IMPULSIVE_NOISE_REM, 0x01 }, { REG_AUTO_RESET, 0x00 }, @@ -786,7 +788,6 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe) static const struct si2165_reg_value_pair dvbc_regs[] = { /* standard = DVB-C */ { REG_DVB_STANDARD, 0x05 }, - { REG_TS_PARALLEL_MODE, 0x00 }, /* agc2 */ { REG_AGC2_MIN, 0x50 }, -- GitLab From f4d90518920952c0c7deae0f69dcaab32ad1735d Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:03 -0500 Subject: [PATCH 0139/1190] media: si2165: Write const value for lock timeout The lock timeout should not depend on the bandwidth. It should be either constant or depend on xtal frequency. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index b2541c1fe554e..7f22f5bdc36a4 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -821,7 +821,6 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) int ret; struct dtv_frontend_properties *p = &fe->dtv_property_cache; const u32 dvb_rate = p->symbol_rate; - const u32 bw_hz = p->bandwidth_hz; if (!state->has_dvbc) return -EINVAL; @@ -838,7 +837,7 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) if (ret < 0) return ret; - ret = si2165_writereg32(state, REG_LOCK_TIMEOUT, bw_hz); + ret = si2165_writereg32(state, REG_LOCK_TIMEOUT, 0x007a1200); if (ret < 0) return ret; -- GitLab From 548b1f94904ae1616f9338a772e89a9f2e705325 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:04 -0500 Subject: [PATCH 0140/1190] media: si2165: Use constellation from property cache instead of hardcoded QAM256 Use constellation from property cache instead of always setting it to QAM256. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 7f22f5bdc36a4..ea9d23e7e2661 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -805,13 +805,11 @@ static const struct si2165_reg_value_pair dvbc_regs[] = { { REG_KP_LOCK, 0x05 }, { REG_CENTRAL_TAP, 0x09 }, REG16(REG_UNKNOWN_350, 0x3e80), - { REG_REQ_CONSTELLATION, 0x00 }, { REG_AUTO_RESET, 0x01 }, REG16(REG_UNKNOWN_24C, 0x0000), REG16(REG_UNKNOWN_27C, 0x0000), { REG_SWEEP_STEP, 0x03 }, - { REG_REQ_CONSTELLATION, 0x0b }, { REG_AGC_IF_TRI, 0x00 }, }; @@ -821,6 +819,7 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) int ret; struct dtv_frontend_properties *p = &fe->dtv_property_cache; const u32 dvb_rate = p->symbol_rate; + u8 u8tmp; if (!state->has_dvbc) return -EINVAL; @@ -837,6 +836,31 @@ static int si2165_set_frontend_dvbc(struct dvb_frontend *fe) if (ret < 0) return ret; + switch (p->modulation) { + case QPSK: + u8tmp = 0x3; + break; + case QAM_16: + u8tmp = 0x7; + break; + case QAM_32: + u8tmp = 0x8; + break; + case QAM_64: + u8tmp = 0x9; + break; + case QAM_128: + u8tmp = 0xa; + break; + case QAM_256: + default: + u8tmp = 0xb; + break; + } + ret = si2165_writereg8(state, REG_REQ_CONSTELLATION, u8tmp); + if (ret < 0) + return ret; + ret = si2165_writereg32(state, REG_LOCK_TIMEOUT, 0x007a1200); if (ret < 0) return ret; @@ -952,7 +976,6 @@ static const struct dvb_frontend_ops si2165_ops = { FE_CAN_QAM_64 | FE_CAN_QAM_128 | FE_CAN_QAM_256 | - FE_CAN_QAM_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO | FE_CAN_MUTE_TS | -- GitLab From 1e5fde1bc224267ea2c58f9ff8db19c2f67efebf Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:02 -0500 Subject: [PATCH 0141/1190] media: si2165: improve read_status Use check_signal register for DVB-T additionally. For DVB-C use ps_lock additionally. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 41 +++++++++++++++++++---- drivers/media/dvb-frontends/si2165_priv.h | 2 ++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index ea9d23e7e2661..30ceba664f5f9 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -651,18 +651,47 @@ static int si2165_sleep(struct dvb_frontend *fe) static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) { int ret; - u8 fec_lock = 0; + u8 u8tmp; struct si2165_state *state = fe->demodulator_priv; + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + u32 delsys = p->delivery_system; - if (!state->has_dvbt) - return -EINVAL; + *status = 0; + + switch (delsys) { + case SYS_DVBT: + /* check fast signal type */ + ret = si2165_readreg8(state, REG_CHECK_SIGNAL, &u8tmp); + if (ret < 0) + return ret; + switch (u8tmp & 0x3) { + case 0: /* searching */ + case 1: /* nothing */ + break; + case 2: /* digital signal */ + *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER; + break; + } + break; + case SYS_DVBC_ANNEX_A: + /* check packet sync lock */ + ret = si2165_readreg8(state, REG_PS_LOCK, &u8tmp); + if (ret < 0) + return ret; + if (u8tmp & 0x01) { + *status |= FE_HAS_SIGNAL; + *status |= FE_HAS_CARRIER; + *status |= FE_HAS_VITERBI; + *status |= FE_HAS_SYNC; + } + break; + } /* check fec_lock */ - ret = si2165_readreg8(state, REG_FEC_LOCK, &fec_lock); + ret = si2165_readreg8(state, REG_FEC_LOCK, &u8tmp); if (ret < 0) return ret; - *status = 0; - if (fec_lock & 0x01) { + if (u8tmp & 0x01) { *status |= FE_HAS_SIGNAL; *status |= FE_HAS_CARRIER; *status |= FE_HAS_VITERBI; diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h index da8bbda8a4e38..47f18ff69fe59 100644 --- a/drivers/media/dvb-frontends/si2165_priv.h +++ b/drivers/media/dvb-frontends/si2165_priv.h @@ -93,6 +93,8 @@ struct si2165_config { #define REG_GP_REG0_LSB 0x0384 #define REG_GP_REG0_MSB 0x0387 #define REG_CRC 0x037a +#define REG_CHECK_SIGNAL 0x03a8 +#define REG_PS_LOCK 0x0440 #define REG_BER_PKT 0x0470 #define REG_FEC_LOCK 0x04e0 #define REG_TS_DATA_MODE 0x04e4 -- GitLab From c0675d0b2a15d6df9ff2e517c7e3b83043f470cf Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:07 -0500 Subject: [PATCH 0142/1190] media: si2165: add DVBv5 C/N statistics for DVB-C Add C/N statistics in dB to read_status (DVBv5). Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 43 +++++++++++++++++++++-- drivers/media/dvb-frontends/si2165_priv.h | 1 + 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 30ceba664f5f9..777b7d049ae79 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -116,6 +116,17 @@ static int si2165_readreg16(struct si2165_state *state, return ret; } +static int si2165_readreg24(struct si2165_state *state, + const u16 reg, u32 *val) +{ + u8 buf[3]; + + int ret = si2165_read(state, reg, buf, 3); + *val = buf[0] | buf[1] << 8 | buf[2] << 16; + dev_dbg(&state->client->dev, "reg read: R(0x%04x)=0x%06x\n", reg, *val); + return ret; +} + static int si2165_writereg8(struct si2165_state *state, const u16 reg, u8 val) { return regmap_write(state->regmap, reg, val); @@ -518,6 +529,7 @@ static int si2165_init(struct dvb_frontend *fe) { int ret = 0; struct si2165_state *state = fe->demodulator_priv; + struct dtv_frontend_properties *c = &fe->dtv_property_cache; u8 val; u8 patch_version = 0x00; @@ -627,6 +639,10 @@ static int si2165_init(struct dvb_frontend *fe) if (ret < 0) return ret; + c = &state->fe.dtv_property_cache; + c->cnr.len = 1; + c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return 0; error: return ret; @@ -652,9 +668,10 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) { int ret; u8 u8tmp; + u32 u32tmp; struct si2165_state *state = fe->demodulator_priv; - struct dtv_frontend_properties *p = &fe->dtv_property_cache; - u32 delsys = p->delivery_system; + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + u32 delsys = c->delivery_system; *status = 0; @@ -699,6 +716,28 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) *status |= FE_HAS_LOCK; } + /* CNR */ + if (delsys == SYS_DVBC_ANNEX_A && *status & FE_HAS_VITERBI) { + ret = si2165_readreg24(state, REG_C_N, &u32tmp); + if (ret < 0) + return ret; + /* + * svalue = + * 1000 * c_n/dB = + * 1000 * 10 * log10(2^24 / regval) = + * 1000 * 10 * (log10(2^24) - log10(regval)) = + * 1000 * 10 * (intlog10(2^24) - intlog10(regval)) / 2^24 + * + * intlog10(x) = log10(x) * 2^24 + * intlog10(2^24) = log10(2^24) * 2^24 = 121210686 + */ + u32tmp = (1000 * 10 * (121210686 - (u64)intlog10(u32tmp))) + >> 24; + c->cnr.stat[0].scale = FE_SCALE_DECIBEL; + c->cnr.stat[0].svalue = u32tmp; + } else + c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return 0; } diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h index 47f18ff69fe59..9d79e86d04c2c 100644 --- a/drivers/media/dvb-frontends/si2165_priv.h +++ b/drivers/media/dvb-frontends/si2165_priv.h @@ -74,6 +74,7 @@ struct si2165_config { #define REG_KP_LOCK 0x023a #define REG_UNKNOWN_24C 0x024c #define REG_CENTRAL_TAP 0x0261 +#define REG_C_N 0x026c #define REG_EQ_AUTO_CONTROL 0x0278 #define REG_UNKNOWN_27C 0x027c #define REG_START_SYNCHRO 0x02e0 -- GitLab From 964b372740ad5f92c12220ebbb03b04a6cdf0435 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:08 -0500 Subject: [PATCH 0143/1190] media: si2165: add DVBv5 BER statistics Add support for BER statistics. Configure a measurement period of 30000 packets. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 57 ++++++++++++++++++++++- drivers/media/dvb-frontends/si2165_priv.h | 11 +++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 777b7d049ae79..1cd2120f5dc48 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -594,8 +594,9 @@ static int si2165_init(struct dvb_frontend *fe) if (ret < 0) goto error; - /* ber_pkt */ - ret = si2165_writereg16(state, REG_BER_PKT, 0x7530); + /* ber_pkt - default 65535 */ + ret = si2165_writereg16(state, REG_BER_PKT, + STATISTICS_PERIOD_PKT_COUNT); if (ret < 0) goto error; @@ -642,6 +643,10 @@ static int si2165_init(struct dvb_frontend *fe) c = &state->fe.dtv_property_cache; c->cnr.len = 1; c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + c->post_bit_error.len = 1; + c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + c->post_bit_count.len = 1; + c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; return 0; error: @@ -738,6 +743,54 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) } else c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + /* BER */ + if (*status & FE_HAS_VITERBI) { + if (c->post_bit_error.stat[0].scale == FE_SCALE_NOT_AVAILABLE) { + /* start new sampling period to get rid of old data*/ + ret = si2165_writereg8(state, REG_BER_RST, 0x01); + if (ret < 0) + return ret; + + /* set scale to enter read code on next call */ + c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; + c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; + c->post_bit_error.stat[0].uvalue = 0; + c->post_bit_count.stat[0].uvalue = 0; + + } else { + ret = si2165_readreg8(state, REG_BER_AVAIL, &u8tmp); + if (ret < 0) + return ret; + + if (u8tmp & 1) { + u32 biterrcnt; + + ret = si2165_readreg24(state, REG_BER_BIT, + &biterrcnt); + if (ret < 0) + return ret; + + c->post_bit_error.stat[0].uvalue += + biterrcnt; + c->post_bit_count.stat[0].uvalue += + STATISTICS_PERIOD_BIT_COUNT; + + /* start new sampling period */ + ret = si2165_writereg8(state, + REG_BER_RST, 0x01); + if (ret < 0) + return ret; + + dev_dbg(&state->client->dev, + "post_bit_error=%u post_bit_count=%u\n", + biterrcnt, STATISTICS_PERIOD_BIT_COUNT); + } + } + } else { + c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + } + return 0; } diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h index 9d79e86d04c2c..8c6fbfe441ffb 100644 --- a/drivers/media/dvb-frontends/si2165_priv.h +++ b/drivers/media/dvb-frontends/si2165_priv.h @@ -38,6 +38,9 @@ struct si2165_config { bool inversion; }; +#define STATISTICS_PERIOD_PKT_COUNT 30000u +#define STATISTICS_PERIOD_BIT_COUNT (STATISTICS_PERIOD_PKT_COUNT * 204 * 8) + #define REG_CHIP_MODE 0x0000 #define REG_CHIP_REVCODE 0x0023 #define REV_CHIP_TYPE 0x0118 @@ -95,8 +98,16 @@ struct si2165_config { #define REG_GP_REG0_MSB 0x0387 #define REG_CRC 0x037a #define REG_CHECK_SIGNAL 0x03a8 +#define REG_CBER_RST 0x0424 +#define REG_CBER_BIT 0x0428 +#define REG_CBER_ERR 0x0430 +#define REG_CBER_AVAIL 0x0434 #define REG_PS_LOCK 0x0440 +#define REG_UNCOR_CNT 0x0468 +#define REG_BER_RST 0x046c #define REG_BER_PKT 0x0470 +#define REG_BER_BIT 0x0478 +#define REG_BER_AVAIL 0x047c #define REG_FEC_LOCK 0x04e0 #define REG_TS_DATA_MODE 0x04e4 #define REG_TS_CLK_MODE 0x04e5 -- GitLab From 2e687a6d3da813dea908e55bef325526ce644fea Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:09 -0500 Subject: [PATCH 0144/1190] media: si2165: add DVBv3 wrapper for C/N statistics Add read_snr function that reads from property cache to support DVBv3. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 1cd2120f5dc48..ceb5a2bb0dea9 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -794,6 +794,17 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) return 0; } +static int si2165_read_snr(struct dvb_frontend *fe, u16 *snr) +{ + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + + if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) + *snr = div_s64(c->cnr.stat[0].svalue, 100); + else + *snr = 0; + return 0; +} + static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate) { u64 oversamp; @@ -1111,6 +1122,7 @@ static const struct dvb_frontend_ops si2165_ops = { .set_frontend = si2165_set_frontend, .read_status = si2165_read_status, + .read_snr = si2165_read_snr, }; static int si2165_probe(struct i2c_client *client, -- GitLab From e9c7d19a3894554c4ebb14513e4da6eb89b91a6a Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:10 -0500 Subject: [PATCH 0145/1190] media: si2165: Add DVBv3 wrapper for ber statistics Add read_ber function that reads from property cache to support DVBv3. The implementation is inspired by the cx24120 driver. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2165.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index ceb5a2bb0dea9..2ad6409dd6b1c 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -57,6 +57,9 @@ struct si2165_state { u32 sys_clk; u32 adc_clk; + /* DVBv3 stats */ + u64 ber_prev; + bool has_dvbc; bool has_dvbt; bool firmware_loaded; @@ -757,6 +760,12 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status) c->post_bit_error.stat[0].uvalue = 0; c->post_bit_count.stat[0].uvalue = 0; + /* + * reset DVBv3 value to deliver a good result + * for the first call + */ + state->ber_prev = 0; + } else { ret = si2165_readreg8(state, REG_BER_AVAIL, &u8tmp); if (ret < 0) @@ -805,6 +814,22 @@ static int si2165_read_snr(struct dvb_frontend *fe, u16 *snr) return 0; } +static int si2165_read_ber(struct dvb_frontend *fe, u32 *ber) +{ + struct si2165_state *state = fe->demodulator_priv; + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + + if (c->post_bit_error.stat[0].scale != FE_SCALE_COUNTER) { + *ber = 0; + return 0; + } + + *ber = c->post_bit_error.stat[0].uvalue - state->ber_prev; + state->ber_prev = c->post_bit_error.stat[0].uvalue; + + return 0; +} + static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate) { u64 oversamp; @@ -1123,6 +1148,7 @@ static const struct dvb_frontend_ops si2165_ops = { .set_frontend = si2165_set_frontend, .read_status = si2165_read_status, .read_snr = si2165_read_snr, + .read_ber = si2165_read_ber, }; static int si2165_probe(struct i2c_client *client, -- GitLab From 7e132dee584800e12f8d5539bdd02a08be98bdb4 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:05 -0500 Subject: [PATCH 0146/1190] media: cx231xx: Use semicolon after assignment instead of comma End assignments by semicolon instead of comma. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-dvb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index 716c9e09f462b..fb5654062b1ab 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -762,8 +762,8 @@ static int dvb_init(struct cx231xx *dev) /* attach demod */ memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &dev->dvb->frontend; - si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, - si2165_pdata.ref_freq_hz = 16000000, + si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL; + si2165_pdata.ref_freq_hz = 16000000; memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); @@ -809,8 +809,8 @@ static int dvb_init(struct cx231xx *dev) /* attach demod */ memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &dev->dvb->frontend; - si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT, - si2165_pdata.ref_freq_hz = 24000000, + si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT; + si2165_pdata.ref_freq_hz = 24000000; memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); -- GitLab From 7c4f4d1d7e5e3a5efc0a75410c7dad1c6c0be838 Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:06 -0500 Subject: [PATCH 0147/1190] media: cx23885: Use semicolon after assignment instead of comma End assignments by semicolon instead of comma. Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx23885/cx23885-dvb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index b33ded4613089..67ad041381832 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -1852,8 +1852,8 @@ static int dvb_register(struct cx23885_tsport *port) /* attach frontend */ memset(&si2165_pdata, 0, sizeof(si2165_pdata)); si2165_pdata.fe = &fe0->dvb.frontend; - si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, - si2165_pdata.ref_freq_hz = 16000000, + si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL; + si2165_pdata.ref_freq_hz = 16000000; memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "si2165", I2C_NAME_SIZE); info.addr = 0x64; -- GitLab From 5e0d3c3a2c67c060e65e152558fa3cbdabdafe6c Mon Sep 17 00:00:00 2001 From: Matthias Schwarzott Date: Sun, 5 Nov 2017 09:25:11 -0500 Subject: [PATCH 0148/1190] media: MAINTAINERS: add si2165 driver Silicon Labs Si2165 DVB-C/T demod driver Signed-off-by: Matthias Schwarzott Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7a52a66aa9912..2f0425e35e7dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12326,6 +12326,14 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/tuners/si2157* +SI2165 MEDIA DRIVER +M: Matthias Schwarzott +L: linux-media@vger.kernel.org +W: https://linuxtv.org +Q: http://patchwork.linuxtv.org/project/linux-media/list/ +S: Maintained +F: drivers/media/dvb-frontends/si2165* + SI2168 MEDIA DRIVER M: Antti Palosaari L: linux-media@vger.kernel.org -- GitLab From 330dada5957e3ca0c8811b14c45e3ac42c694651 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 12 Dec 2017 07:48:12 -0500 Subject: [PATCH 0149/1190] media: dvb_frontend: fix return error code The correct error code when a function is not defined is -ENOTSUPP. It was typoed wrong as -EOPNOTSUPP, with, unfortunately, exists, but it is not used by the DVB core. Thanks-to: Geert Uytterhoeven Thanks-to: Arnd Bergmann To make me revisit this code. Fixes: a9cb97c3e628 ("media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code") Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 46f977177fafb..4eedaa5922ebf 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2110,7 +2110,7 @@ static int dvb_frontend_handle_ioctl(struct file *file, struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend_private *fepriv = fe->frontend_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; - int i, err = -EOPNOTSUPP; + int i, err = -ENOTSUPP; dev_dbg(fe->dvb->device, "%s:\n", __func__); -- GitLab From c6a69269eb4f98aa998689449ad542df9741248f Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 16 Nov 2017 10:27:28 -0500 Subject: [PATCH 0150/1190] media: dibx000_common: Fix line continuation format Line continuations with excess spacing causes unexpected output. Signed-off-by: Joe Perches Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/dibx000_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/dibx000_common.c b/drivers/media/dvb-frontends/dibx000_common.c index bc28184c7fb08..d981233e458f9 100644 --- a/drivers/media/dvb-frontends/dibx000_common.c +++ b/drivers/media/dvb-frontends/dibx000_common.c @@ -288,8 +288,8 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap, int ret; if (num > 32) { - dprintk("%s: too much I2C message to be transmitted (%i).\ - Maximum is 32", __func__, num); + dprintk("%s: too much I2C message to be transmitted (%i). Maximum is 32", + __func__, num); return -ENOMEM; } @@ -335,8 +335,8 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap, int ret; if (num > 32) { - dprintk("%s: too much I2C message to be transmitted (%i).\ - Maximum is 32", __func__, num); + dprintk("%s: too much I2C message to be transmitted (%i). Maximum is 32", + __func__, num); return -ENOMEM; } -- GitLab From ddae82d09a7ea7e374edfe29ca5600ecc7941316 Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:00 +0100 Subject: [PATCH 0151/1190] MIPS: math-emu: Remove an unnecessary header inclusion Remove an unnecessary header inclusion of "ieee754dp.h". Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17583/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/sp_tlong.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/math-emu/sp_tlong.c b/arch/mips/math-emu/sp_tlong.c index a2450c7e452a6..bca5ac9958010 100644 --- a/arch/mips/math-emu/sp_tlong.c +++ b/arch/mips/math-emu/sp_tlong.c @@ -20,7 +20,6 @@ */ #include "ieee754sp.h" -#include "ieee754dp.h" s64 ieee754sp_tlong(union ieee754sp x) { -- GitLab From 999eae9bf61d379b22f460b31f76b4a03f40bb22 Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:01 +0100 Subject: [PATCH 0152/1190] MIPS: math-emu: Avoid definition duplication for macro DPXMULT() Avoid duplicate definition of macro DPXMULT(). Move its definition to a header. Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17584/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/dp_maddf.c | 3 --- arch/mips/math-emu/dp_mul.c | 3 --- arch/mips/math-emu/ieee754dp.h | 3 +++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c index 7ad79ed411f5b..28b90fd3e0930 100644 --- a/arch/mips/math-emu/dp_maddf.c +++ b/arch/mips/math-emu/dp_maddf.c @@ -201,9 +201,6 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, * Multiply 64 bits xm and ym to give 128 bits result in hrm:lrm. */ - /* 32 * 32 => 64 */ -#define DPXMULT(x, y) ((u64)(x) * (u64)y) - lxm = xm; hxm = xm >> 32; lym = ym; diff --git a/arch/mips/math-emu/dp_mul.c b/arch/mips/math-emu/dp_mul.c index 60c8bfe409473..7bc5dde8e7460 100644 --- a/arch/mips/math-emu/dp_mul.c +++ b/arch/mips/math-emu/dp_mul.c @@ -128,9 +128,6 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y) * Multiply 64 bits xm, ym to give high 64 bits rm with stickness. */ - /* 32 * 32 => 64 */ -#define DPXMULT(x, y) ((u64)(x) * (u64)y) - lxm = xm; hxm = xm >> 32; lym = ym; diff --git a/arch/mips/math-emu/ieee754dp.h b/arch/mips/math-emu/ieee754dp.h index 9ba023004eb6f..a56707b75282a 100644 --- a/arch/mips/math-emu/ieee754dp.h +++ b/arch/mips/math-emu/ieee754dp.h @@ -55,6 +55,9 @@ static inline int ieee754dp_finite(union ieee754dp x) #define XDPSRS1(v) \ (((v) >> 1) | ((v) & 1)) +/* 32bit * 32bit => 64bit unsigned integer multiplication */ +#define DPXMULT(x, y) ((u64)(x) * (u64)y) + /* convert denormal to normalized with extended exponent */ #define DPDNORMx(m,e) \ while ((m >> DP_FBITS) == 0) { m <<= 1; e--; } -- GitLab From 95306f0469580ba94e909d63ee1e2a67c5dc5cba Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:02 +0100 Subject: [PATCH 0153/1190] MIPS: math-emu: Declare function srl128() as static Declare function srl128() as static, since it it used just locally to the source file. This also removes a sparse warning for corresponding file. Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17585/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/dp_maddf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c index 28b90fd3e0930..5c4ad8e32fcb2 100644 --- a/arch/mips/math-emu/dp_maddf.c +++ b/arch/mips/math-emu/dp_maddf.c @@ -16,7 +16,7 @@ /* 128 bits shift right logical with rounding. */ -void srl128(u64 *hptr, u64 *lptr, int count) +static void srl128(u64 *hptr, u64 *lptr, int count) { u64 low; -- GitLab From 8904d5b1a31febe0ced1f56aa347e761668af571 Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:03 +0100 Subject: [PATCH 0154/1190] MIPS: math-emu: Avoid an assignment within if statement condition Move invocation of fpu_emu() to be out of if statement condition. This makes code easier to follow and debug, and fixes a checkpatch warning. Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Maciej W. Rozycki Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17586/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/cp1emu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index da6c1c0c30c11..9e5c8806e43a2 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c @@ -1353,7 +1353,8 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, return SIGILL; /* a real fpu computation instruction */ - if ((sig = fpu_emu(xcp, ctx, ir))) + sig = fpu_emu(xcp, ctx, ir); + if (sig) return sig; } break; -- GitLab From 61100500a15aed732f363cf19c5206bcd30f4754 Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:04 +0100 Subject: [PATCH 0155/1190] MIPS: math-emu: Avoid multiple assignment Replace several instances of multiple assignment with individual assignments. Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Maciej W. Rozycki Cc: Manuel Lauss Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17587/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/cp1emu.c | 3 ++- arch/mips/math-emu/dp_sqrt.c | 6 ++++-- arch/mips/math-emu/sp_sqrt.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index 9e5c8806e43a2..fe74973a0a29d 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c @@ -1190,7 +1190,8 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, if (!cpu_has_mips_r6 || delay_slot(xcp)) return SIGILL; - cond = likely = 0; + likely = 0; + cond = 0; fpr = ¤t->thread.fpu.fpr[MIPSInst_RT(ir)]; bit0 = get_fpr32(fpr, 0) & 0x1; switch (MIPSInst_RS(ir)) { diff --git a/arch/mips/math-emu/dp_sqrt.c b/arch/mips/math-emu/dp_sqrt.c index cea907b831460..fa39eb84ba8bf 100644 --- a/arch/mips/math-emu/dp_sqrt.c +++ b/arch/mips/math-emu/dp_sqrt.c @@ -91,7 +91,8 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) scalx -= 256; } - y = x = builddp(0, xe + DP_EBIAS, xm & ~DP_HIDDEN_BIT); + x = builddp(0, xe + DP_EBIAS, xm & ~DP_HIDDEN_BIT); + y = x; /* magic initial approximation to almost 8 sig. bits */ yh = y.bits >> 32; @@ -108,7 +109,8 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) /* triple to almost 56 sig. bits: y ~= sqrt(x) to within 1 ulp */ /* t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y; */ - z = t = ieee754dp_mul(y, y); + t = ieee754dp_mul(y, y); + z = t; t.bexp += 0x001; t = ieee754dp_add(t, z); z = ieee754dp_mul(ieee754dp_sub(x, z), y); diff --git a/arch/mips/math-emu/sp_sqrt.c b/arch/mips/math-emu/sp_sqrt.c index 67059c33a250a..9cc83f012342c 100644 --- a/arch/mips/math-emu/sp_sqrt.c +++ b/arch/mips/math-emu/sp_sqrt.c @@ -82,7 +82,8 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) /* generate sqrt(x) bit by bit */ ix += ix; - q = s = 0; /* q = sqrt(x) */ + s = 0; + q = 0; /* q = sqrt(x) */ r = 0x01000000; /* r = moving bit from right to left */ while (r != 0) { -- GitLab From 2a14b21acd056499cb150014e93d805a5ade2ce1 Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Thu, 2 Nov 2017 12:14:05 +0100 Subject: [PATCH 0156/1190] MIPS: math-emu: Mark fall throughs in switch statements with a comment Mark intentional fall throughs in switch statements with a consistent comment. In most of the cases, a new comment line containing text "fall through" is inserted. In some of the cases, existing comment contained a variation of the text "fall through" (for example, "FALL THROUGH" or "drop through"). In such cases, the existing comment is modified to contain "fall through". Lastly, in two cases, code segments were described in comments as "fall througs", but were in reality "breaks out" of switch statement. In such cases, existing comments are accordingly modified. Apart from making code easier to follow and debug, this change enables some static code analysers to interpret newly inserted comments as their annotations (and, therefore, not issue warnings of type "fall through in switch statement", which is desireable, since marked fallthroughs are intentional). Signed-off-by: Aleksandar Markovic Cc: Douglas Leung Cc: Goran Ferenc Cc: James Hogan Cc: Maciej W. Rozycki Cc: Manuel Lauss Cc: Miodrag Dinic Cc: Paul Burton Cc: Petar Jovanovic Cc: Raghu Gandham Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/17588/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/cp1emu.c | 22 +++++++++++++++------- arch/mips/math-emu/dp_add.c | 3 +-- arch/mips/math-emu/dp_div.c | 1 + arch/mips/math-emu/dp_fmax.c | 2 ++ arch/mips/math-emu/dp_fmin.c | 2 ++ arch/mips/math-emu/dp_maddf.c | 3 ++- arch/mips/math-emu/dp_mul.c | 1 + arch/mips/math-emu/dp_sqrt.c | 2 +- arch/mips/math-emu/dp_sub.c | 2 +- arch/mips/math-emu/sp_add.c | 3 +-- arch/mips/math-emu/sp_div.c | 1 + arch/mips/math-emu/sp_fdp.c | 3 ++- arch/mips/math-emu/sp_fmax.c | 2 ++ arch/mips/math-emu/sp_fmin.c | 2 ++ arch/mips/math-emu/sp_maddf.c | 3 ++- arch/mips/math-emu/sp_mul.c | 1 + arch/mips/math-emu/sp_sub.c | 1 + 17 files changed, 38 insertions(+), 16 deletions(-) diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index fe74973a0a29d..62deb025970bd 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c @@ -451,7 +451,7 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, regs->cp0_epc + dec_insn.pc_inc + dec_insn.next_pc_inc; } - /* Fall through */ + /* fall through */ case jr_op: /* For R6, JR already emulated in jalr_op */ if (NO_R6EMU && insn.r_format.func == jr_op) @@ -471,10 +471,11 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, regs->regs[31] = regs->cp0_epc + dec_insn.pc_inc + dec_insn.next_pc_inc; - /* Fall through */ + /* fall through */ case bltzl_op: if (NO_R6EMU) break; + /* fall through */ case bltz_op: if ((long)regs->regs[insn.i_format.rs] < 0) *contpc = regs->cp0_epc + @@ -494,10 +495,11 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, regs->regs[31] = regs->cp0_epc + dec_insn.pc_inc + dec_insn.next_pc_inc; - /* Fall through */ + /* fall through */ case bgezl_op: if (NO_R6EMU) break; + /* fall through */ case bgez_op: if ((long)regs->regs[insn.i_format.rs] >= 0) *contpc = regs->cp0_epc + @@ -512,11 +514,12 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, break; case jalx_op: set_isa16_mode(bit); + /* fall through */ case jal_op: regs->regs[31] = regs->cp0_epc + dec_insn.pc_inc + dec_insn.next_pc_inc; - /* Fall through */ + /* fall through */ case j_op: *contpc = regs->cp0_epc + dec_insn.pc_inc; *contpc >>= 28; @@ -528,6 +531,7 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, case beql_op: if (NO_R6EMU) break; + /* fall through */ case beq_op: if (regs->regs[insn.i_format.rs] == regs->regs[insn.i_format.rt]) @@ -542,6 +546,7 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, case bnel_op: if (NO_R6EMU) break; + /* fall through */ case bne_op: if (regs->regs[insn.i_format.rs] != regs->regs[insn.i_format.rt]) @@ -556,6 +561,7 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, case blezl_op: if (!insn.i_format.rt && NO_R6EMU) break; + /* fall through */ case blez_op: /* @@ -593,6 +599,7 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, case bgtzl_op: if (!insn.i_format.rt && NO_R6EMU) break; + /* fall through */ case bgtz_op: /* * Compact branches for R6 for the @@ -729,7 +736,8 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, return 1; } - /* R2/R6 compatible cop1 instruction. Fall through */ + /* R2/R6 compatible cop1 instruction */ + /* fall through */ case cop2_op: case cop1x_op: if (insn.i_format.rs == bc_op) { @@ -1221,14 +1229,14 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, case bcfl_op: if (cpu_has_mips_2_3_4_5_r) likely = 1; - /* Fall through */ + /* fall through */ case bcf_op: cond = !cond; break; case bctl_op: if (cpu_has_mips_2_3_4_5_r) likely = 1; - /* Fall through */ + /* fall through */ case bct_op: break; } diff --git a/arch/mips/math-emu/dp_add.c b/arch/mips/math-emu/dp_add.c index 8954ef031f843..678de20e4cb16 100644 --- a/arch/mips/math-emu/dp_add.c +++ b/arch/mips/math-emu/dp_add.c @@ -104,8 +104,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; - - /* FALL THROUGH */ + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; diff --git a/arch/mips/math-emu/dp_div.c b/arch/mips/math-emu/dp_div.c index f4746f7c5f63b..3063ae3ab3b9a 100644 --- a/arch/mips/math-emu/dp_div.c +++ b/arch/mips/math-emu/dp_div.c @@ -103,6 +103,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c index 5bec64f2884eb..d1f984b40344e 100644 --- a/arch/mips/math-emu/dp_fmax.c +++ b/arch/mips/math-emu/dp_fmax.c @@ -96,6 +96,7 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; @@ -224,6 +225,7 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c index a287b23818d82..f98b96135c8dd 100644 --- a/arch/mips/math-emu/dp_fmin.c +++ b/arch/mips/math-emu/dp_fmin.c @@ -96,6 +96,7 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; @@ -224,6 +225,7 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c index 5c4ad8e32fcb2..7ea2f82220267 100644 --- a/arch/mips/math-emu/dp_maddf.c +++ b/arch/mips/math-emu/dp_maddf.c @@ -157,6 +157,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): if (zc == IEEE754_CLASS_INF) @@ -173,7 +174,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754dp_inf(zs); - /* fall through to real computations */ + /* continue to real computations */ } /* Finally get to do some computation */ diff --git a/arch/mips/math-emu/dp_mul.c b/arch/mips/math-emu/dp_mul.c index 7bc5dde8e7460..c34a6cdf1b253 100644 --- a/arch/mips/math-emu/dp_mul.c +++ b/arch/mips/math-emu/dp_mul.c @@ -101,6 +101,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): DPDNORMY; diff --git a/arch/mips/math-emu/dp_sqrt.c b/arch/mips/math-emu/dp_sqrt.c index fa39eb84ba8bf..1d26c92e52957 100644 --- a/arch/mips/math-emu/dp_sqrt.c +++ b/arch/mips/math-emu/dp_sqrt.c @@ -142,7 +142,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) switch (oldcsr.rm) { case FPU_CSR_RU: y.bits += 1; - /* drop through */ + /* fall through */ case FPU_CSR_RN: t.bits += 1; break; diff --git a/arch/mips/math-emu/dp_sub.c b/arch/mips/math-emu/dp_sub.c index fc17a781b9ae8..3cc48b86519bd 100644 --- a/arch/mips/math-emu/dp_sub.c +++ b/arch/mips/math-emu/dp_sub.c @@ -106,7 +106,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): DPDNORMX; - /* FALL THROUGH */ + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): /* normalize ym,ye */ diff --git a/arch/mips/math-emu/sp_add.c b/arch/mips/math-emu/sp_add.c index c55c0c00bca80..51dced9fbdaf5 100644 --- a/arch/mips/math-emu/sp_add.c +++ b/arch/mips/math-emu/sp_add.c @@ -104,8 +104,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; - - /* FALL THROUGH */ + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; diff --git a/arch/mips/math-emu/sp_div.c b/arch/mips/math-emu/sp_div.c index 23587b31ca878..5d2904960eb89 100644 --- a/arch/mips/math-emu/sp_div.c +++ b/arch/mips/math-emu/sp_div.c @@ -103,6 +103,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; diff --git a/arch/mips/math-emu/sp_fdp.c b/arch/mips/math-emu/sp_fdp.c index 5060e8fdcb0b8..36a50f9082d12 100644 --- a/arch/mips/math-emu/sp_fdp.c +++ b/arch/mips/math-emu/sp_fdp.c @@ -46,7 +46,8 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x) case IEEE754_CLASS_SNAN: x = ieee754dp_nanxcpt(x); EXPLODEXDP; - /* Fall through. */ + /* fall through */ + case IEEE754_CLASS_QNAN: y = ieee754sp_nan_fdp(xs, xm); if (!ieee754_csr.nan2008) { diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c index 74a5a00d2f22b..22019ed691df1 100644 --- a/arch/mips/math-emu/sp_fmax.c +++ b/arch/mips/math-emu/sp_fmax.c @@ -96,6 +96,7 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; @@ -224,6 +225,7 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c index c51385f46b099..feaec3985ccac 100644 --- a/arch/mips/math-emu/sp_fmin.c +++ b/arch/mips/math-emu/sp_fmin.c @@ -96,6 +96,7 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; @@ -224,6 +225,7 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; diff --git a/arch/mips/math-emu/sp_maddf.c b/arch/mips/math-emu/sp_maddf.c index f823338dbb65d..07ba675401e24 100644 --- a/arch/mips/math-emu/sp_maddf.c +++ b/arch/mips/math-emu/sp_maddf.c @@ -126,6 +126,7 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): if (zc == IEEE754_CLASS_INF) @@ -142,7 +143,7 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754sp_inf(zs); - /* fall through to real computations */ + /* continue to real computations */ } /* Finally get to do some computation */ diff --git a/arch/mips/math-emu/sp_mul.c b/arch/mips/math-emu/sp_mul.c index 4015101fbc37e..fde71e293ec46 100644 --- a/arch/mips/math-emu/sp_mul.c +++ b/arch/mips/math-emu/sp_mul.c @@ -101,6 +101,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; diff --git a/arch/mips/math-emu/sp_sub.c b/arch/mips/math-emu/sp_sub.c index dc998ed47295d..9f2ff72c3d6ba 100644 --- a/arch/mips/math-emu/sp_sub.c +++ b/arch/mips/math-emu/sp_sub.c @@ -106,6 +106,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y) case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): SPDNORMX; + /* fall through */ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): SPDNORMY; -- GitLab From f4c12d4dee085dbb3e205e401539158588667b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Sun, 26 Nov 2017 19:32:58 +0100 Subject: [PATCH 0157/1190] platform/x86: silead_dmi: Add touchscreen info for SurfTab twin 10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add touchscreen info for the Trekstor SurfTab twin 10.1 ST10432-8 tablet. Resolution based on output of evemu-record. Signed-off-by: Bernhard Übelacker Signed-off-by: Hans de Goede Signed-off-by: Andy Shevchenko --- drivers/platform/x86/silead_dmi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/platform/x86/silead_dmi.c b/drivers/platform/x86/silead_dmi.c index 266535c2a72f2..9a3da53202cbf 100644 --- a/drivers/platform/x86/silead_dmi.c +++ b/drivers/platform/x86/silead_dmi.c @@ -67,6 +67,21 @@ static const struct silead_ts_dmi_data dexp_ursus_7w_data = { .properties = dexp_ursus_7w_props, }; +static const struct property_entry surftab_twin_10_1_st10432_8_props[] = { + PROPERTY_ENTRY_U32("touchscreen-size-x", 1900), + PROPERTY_ENTRY_U32("touchscreen-size-y", 1280), + PROPERTY_ENTRY_U32("touchscreen-inverted-y", 1), + PROPERTY_ENTRY_STRING("firmware-name", + "gsl3670-surftab-twin-10-1-st10432-8.fw"), + PROPERTY_ENTRY_U32("silead,max-fingers", 10), + { } +}; + +static const struct silead_ts_dmi_data surftab_twin_10_1_st10432_8_data = { + .acpi_name = "MSSL1680:00", + .properties = surftab_twin_10_1_st10432_8_props, +}; + static const struct property_entry surftab_wintron70_st70416_6_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 884), PROPERTY_ENTRY_U32("touchscreen-size-y", 632), @@ -198,6 +213,14 @@ static const struct dmi_system_id silead_ts_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "7W"), }, }, + { + /* TrekStor SurfTab twin 10.1 ST10432-8 */ + .driver_data = (void *)&surftab_twin_10_1_st10432_8_data, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"), + DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab twin 10.1"), + }, + }, { /* Trekstor Surftab Wintron 7.0 ST70416-6 */ .driver_data = (void *)&surftab_wintron70_st70416_6_data, -- GitLab From 32f2fe5944092f3e289098e1e0a19073b2526817 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 19 Nov 2017 13:57:17 -0500 Subject: [PATCH 0158/1190] media: c8sectpfe: DVB_C8SECTPFE should depend on HAS_DMA If NO_DMA=y: ERROR: "bad_dma_ops" [drivers/media/platform/sti/c8sectpfe/c8sectpfe.ko] undefined! Add a dependency on HAS_DMA to fix this. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/c8sectpfe/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/sti/c8sectpfe/Kconfig b/drivers/media/platform/sti/c8sectpfe/Kconfig index 7420a50572d34..740190f8a3b60 100644 --- a/drivers/media/platform/sti/c8sectpfe/Kconfig +++ b/drivers/media/platform/sti/c8sectpfe/Kconfig @@ -1,6 +1,6 @@ config DVB_C8SECTPFE tristate "STMicroelectronics C8SECTPFE DVB support" - depends on PINCTRL && DVB_CORE && I2C + depends on PINCTRL && DVB_CORE && I2C && HAS_DMA depends on ARCH_STI || ARCH_MULTIPLATFORM || COMPILE_TEST select FW_LOADER select DEBUG_FS -- GitLab From baed3c4bc4c13de93e0dba0a26d601411ebcb389 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 20 Nov 2017 09:00:55 -0500 Subject: [PATCH 0159/1190] media: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt _channel_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _channel_ has been null checked. This issue was detected with the help of Coccinelle. Fixes: c5f5d0f99794 ("[media] c8sectpfe: STiH407/10 Linux DVB demux support") Signed-off-by: Gustavo A. R. Silva Acked-by: Patrice Chotard Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index a0acee7671b16..8bd19e61846d7 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c @@ -83,7 +83,7 @@ static void c8sectpfe_timer_interrupt(struct timer_list *t) static void channel_swdemux_tsklet(unsigned long data) { struct channel_info *channel = (struct channel_info *)data; - struct c8sectpfei *fei = channel->fei; + struct c8sectpfei *fei; unsigned long wp, rp; int pos, num_packets, n, size; u8 *buf; @@ -91,6 +91,8 @@ static void channel_swdemux_tsklet(unsigned long data) if (unlikely(!channel || !channel->irec)) return; + fei = channel->fei; + wp = readl(channel->irec + DMA_PRDS_BUSWP_TP(0)); rp = readl(channel->irec + DMA_PRDS_BUSRP_TP(0)); -- GitLab From 7bed816d3465f7c4f4dac08833c1e68dd5712a84 Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Mon, 20 Nov 2017 17:46:47 -0500 Subject: [PATCH 0160/1190] media: c8sectpfe: Use resource_size function on memory resource To adapt fei->sram_size calculation via resource_size for memory size calculation before, in fei->sram = devm_ioremap_resource(dev, res). And make memory initialization range in memset_io for fei->sram appropriate Signed-off-by: Vasyl Gomonovych Acked-by: Patrice Chotard Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index 8bd19e61846d7..ef529dfe1e8c0 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c @@ -693,7 +693,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) if (IS_ERR(fei->sram)) return PTR_ERR(fei->sram); - fei->sram_size = res->end - res->start; + fei->sram_size = resource_size(res); fei->idle_irq = platform_get_irq_byname(pdev, "c8sectpfe-idle-irq"); if (fei->idle_irq < 0) { -- GitLab From 50170325b880c2d9ce7ba3c4012d7b50c767beb8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 21 Nov 2017 08:51:10 -0500 Subject: [PATCH 0161/1190] media: stb0899: remove redundant self assignment of k_indirect The self assignment of k_indirect is redundant and can be removed. Detected using coccinelle. Signed-off-by: Colin Ian King Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 3012f196e9bd9..bd2defde7a77a 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -925,8 +925,7 @@ static void stb0899_dvbs2_set_btr_loopbw(struct stb0899_state *state) wn = (4 * zeta * zeta) + 1000000; wn = (2 * (loopbw_percent * 1000) * 40 * zeta) /wn; /*wn =wn 10^-8*/ - k_indirect = (wn * wn) / K; - k_indirect = k_indirect; /*kindirect = kindirect 10^-6*/ + k_indirect = (wn * wn) / K; /*kindirect = kindirect 10^-6*/ k_direct = (2 * wn * zeta) / K; /*kDirect = kDirect 10^-2*/ k_direct *= 100; -- GitLab From 82ba8132dec8deb6dd44e1795049e000e50cb831 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 21 Nov 2017 10:07:45 -0500 Subject: [PATCH 0162/1190] media: dvb-frontends/stv0367: remove redundant self assignment of temporary The self assignment of temporary is redundant and can be removed. Detected using coccinelle. Signed-off-by: Colin Ian King Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0367.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index f3529df8211dc..ebad100d913f3 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -1547,7 +1547,6 @@ static int stv0367ter_read_ber(struct dvb_frontend *fe, u32 *ber) } else if (abc == 0x7) { if (Errors <= 4) { temporary = (Errors * 1000000000) / (8 * (1 << 14)); - temporary = temporary; } else if (Errors <= 42) { temporary = (Errors * 100000000) / (8 * (1 << 14)); temporary = temporary * 10; @@ -1625,7 +1624,6 @@ static u32 stv0367ter_get_per(struct stv0367_state *state) else if (abc == 0x9) { if (Errors <= 4) { temporary = (Errors * 1000000000) / (8 * (1 << 8)); - temporary = temporary; } else if (Errors <= 42) { temporary = (Errors * 100000000) / (8 * (1 << 8)); temporary = temporary * 10; -- GitLab From 148abd3b5b146021a637d36ac5c0ee91cd4ad520 Mon Sep 17 00:00:00 2001 From: Olli Salonen Date: Thu, 23 Nov 2017 03:24:45 -0500 Subject: [PATCH 0163/1190] media: tda18250: support for new silicon tuner NXP TDA18250 silicon tuner driver. Version 4 includes some checkpatch fixes. Signed-off-by: Olli Salonen Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 9 + drivers/media/tuners/Kconfig | 7 + drivers/media/tuners/Makefile | 1 + drivers/media/tuners/tda18250.c | 902 +++++++++++++++++++++++++++ drivers/media/tuners/tda18250.h | 51 ++ drivers/media/tuners/tda18250_priv.h | 145 +++++ 6 files changed, 1115 insertions(+) create mode 100644 drivers/media/tuners/tda18250.c create mode 100644 drivers/media/tuners/tda18250.h create mode 100644 drivers/media/tuners/tda18250_priv.h diff --git a/MAINTAINERS b/MAINTAINERS index 2f0425e35e7dd..947363d3d6e85 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13250,6 +13250,15 @@ T: git git://linuxtv.org/anttip/media_tree.git S: Maintained F: drivers/media/tuners/tda18218* +TDA18250 MEDIA DRIVER +M: Olli Salonen +L: linux-media@vger.kernel.org +W: https://linuxtv.org +Q: http://patchwork.linuxtv.org/project/linux-media/list/ +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: drivers/media/tuners/tda18250* + TDA18271 MEDIA DRIVER M: Michael Krufky L: linux-media@vger.kernel.org diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index 05998f0254c6c..6687514df97f5 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig @@ -26,6 +26,13 @@ config MEDIA_TUNER_SIMPLE help Say Y here to include support for various simple tuners. +config MEDIA_TUNER_TDA18250 + tristate "NXP TDA18250 silicon tuner" + depends on MEDIA_SUPPORT && I2C + default m if !MEDIA_SUBDRV_AUTOSELECT + help + Say Y here to include support for TDA18250 tuner. + config MEDIA_TUNER_TDA8290 tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" depends on MEDIA_SUPPORT && I2C diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile index 7be96511532dd..cb5f71b3bd780 100644 --- a/drivers/media/tuners/Makefile +++ b/drivers/media/tuners/Makefile @@ -42,6 +42,7 @@ obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o obj-$(CONFIG_MEDIA_TUNER_M88RS6000T) += m88rs6000t.o +obj-$(CONFIG_MEDIA_TUNER_TDA18250) += tda18250.o ccflags-y += -I$(srctree)/drivers/media/dvb-core ccflags-y += -I$(srctree)/drivers/media/dvb-frontends diff --git a/drivers/media/tuners/tda18250.c b/drivers/media/tuners/tda18250.c new file mode 100644 index 0000000000000..20d12b0633807 --- /dev/null +++ b/drivers/media/tuners/tda18250.c @@ -0,0 +1,902 @@ +/* + * NXP TDA18250 silicon tuner driver + * + * Copyright (C) 2017 Olli Salonen + * + * 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. + * + */ + +#include "tda18250_priv.h" +#include + +static const struct dvb_tuner_ops tda18250_ops; + +static int tda18250_power_control(struct dvb_frontend *fe, + unsigned int power_state) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + int ret; + unsigned int utmp; + + dev_dbg(&client->dev, "power state: %d", power_state); + + switch (power_state) { + case TDA18250_POWER_NORMAL: + ret = regmap_write_bits(dev->regmap, R06_POWER2, 0x07, 0x00); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, R25_REF, 0xc0, 0xc0); + if (ret) + goto err; + break; + case TDA18250_POWER_STANDBY: + if (dev->loopthrough) { + ret = regmap_write_bits(dev->regmap, + R25_REF, 0xc0, 0x80); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R06_POWER2, 0x07, 0x02); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R10_LT1, 0x80, 0x00); + if (ret) + goto err; + } else { + ret = regmap_write_bits(dev->regmap, + R25_REF, 0xc0, 0x80); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R06_POWER2, 0x07, 0x01); + if (ret) + goto err; + ret = regmap_read(dev->regmap, + R0D_AGC12, &utmp); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R0D_AGC12, 0x03, 0x03); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R10_LT1, 0x80, 0x80); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, + R0D_AGC12, 0x03, utmp & 0x03); + if (ret) + goto err; + } + break; + default: + ret = -EINVAL; + goto err; + } + + return 0; +err: + return ret; +} + +static int tda18250_wait_for_irq(struct dvb_frontend *fe, + int maxwait, int step, u8 irq) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + int ret; + unsigned long timeout; + bool triggered; + unsigned int utmp; + + triggered = false; + timeout = jiffies + msecs_to_jiffies(maxwait); + while (!time_after(jiffies, timeout)) { + // check for the IRQ + ret = regmap_read(dev->regmap, R08_IRQ1, &utmp); + if (ret) + goto err; + if ((utmp & irq) == irq) { + triggered = true; + break; + } + msleep(step); + } + + dev_dbg(&client->dev, "waited IRQ (0x%02x) %d ms, triggered: %s", irq, + jiffies_to_msecs(jiffies) - + (jiffies_to_msecs(timeout) - maxwait), + triggered ? "true" : "false"); + + if (!triggered) + return -ETIMEDOUT; + + return 0; +err: + return ret; +} + +static int tda18250_init(struct dvb_frontend *fe) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + int ret, i; + + /* default values for various regs */ + static const u8 init_regs[][2] = { + { R0C_AGC11, 0xc7 }, + { R0D_AGC12, 0x5d }, + { R0E_AGC13, 0x40 }, + { R0F_AGC14, 0x0e }, + { R10_LT1, 0x47 }, + { R11_LT2, 0x4e }, + { R12_AGC21, 0x26 }, + { R13_AGC22, 0x60 }, + { R18_AGC32, 0x37 }, + { R19_AGC33, 0x09 }, + { R1A_AGCK, 0x00 }, + { R1E_WI_FI, 0x29 }, + { R1F_RF_BPF, 0x06 }, + { R20_IR_MIX, 0xc6 }, + { R21_IF_AGC, 0x00 }, + { R2C_PS1, 0x75 }, + { R2D_PS2, 0x06 }, + { R2E_PS3, 0x07 }, + { R30_RSSI2, 0x0e }, + { R31_IRQ_CTRL, 0x00 }, + { R39_SD5, 0x00 }, + { R3B_REGU, 0x55 }, + { R3C_RCCAL1, 0xa7 }, + { R3F_IRCAL2, 0x85 }, + { R40_IRCAL3, 0x87 }, + { R41_IRCAL4, 0xc0 }, + { R43_PD1, 0x40 }, + { R44_PD2, 0xc0 }, + { R46_CPUMP, 0x0c }, + { R47_LNAPOL, 0x64 }, + { R4B_XTALOSC1, 0x30 }, + { R59_AGC2_UP2, 0x05 }, + { R5B_AGC_AUTO, 0x07 }, + { R5C_AGC_DEBUG, 0x00 }, + }; + + /* crystal related regs depend on frequency */ + static const u8 xtal_regs[][5] = { + /* reg: 4d 4e 4f 50 51 */ + [TDA18250_XTAL_FREQ_16MHZ] = { 0x3e, 0x80, 0x50, 0x00, 0x20 }, + [TDA18250_XTAL_FREQ_24MHZ] = { 0x5d, 0xc0, 0xec, 0x00, 0x18 }, + [TDA18250_XTAL_FREQ_25MHZ] = { 0x61, 0xa8, 0xec, 0x80, 0x19 }, + [TDA18250_XTAL_FREQ_27MHZ] = { 0x69, 0x78, 0x8d, 0x80, 0x1b }, + [TDA18250_XTAL_FREQ_30MHZ] = { 0x75, 0x30, 0x8f, 0x00, 0x1e }, + }; + + dev_dbg(&client->dev, "\n"); + + ret = tda18250_power_control(fe, TDA18250_POWER_NORMAL); + if (ret) + goto err; + + msleep(20); + + if (dev->warm) + goto warm; + + /* set initial register values */ + for (i = 0; i < ARRAY_SIZE(init_regs); i++) { + ret = regmap_write(dev->regmap, init_regs[i][0], + init_regs[i][1]); + if (ret) + goto err; + } + + /* set xtal related regs */ + ret = regmap_bulk_write(dev->regmap, R4D_XTALFLX1, + xtal_regs[dev->xtal_freq], 5); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R10_LT1, 0x80, + dev->loopthrough ? 0x00 : 0x80); + if (ret) + goto err; + + /* clear IRQ */ + ret = regmap_write(dev->regmap, R0A_IRQ3, TDA18250_IRQ_HW_INIT); + if (ret) + goto err; + + /* start HW init */ + ret = regmap_write(dev->regmap, R2A_MSM1, 0x70); + if (ret) + goto err; + + ret = regmap_write(dev->regmap, R2B_MSM2, 0x01); + if (ret) + goto err; + + ret = tda18250_wait_for_irq(fe, 500, 10, TDA18250_IRQ_HW_INIT); + if (ret) + goto err; + + /* tuner calibration */ + ret = regmap_write(dev->regmap, R2A_MSM1, 0x02); + if (ret) + goto err; + + ret = regmap_write(dev->regmap, R2B_MSM2, 0x01); + if (ret) + goto err; + + ret = tda18250_wait_for_irq(fe, 500, 10, TDA18250_IRQ_CAL); + if (ret) + goto err; + + dev->warm = true; + +warm: + /* power up LNA */ + ret = regmap_write_bits(dev->regmap, R0C_AGC11, 0x80, 0x00); + if (ret) + goto err; + + return 0; +err: + dev_dbg(&client->dev, "failed=%d", ret); + return ret; +} + +static int tda18250_set_agc(struct dvb_frontend *fe) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + int ret; + u8 utmp, utmp2; + + dev_dbg(&client->dev, "\n"); + + ret = regmap_write_bits(dev->regmap, R1F_RF_BPF, 0x87, 0x06); + if (ret) + goto err; + + utmp = ((c->frequency < 100000000) && + ((c->delivery_system == SYS_DVBC_ANNEX_A) || + (c->delivery_system == SYS_DVBC_ANNEX_C)) && + (c->bandwidth_hz == 6000000)) ? 0x80 : 0x00; + ret = regmap_write(dev->regmap, R5A_H3H5, utmp); + if (ret) + goto err; + + /* AGC1 */ + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + utmp = 4; + break; + default: /* DVB-C/QAM */ + switch (c->bandwidth_hz) { + case 6000000: + utmp = (c->frequency < 800000000) ? 6 : 4; + break; + default: /* 7.935 and 8 MHz */ + utmp = (c->frequency < 100000000) ? 2 : 3; + break; + } + break; + } + + ret = regmap_write_bits(dev->regmap, R0C_AGC11, 0x07, utmp); + if (ret) + goto err; + + /* AGC2 */ + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + utmp = (c->frequency < 320000000) ? 20 : 16; + utmp2 = (c->frequency < 320000000) ? 22 : 18; + break; + default: /* DVB-C/QAM */ + switch (c->bandwidth_hz) { + case 6000000: + if (c->frequency < 600000000) { + utmp = 18; + utmp2 = 22; + } else if (c->frequency < 800000000) { + utmp = 16; + utmp2 = 20; + } else { + utmp = 14; + utmp2 = 16; + } + break; + default: /* 7.935 and 8 MHz */ + utmp = (c->frequency < 320000000) ? 16 : 18; + utmp2 = (c->frequency < 320000000) ? 18 : 20; + break; + } + break; + } + ret = regmap_write_bits(dev->regmap, R58_AGC2_UP1, 0x1f, utmp2+8); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, R13_AGC22, 0x1f, utmp); + if (ret) + goto err; + ret = regmap_write_bits(dev->regmap, R14_AGC23, 0x1f, utmp2); + if (ret) + goto err; + + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + utmp = 98; + break; + default: /* DVB-C/QAM */ + utmp = 90; + break; + } + ret = regmap_write_bits(dev->regmap, R16_AGC25, 0xf8, utmp); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R12_AGC21, 0x60, + (c->frequency > 800000000) ? 0x40 : 0x20); + if (ret) + goto err; + + /* AGC3 */ + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + utmp = (c->frequency < 320000000) ? 5 : 7; + utmp2 = (c->frequency < 320000000) ? 10 : 12; + break; + default: /* DVB-C/QAM */ + utmp = 7; + utmp2 = 12; + break; + } + ret = regmap_write(dev->regmap, R17_AGC31, (utmp << 4) | utmp2); + if (ret) + goto err; + + /* S2D */ + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + if (c->bandwidth_hz == 8000000) + utmp = 0x04; + else + utmp = (c->frequency < 320000000) ? 0x04 : 0x02; + break; + default: /* DVB-C/QAM */ + if (c->bandwidth_hz == 6000000) + utmp = ((c->frequency > 172544000) && + (c->frequency < 320000000)) ? 0x04 : 0x02; + else /* 7.935 and 8 MHz */ + utmp = ((c->frequency > 320000000) && + (c->frequency < 600000000)) ? 0x02 : 0x04; + break; + } + ret = regmap_write_bits(dev->regmap, R20_IR_MIX, 0x06, utmp); + if (ret) + goto err; + + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + utmp = 0; + break; + default: /* DVB-C/QAM */ + utmp = (c->frequency < 600000000) ? 0 : 3; + break; + } + ret = regmap_write_bits(dev->regmap, R16_AGC25, 0x03, utmp); + if (ret) + goto err; + + utmp = 0x09; + switch (c->delivery_system) { + case SYS_ATSC: + case SYS_DVBT: + case SYS_DVBT2: + if (c->bandwidth_hz == 8000000) + utmp = 0x0c; + break; + default: /* DVB-C/QAM */ + utmp = 0x0c; + break; + } + ret = regmap_write_bits(dev->regmap, R0F_AGC14, 0x3f, utmp); + if (ret) + goto err; + + return 0; +err: + dev_dbg(&client->dev, "failed=%d", ret); + return ret; +} + +static int tda18250_pll_calc(struct dvb_frontend *fe, u8 *rdiv, + u8 *ndiv, u8 *icp) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + int ret; + unsigned int uval, exp, lopd, scale; + unsigned long fvco; + + ret = regmap_read(dev->regmap, R34_MD1, &uval); + if (ret) + goto err; + + exp = (uval & 0x70) >> 4; + if (exp > 5) + exp = 0; + lopd = 1 << (exp - 1); + scale = uval & 0x0f; + fvco = lopd * scale * ((c->frequency / 1000) + dev->if_frequency); + + switch (dev->xtal_freq) { + case TDA18250_XTAL_FREQ_16MHZ: + *rdiv = 1; + *ndiv = 0; + *icp = (fvco < 6622000) ? 0x05 : 0x02; + break; + case TDA18250_XTAL_FREQ_24MHZ: + case TDA18250_XTAL_FREQ_25MHZ: + *rdiv = 3; + *ndiv = 1; + *icp = (fvco < 6622000) ? 0x05 : 0x02; + break; + case TDA18250_XTAL_FREQ_27MHZ: + if (fvco < 6643000) { + *rdiv = 2; + *ndiv = 0; + *icp = 0x05; + } else if (fvco < 6811000) { + *rdiv = 2; + *ndiv = 0; + *icp = 0x06; + } else { + *rdiv = 3; + *ndiv = 1; + *icp = 0x02; + } + break; + case TDA18250_XTAL_FREQ_30MHZ: + *rdiv = 2; + *ndiv = 0; + *icp = (fvco < 6811000) ? 0x05 : 0x02; + break; + default: + return -EINVAL; + } + + dev_dbg(&client->dev, + "lopd=%d scale=%u fvco=%lu, rdiv=%d ndiv=%d icp=%d", + lopd, scale, fvco, *rdiv, *ndiv, *icp); + return 0; +err: + return ret; +} + +static int tda18250_set_params(struct dvb_frontend *fe) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + u32 if_khz; + int ret; + unsigned int i, j; + u8 utmp; + u8 buf[3]; + + #define REG 0 + #define MASK 1 + #define DVBT_6 2 + #define DVBT_7 3 + #define DVBT_8 4 + #define DVBC_6 5 + #define DVBC_8 6 + #define ATSC 7 + + static const u8 delsys_params[][16] = { + [REG] = { 0x22, 0x23, 0x24, 0x21, 0x0d, 0x0c, 0x0f, 0x14, + 0x0e, 0x12, 0x58, 0x59, 0x1a, 0x19, 0x1e, 0x30 }, + [MASK] = { 0x77, 0xff, 0xff, 0x87, 0xf0, 0x78, 0x07, 0xe0, + 0x60, 0x0f, 0x60, 0x0f, 0x33, 0x30, 0x80, 0x06 }, + [DVBT_6] = { 0x51, 0x03, 0x83, 0x82, 0x40, 0x48, 0x01, 0xe0, + 0x60, 0x0f, 0x60, 0x05, 0x03, 0x10, 0x00, 0x04 }, + [DVBT_7] = { 0x52, 0x03, 0x85, 0x82, 0x40, 0x48, 0x01, 0xe0, + 0x60, 0x0f, 0x60, 0x05, 0x03, 0x10, 0x00, 0x04 }, + [DVBT_8] = { 0x53, 0x03, 0x87, 0x82, 0x40, 0x48, 0x06, 0xe0, + 0x60, 0x07, 0x60, 0x05, 0x03, 0x10, 0x00, 0x04 }, + [DVBC_6] = { 0x32, 0x05, 0x86, 0x82, 0x50, 0x00, 0x06, 0x60, + 0x40, 0x0e, 0x60, 0x05, 0x33, 0x10, 0x00, 0x04 }, + [DVBC_8] = { 0x53, 0x03, 0x88, 0x82, 0x50, 0x00, 0x06, 0x60, + 0x40, 0x0e, 0x60, 0x05, 0x33, 0x10, 0x00, 0x04 }, + [ATSC] = { 0x51, 0x03, 0x83, 0x82, 0x40, 0x48, 0x01, 0xe0, + 0x40, 0x0e, 0x60, 0x05, 0x03, 0x00, 0x80, 0x04 }, + }; + + dev_dbg(&client->dev, + "delivery_system=%d frequency=%u bandwidth_hz=%u", + c->delivery_system, c->frequency, c->bandwidth_hz); + + + switch (c->delivery_system) { + case SYS_ATSC: + j = ATSC; + if_khz = dev->if_atsc; + break; + case SYS_DVBT: + case SYS_DVBT2: + if (c->bandwidth_hz == 0) { + ret = -EINVAL; + goto err; + } else if (c->bandwidth_hz <= 6000000) { + j = DVBT_6; + if_khz = dev->if_dvbt_6; + } else if (c->bandwidth_hz <= 7000000) { + j = DVBT_7; + if_khz = dev->if_dvbt_7; + } else if (c->bandwidth_hz <= 8000000) { + j = DVBT_8; + if_khz = dev->if_dvbt_8; + } else { + ret = -EINVAL; + goto err; + } + break; + case SYS_DVBC_ANNEX_A: + case SYS_DVBC_ANNEX_C: + if (c->bandwidth_hz == 0) { + ret = -EINVAL; + goto err; + } else if (c->bandwidth_hz <= 6000000) { + j = DVBC_6; + if_khz = dev->if_dvbc_6; + } else if (c->bandwidth_hz <= 8000000) { + j = DVBC_8; + if_khz = dev->if_dvbc_8; + } else { + ret = -EINVAL; + goto err; + } + break; + default: + ret = -EINVAL; + dev_err(&client->dev, "unsupported delivery system=%d", + c->delivery_system); + goto err; + } + + /* set delivery system dependent registers */ + for (i = 0; i < 16; i++) { + ret = regmap_write_bits(dev->regmap, delsys_params[REG][i], + delsys_params[MASK][i], delsys_params[j][i]); + if (ret) + goto err; + } + + /* set IF if needed */ + if (dev->if_frequency != if_khz) { + utmp = DIV_ROUND_CLOSEST(if_khz, 50); + ret = regmap_write(dev->regmap, R26_IF, utmp); + if (ret) + goto err; + dev->if_frequency = if_khz; + dev_dbg(&client->dev, "set IF=%u kHz", if_khz); + + } + + ret = tda18250_set_agc(fe); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R1A_AGCK, 0x03, 0x01); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R14_AGC23, 0x40, 0x00); + if (ret) + goto err; + + /* set frequency */ + buf[0] = ((c->frequency / 1000) >> 16) & 0xff; + buf[1] = ((c->frequency / 1000) >> 8) & 0xff; + buf[2] = ((c->frequency / 1000) >> 0) & 0xff; + ret = regmap_bulk_write(dev->regmap, R27_RF1, buf, 3); + if (ret) + goto err; + + ret = regmap_write(dev->regmap, R0A_IRQ3, TDA18250_IRQ_TUNE); + if (ret) + goto err; + + /* initial tune */ + ret = regmap_write(dev->regmap, R2A_MSM1, 0x01); + if (ret) + goto err; + + ret = regmap_write(dev->regmap, R2B_MSM2, 0x01); + if (ret) + goto err; + + ret = tda18250_wait_for_irq(fe, 500, 10, TDA18250_IRQ_TUNE); + if (ret) + goto err; + + /* calc ndiv and rdiv */ + ret = tda18250_pll_calc(fe, &buf[0], &buf[1], &buf[2]); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R4F_XTALFLX3, 0xe0, + (buf[0] << 6) | (buf[1] << 5)); + if (ret) + goto err; + + /* clear IRQ */ + ret = regmap_write(dev->regmap, R0A_IRQ3, TDA18250_IRQ_TUNE); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R46_CPUMP, 0x07, 0x00); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R39_SD5, 0x03, 0x00); + if (ret) + goto err; + + /* tune again */ + ret = regmap_write(dev->regmap, R2A_MSM1, 0x01); /* tune */ + if (ret) + goto err; + + ret = regmap_write(dev->regmap, R2B_MSM2, 0x01); /* go */ + if (ret) + goto err; + + ret = tda18250_wait_for_irq(fe, 500, 10, TDA18250_IRQ_TUNE); + if (ret) + goto err; + + /* pll locking */ + msleep(20); + + ret = regmap_write_bits(dev->regmap, R2B_MSM2, 0x04, 0x04); + if (ret) + goto err; + + msleep(20); + + /* restore AGCK */ + ret = regmap_write_bits(dev->regmap, R1A_AGCK, 0x03, 0x03); + if (ret) + goto err; + + ret = regmap_write_bits(dev->regmap, R14_AGC23, 0x40, 0x40); + if (ret) + goto err; + + /* charge pump */ + ret = regmap_write_bits(dev->regmap, R46_CPUMP, 0x07, buf[2]); + + return 0; +err: + return ret; +} + +static int tda18250_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + + *frequency = dev->if_frequency * 1000; + return 0; +} + +static int tda18250_sleep(struct dvb_frontend *fe) +{ + struct i2c_client *client = fe->tuner_priv; + struct tda18250_dev *dev = i2c_get_clientdata(client); + int ret; + + dev_dbg(&client->dev, "\n"); + + /* power down LNA */ + ret = regmap_write_bits(dev->regmap, R0C_AGC11, 0x80, 0x00); + if (ret) + return ret; + + /* set if freq to 0 in order to make sure it's set after wake up */ + dev->if_frequency = 0; + + ret = tda18250_power_control(fe, TDA18250_POWER_STANDBY); + return ret; +} + +static const struct dvb_tuner_ops tda18250_ops = { + .info = { + .name = "NXP TDA18250", + .frequency_min = 42000000, + .frequency_max = 870000000, + }, + + .init = tda18250_init, + .set_params = tda18250_set_params, + .get_if_frequency = tda18250_get_if_frequency, + .sleep = tda18250_sleep, +}; + +static int tda18250_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct tda18250_config *cfg = client->dev.platform_data; + struct dvb_frontend *fe = cfg->fe; + struct tda18250_dev *dev; + int ret; + unsigned char chip_id[3]; + + /* some registers are always read from HW */ + static const struct regmap_range tda18250_yes_ranges[] = { + regmap_reg_range(R05_POWER1, R0B_IRQ4), + regmap_reg_range(R21_IF_AGC, R21_IF_AGC), + regmap_reg_range(R2A_MSM1, R2B_MSM2), + regmap_reg_range(R2F_RSSI1, R31_IRQ_CTRL), + }; + + static const struct regmap_access_table tda18250_volatile_table = { + .yes_ranges = tda18250_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(tda18250_yes_ranges), + }; + + static const struct regmap_config tda18250_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = TDA18250_NUM_REGS - 1, + .volatile_table = &tda18250_volatile_table, + }; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + ret = -ENOMEM; + goto err; + } + + i2c_set_clientdata(client, dev); + + dev->fe = cfg->fe; + dev->loopthrough = cfg->loopthrough; + if (cfg->xtal_freq < TDA18250_XTAL_FREQ_MAX) { + dev->xtal_freq = cfg->xtal_freq; + } else { + ret = -EINVAL; + dev_err(&client->dev, "xtal_freq invalid=%d", cfg->xtal_freq); + goto err_kfree; + } + dev->if_dvbt_6 = cfg->if_dvbt_6; + dev->if_dvbt_7 = cfg->if_dvbt_7; + dev->if_dvbt_8 = cfg->if_dvbt_8; + dev->if_dvbc_6 = cfg->if_dvbc_6; + dev->if_dvbc_8 = cfg->if_dvbc_8; + dev->if_atsc = cfg->if_atsc; + + dev->if_frequency = 0; + dev->warm = false; + + dev->regmap = devm_regmap_init_i2c(client, &tda18250_regmap_config); + if (IS_ERR(dev->regmap)) { + ret = PTR_ERR(dev->regmap); + goto err_kfree; + } + + /* read the three chip ID registers */ + regmap_bulk_read(dev->regmap, R00_ID1, &chip_id, 3); + dev_dbg(&client->dev, "chip_id=%02x:%02x:%02x", + chip_id[0], chip_id[1], chip_id[2]); + + switch (chip_id[0]) { + case 0xc7: + dev->slave = false; + break; + case 0x47: + dev->slave = true; + break; + default: + ret = -ENODEV; + goto err_kfree; + } + + if (chip_id[1] != 0x4a) { + ret = -ENODEV; + goto err_kfree; + } + + switch (chip_id[2]) { + case 0x20: + dev_info(&client->dev, + "NXP TDA18250AHN/%s successfully identified", + dev->slave ? "S" : "M"); + break; + case 0x21: + dev_info(&client->dev, + "NXP TDA18250BHN/%s successfully identified", + dev->slave ? "S" : "M"); + break; + default: + ret = -ENODEV; + goto err_kfree; + } + + fe->tuner_priv = client; + memcpy(&fe->ops.tuner_ops, &tda18250_ops, + sizeof(struct dvb_tuner_ops)); + + /* put the tuner in standby */ + tda18250_power_control(fe, TDA18250_POWER_STANDBY); + + return 0; +err_kfree: + kfree(dev); +err: + dev_dbg(&client->dev, "failed=%d", ret); + return ret; +} + +static int tda18250_remove(struct i2c_client *client) +{ + struct tda18250_dev *dev = i2c_get_clientdata(client); + struct dvb_frontend *fe = dev->fe; + + dev_dbg(&client->dev, "\n"); + + memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); + fe->tuner_priv = NULL; + kfree(dev); + + return 0; +} + +static const struct i2c_device_id tda18250_id_table[] = { + {"tda18250", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, tda18250_id_table); + +static struct i2c_driver tda18250_driver = { + .driver = { + .name = "tda18250", + }, + .probe = tda18250_probe, + .remove = tda18250_remove, + .id_table = tda18250_id_table, +}; + +module_i2c_driver(tda18250_driver); + +MODULE_DESCRIPTION("NXP TDA18250 silicon tuner driver"); +MODULE_AUTHOR("Olli Salonen "); +MODULE_LICENSE("GPL"); diff --git a/drivers/media/tuners/tda18250.h b/drivers/media/tuners/tda18250.h new file mode 100644 index 0000000000000..fb569060876f9 --- /dev/null +++ b/drivers/media/tuners/tda18250.h @@ -0,0 +1,51 @@ +/* + * NXP TDA18250BHN silicon tuner driver + * + * Copyright (C) 2017 Olli Salonen + * + * 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. + */ + +#ifndef TDA18250_H +#define TDA18250_H + +#include +#include +#include "dvb_frontend.h" + +#define TDA18250_XTAL_FREQ_16MHZ 0 +#define TDA18250_XTAL_FREQ_24MHZ 1 +#define TDA18250_XTAL_FREQ_25MHZ 2 +#define TDA18250_XTAL_FREQ_27MHZ 3 +#define TDA18250_XTAL_FREQ_30MHZ 4 +#define TDA18250_XTAL_FREQ_MAX 5 + +struct tda18250_config { + u16 if_dvbt_6; + u16 if_dvbt_7; + u16 if_dvbt_8; + u16 if_dvbc_6; + u16 if_dvbc_8; + u16 if_atsc; + u8 xtal_freq; + bool loopthrough; + + /* + * frontend + */ + struct dvb_frontend *fe; + +#if defined(CONFIG_MEDIA_CONTROLLER) + struct media_device *mdev; +#endif +}; + +#endif diff --git a/drivers/media/tuners/tda18250_priv.h b/drivers/media/tuners/tda18250_priv.h new file mode 100644 index 0000000000000..4a6f801701a73 --- /dev/null +++ b/drivers/media/tuners/tda18250_priv.h @@ -0,0 +1,145 @@ +/* + * NXP TDA18250BHN silicon tuner driver + * + * Copyright (C) 2017 Olli Salonen + * + * 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. + */ + +#ifndef TDA18250_PRIV_H +#define TDA18250_PRIV_H + +#include "tda18250.h" + +#define R00_ID1 0x00 /* ID byte 1 */ +#define R01_ID2 0x01 /* ID byte 2 */ +#define R02_ID3 0x02 /* ID byte 3 */ +#define R03_THERMO1 0x03 /* Thermo byte 1 */ +#define R04_THERMO2 0x04 /* Thermo byte 2 */ +#define R05_POWER1 0x05 /* Power byte 1 */ +#define R06_POWER2 0x06 /* Power byte 2 */ +#define R07_GPIO 0x07 /* GPIO */ +#define R08_IRQ1 0x08 /* IRQ */ +#define R09_IRQ2 0x09 /* IRQ */ +#define R0A_IRQ3 0x0a /* IRQ */ +#define R0B_IRQ4 0x0b /* IRQ */ +#define R0C_AGC11 0x0c /* AGC1 byte 1 */ +#define R0D_AGC12 0x0d /* AGC1 byte 2 */ +#define R0E_AGC13 0x0e /* AGC1 byte 3 */ +#define R0F_AGC14 0x0f /* AGC1 byte 4 */ +#define R10_LT1 0x10 /* LT byte 1 */ +#define R11_LT2 0x11 /* LT byte 2 */ +#define R12_AGC21 0x12 /* AGC2 byte 1 */ +#define R13_AGC22 0x13 /* AGC2 byte 2 */ +#define R14_AGC23 0x14 /* AGC2 byte 3 */ +#define R15_AGC24 0x15 /* AGC2 byte 4 */ +#define R16_AGC25 0x16 /* AGC2 byte 5 */ +#define R17_AGC31 0x17 /* AGC3 byte 1 */ +#define R18_AGC32 0x18 /* AGC3 byte 2 */ +#define R19_AGC33 0x19 /* AGC3 byte 3 */ +#define R1A_AGCK 0x1a +#define R1B_GAIN1 0x1b +#define R1C_GAIN2 0x1c +#define R1D_GAIN3 0x1d +#define R1E_WI_FI 0x1e /* Wireless Filter */ +#define R1F_RF_BPF 0x1f /* RF Band Pass Filter */ +#define R20_IR_MIX 0x20 /* IR Mixer */ +#define R21_IF_AGC 0x21 +#define R22_IF1 0x22 /* IF byte 1 */ +#define R23_IF2 0x23 /* IF byte 2 */ +#define R24_IF3 0x24 /* IF byte 3 */ +#define R25_REF 0x25 /* reference byte */ +#define R26_IF 0x26 /* IF frequency */ +#define R27_RF1 0x27 /* RF frequency byte 1 */ +#define R28_RF2 0x28 /* RF frequency byte 2 */ +#define R29_RF3 0x29 /* RF frequency byte 3 */ +#define R2A_MSM1 0x2a +#define R2B_MSM2 0x2b +#define R2C_PS1 0x2c /* power saving mode byte 1 */ +#define R2D_PS2 0x2d /* power saving mode byte 2 */ +#define R2E_PS3 0x2e /* power saving mode byte 3 */ +#define R2F_RSSI1 0x2f +#define R30_RSSI2 0x30 +#define R31_IRQ_CTRL 0x31 +#define R32_DUMMY 0x32 +#define R33_TEST 0x33 +#define R34_MD1 0x34 +#define R35_SD1 0x35 +#define R36_SD2 0x36 +#define R37_SD3 0x37 +#define R38_SD4 0x38 +#define R39_SD5 0x39 +#define R3A_SD_TEST 0x3a +#define R3B_REGU 0x3b +#define R3C_RCCAL1 0x3c +#define R3D_RCCAL2 0x3d +#define R3E_IRCAL1 0x3e +#define R3F_IRCAL2 0x3f +#define R40_IRCAL3 0x40 +#define R41_IRCAL4 0x41 +#define R42_IRCAL5 0x42 +#define R43_PD1 0x43 /* power down byte 1 */ +#define R44_PD2 0x44 /* power down byte 2 */ +#define R45_PD 0x45 /* power down */ +#define R46_CPUMP 0x46 /* charge pump */ +#define R47_LNAPOL 0x47 /* LNA polar casc */ +#define R48_SMOOTH1 0x48 /* smooth test byte 1 */ +#define R49_SMOOTH2 0x49 /* smooth test byte 2 */ +#define R4A_SMOOTH3 0x4a /* smooth test byte 3 */ +#define R4B_XTALOSC1 0x4b +#define R4C_XTALOSC2 0x4c +#define R4D_XTALFLX1 0x4d +#define R4E_XTALFLX2 0x4e +#define R4F_XTALFLX3 0x4f +#define R50_XTALFLX4 0x50 +#define R51_XTALFLX5 0x51 +#define R52_IRLOOP0 0x52 +#define R53_IRLOOP1 0x53 +#define R54_IRLOOP2 0x54 +#define R55_IRLOOP3 0x55 +#define R56_IRLOOP4 0x56 +#define R57_PLL_LOG 0x57 +#define R58_AGC2_UP1 0x58 +#define R59_AGC2_UP2 0x59 +#define R5A_H3H5 0x5a +#define R5B_AGC_AUTO 0x5b +#define R5C_AGC_DEBUG 0x5c + +#define TDA18250_NUM_REGS 93 + +#define TDA18250_POWER_STANDBY 0 +#define TDA18250_POWER_NORMAL 1 + +#define TDA18250_IRQ_CAL 0x81 +#define TDA18250_IRQ_HW_INIT 0x82 +#define TDA18250_IRQ_TUNE 0x88 + +struct tda18250_dev { + struct mutex i2c_mutex; + struct dvb_frontend *fe; + struct i2c_adapter *i2c; + struct regmap *regmap; + u8 xtal_freq; + /* IF in kHz */ + u16 if_dvbt_6; + u16 if_dvbt_7; + u16 if_dvbt_8; + u16 if_dvbc_6; + u16 if_dvbc_8; + u16 if_atsc; + u16 if_frequency; + bool slave; + bool loopthrough; + bool warm; + u8 regs[TDA18250_NUM_REGS]; +}; + +#endif -- GitLab From c4d84547d5ae4fafe2dde649deaf10047ef34d00 Mon Sep 17 00:00:00 2001 From: Olli Salonen Date: Thu, 23 Nov 2017 03:24:46 -0500 Subject: [PATCH 0164/1190] media: dib0700: add support for Xbox One Digital TV Tuner Xbox One Digital TV Tuner is a low-cost USB 2.0 multistandard TV tuner. It supports DVB-T, DVB-T2 and DVB-C broadcast standards. USB bridge: DibCom 0700C Demodulator: Panasonic MN88472 Tuner: TDA18250BHN The demodulator requires firmware. Download one from here: http://palosaari.fi/linux/v4l-dvb/firmware/MN88472/02/latest/ Signed-off-by: Olli Salonen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb-usb-ids.h | 2 + drivers/media/usb/dvb-usb/Kconfig | 2 + drivers/media/usb/dvb-usb/dib0700.h | 2 + drivers/media/usb/dvb-usb/dib0700_core.c | 26 ++++- drivers/media/usb/dvb-usb/dib0700_devices.c | 109 +++++++++++++++++++- 5 files changed, 139 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h index 54d7d8a48b183..d1954e6debe34 100644 --- a/drivers/media/dvb-core/dvb-usb-ids.h +++ b/drivers/media/dvb-core/dvb-usb-ids.h @@ -81,6 +81,7 @@ #define USB_VID_AZUREWAVE 0x13d3 #define USB_VID_TECHNISAT 0x14f7 #define USB_VID_HAMA 0x147f +#define USB_VID_MICROSOFT 0x045e /* Product IDs */ #define USB_PID_ADSTECH_USB2_COLD 0xa333 @@ -418,4 +419,5 @@ #define USB_PID_WINTV_SOLOHD 0x0264 #define USB_PID_EVOLVEO_XTRATV_STICK 0xa115 #define USB_PID_HAMA_DVBT_HYBRID 0x2758 +#define USB_PID_XBOX_ONE_TUNER 0x02d5 #endif diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig index 959fa09dfd92c..2651ae2773479 100644 --- a/drivers/media/usb/dvb-usb/Kconfig +++ b/drivers/media/usb/dvb-usb/Kconfig @@ -86,6 +86,7 @@ config DVB_USB_DIB0700 select DVB_USB_DIB3000MC if MEDIA_SUBDRV_AUTOSELECT select DVB_S5H1411 if MEDIA_SUBDRV_AUTOSELECT select DVB_LGDT3305 if MEDIA_SUBDRV_AUTOSELECT + select DVB_MN88472 if MEDIA_SUBDRV_AUTOSELECT select DVB_TUNER_DIB0070 if MEDIA_SUBDRV_AUTOSELECT select DVB_TUNER_DIB0090 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT @@ -94,6 +95,7 @@ config DVB_USB_DIB0700 select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_XC4000 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT + select MEDIA_TUNER_TDA18250 if MEDIA_SUBDRV_AUTOSELECT help Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The USB bridge is also present in devices having the DiB7700 DVB-T-USB diff --git a/drivers/media/usb/dvb-usb/dib0700.h b/drivers/media/usb/dvb-usb/dib0700.h index f89ab3b5a6c4b..3a9d4c288cc25 100644 --- a/drivers/media/usb/dvb-usb/dib0700.h +++ b/drivers/media/usb/dvb-usb/dib0700.h @@ -51,6 +51,8 @@ struct dib0700_state { int (*read_status)(struct dvb_frontend *, enum fe_status *); int (*sleep)(struct dvb_frontend* fe); u8 buf[255]; + struct i2c_client *i2c_client_demod; + struct i2c_client *i2c_client_tuner; }; extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion, diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c index 1ee7ec5582938..94bd176104c11 100644 --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c @@ -911,10 +911,34 @@ static int dib0700_probe(struct usb_interface *intf, return -ENODEV; } +static void dib0700_disconnect(struct usb_interface *intf) +{ + struct dvb_usb_device *d = usb_get_intfdata(intf); + struct dib0700_state *st = d->priv; + struct i2c_client *client; + + /* remove I2C client for tuner */ + client = st->i2c_client_tuner; + if (client) { + module_put(client->dev.driver->owner); + i2c_unregister_device(client); + } + + /* remove I2C client for demodulator */ + client = st->i2c_client_demod; + if (client) { + module_put(client->dev.driver->owner); + i2c_unregister_device(client); + } + + dvb_usb_device_exit(intf); +} + + static struct usb_driver dib0700_driver = { .name = "dvb_usb_dib0700", .probe = dib0700_probe, - .disconnect = dvb_usb_device_exit, + .disconnect = dib0700_disconnect, .id_table = dib0700_usb_id_table, }; diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c index 366b055299157..470836a274dd3 100644 --- a/drivers/media/usb/dvb-usb/dib0700_devices.c +++ b/drivers/media/usb/dvb-usb/dib0700_devices.c @@ -23,6 +23,9 @@ #include "dib0090.h" #include "lgdt3305.h" #include "mxl5007t.h" +#include "mn88472.h" +#include "tda18250.h" + static int force_lna_activation; module_param(force_lna_activation, int, 0644); @@ -3725,6 +3728,90 @@ static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap) &hcw_mxl5007t_config) == NULL ? -ENODEV : 0; } +static int xbox_one_attach(struct dvb_usb_adapter *adap) +{ + struct dib0700_state *st = adap->dev->priv; + struct i2c_client *client_demod, *client_tuner; + struct dvb_usb_device *d = adap->dev; + struct mn88472_config mn88472_config = { }; + struct tda18250_config tda18250_config; + struct i2c_board_info info; + + st->fw_use_new_i2c_api = 1; + st->disable_streaming_master_mode = 1; + + /* fe power enable */ + dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); + msleep(30); + dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); + msleep(30); + + /* demod reset */ + dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); + msleep(30); + dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); + msleep(30); + dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); + msleep(30); + + /* attach demod */ + mn88472_config.fe = &adap->fe_adap[0].fe; + mn88472_config.i2c_wr_max = 22; + mn88472_config.xtal = 20500000; + mn88472_config.ts_mode = PARALLEL_TS_MODE; + mn88472_config.ts_clock = FIXED_TS_CLOCK; + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "mn88472", I2C_NAME_SIZE); + info.addr = 0x18; + info.platform_data = &mn88472_config; + request_module(info.type); + client_demod = i2c_new_device(&d->i2c_adap, &info); + if (client_demod == NULL || client_demod->dev.driver == NULL) + goto fail_demod_device; + if (!try_module_get(client_demod->dev.driver->owner)) + goto fail_demod_module; + + st->i2c_client_demod = client_demod; + + adap->fe_adap[0].fe = mn88472_config.get_dvb_frontend(client_demod); + + /* attach tuner */ + memset(&tda18250_config, 0, sizeof(tda18250_config)); + tda18250_config.if_dvbt_6 = 3950; + tda18250_config.if_dvbt_7 = 4450; + tda18250_config.if_dvbt_8 = 4950; + tda18250_config.if_dvbc_6 = 4950; + tda18250_config.if_dvbc_8 = 4950; + tda18250_config.if_atsc = 4079; + tda18250_config.loopthrough = true; + tda18250_config.xtal_freq = TDA18250_XTAL_FREQ_27MHZ; + tda18250_config.fe = adap->fe_adap[0].fe; + + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "tda18250", I2C_NAME_SIZE); + info.addr = 0x60; + info.platform_data = &tda18250_config; + + request_module(info.type); + client_tuner = i2c_new_device(&adap->dev->i2c_adap, &info); + if (client_tuner == NULL || client_tuner->dev.driver == NULL) + goto fail_tuner_device; + if (!try_module_get(client_tuner->dev.driver->owner)) + goto fail_tuner_module; + + st->i2c_client_tuner = client_tuner; + return 0; + +fail_tuner_module: + i2c_unregister_device(client_tuner); +fail_tuner_device: + module_put(client_demod->dev.driver->owner); +fail_demod_module: + i2c_unregister_device(client_demod); +fail_demod_device: + return -ENODEV; +} + /* DVB-USB and USB stuff follows */ struct usb_device_id dib0700_usb_id_table[] = { @@ -3816,7 +3903,8 @@ struct usb_device_id dib0700_usb_id_table[] = { { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) }, { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) }, { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) }, - { USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) }, +/* 85 */{ USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) }, + { USB_DEVICE(USB_VID_MICROSOFT, USB_PID_XBOX_ONE_TUNER) }, { 0 } /* Terminating entry */ }; MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); @@ -5040,6 +5128,25 @@ struct dvb_usb_device_properties dib0700_devices[] = { RC_PROTO_BIT_NEC, .change_protocol = dib0700_change_protocol, }, + }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, + .num_adapters = 1, + .adapter = { + { + DIB0700_NUM_FRONTENDS(1), + .fe = {{ + .frontend_attach = xbox_one_attach, + + DIB0700_DEFAULT_STREAMING_CONFIG(0x82), + } }, + }, + }, + .num_device_descs = 1, + .devices = { + { "Microsoft Xbox One Digital TV Tuner", + { &dib0700_usb_id_table[86], NULL }, + { NULL }, + }, + }, }, }; -- GitLab From 2ddc125de832f4d8e1820dc923cb2029170beea0 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Nov 2017 05:19:19 -0500 Subject: [PATCH 0165/1190] media: dvb_frontend: remove redundant status self assignment The assignment status to itself is redundant and can be removed. Detected with Coccinelle. Signed-off-by: Colin Ian King Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxd_hard.c | 3 --- drivers/media/dvb-frontends/tda18271c2dd.c | 1 - 2 files changed, 4 deletions(-) diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c index 3215d003b2a1d..087350ec8712a 100644 --- a/drivers/media/dvb-frontends/drxd_hard.c +++ b/drivers/media/dvb-frontends/drxd_hard.c @@ -2138,7 +2138,6 @@ static int DRX_Start(struct drxd_state *state, s32 off) } break; } - status = status; if (status < 0) break; @@ -2249,7 +2248,6 @@ static int DRX_Start(struct drxd_state *state, s32 off) break; } - status = status; if (status < 0) break; @@ -2316,7 +2314,6 @@ static int DRX_Start(struct drxd_state *state, s32 off) } break; } - status = status; if (status < 0) break; diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c index 2d2778be2d2fb..45cd5ba0cf8a1 100644 --- a/drivers/media/dvb-frontends/tda18271c2dd.c +++ b/drivers/media/dvb-frontends/tda18271c2dd.c @@ -674,7 +674,6 @@ static int PowerScan(struct tda_state *state, Count = 200000; wait = true; } - status = status; if (status < 0) break; if (CID_Gain >= CID_Target) { -- GitLab From 1cba4ae011333b7932c8fcd0d21be82f9497257f Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:03 -0500 Subject: [PATCH 0166/1190] media: frontends/stv0910: add field offsets to field defines Each field (FSTV0910_XX) is declared as reg/off/unused/sign/mask. Add the missing offset value to the defines. Picked up from dddvb master, commit 8a1f27c3d22c ("add field offset to field defines") by Ralph Metzler , adapted to match the comment style in the mainline driver. Cc: Ralph Metzler Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910_regs.h | 1854 ++++++++++---------- 1 file changed, 927 insertions(+), 927 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0910_regs.h b/drivers/media/dvb-frontends/stv0910_regs.h index 32ced4eaf2967..f0eb915090bda 100644 --- a/drivers/media/dvb-frontends/stv0910_regs.h +++ b/drivers/media/dvb-frontends/stv0910_regs.h @@ -7,15 +7,15 @@ * Registers Declaration (Internal ST, All Applications ) * ------------------------- * Each register (RSTV0910__XXXXX) is defined by its address (2 bytes). - * - * Each field (FSTV0910__XXXXX)is defined as follow: - * [register address -- 2bytes][field sign -- 1byte][field mask -- 1byte] - * ====================================================================== + * Each field (FSTV0910__XXXXX) is defined as follow: + * [register address -- 2bytes][field offset -- 4 bits][unused -- 3 bits] + * [field sign -- 1 bit][field mask -- 1byte] + * ======================================================================= */ /* MID */ #define RSTV0910_MID 0xf100 -#define FSTV0910_MCHIP_IDENT 0xf10000f0 +#define FSTV0910_MCHIP_IDENT 0xf10040f0 #define FSTV0910_MRELEASE 0xf100000f /* DID */ @@ -24,7 +24,7 @@ /* DACR1 */ #define RSTV0910_DACR1 0xf113 -#define FSTV0910_DAC_MODE 0xf11300e0 +#define FSTV0910_DAC_MODE 0xf11350e0 #define FSTV0910_DAC_VALUE1 0xf113000f /* DACR2 */ @@ -33,283 +33,283 @@ /* PADCFG */ #define RSTV0910_PADCFG 0xf11a -#define FSTV0910_AGCRF2_OPD 0xf11a0008 -#define FSTV0910_AGCRF2_XOR 0xf11a0004 -#define FSTV0910_AGCRF1_OPD 0xf11a0002 +#define FSTV0910_AGCRF2_OPD 0xf11a3008 +#define FSTV0910_AGCRF2_XOR 0xf11a2004 +#define FSTV0910_AGCRF1_OPD 0xf11a1002 #define FSTV0910_AGCRF1_XOR 0xf11a0001 /* OUTCFG2 */ #define RSTV0910_OUTCFG2 0xf11b -#define FSTV0910_TS2_ERROR_XOR 0xf11b0080 -#define FSTV0910_TS2_DPN_XOR 0xf11b0040 -#define FSTV0910_TS2_STROUT_XOR 0xf11b0020 -#define FSTV0910_TS2_CLOCKOUT_XOR 0xf11b0010 -#define FSTV0910_TS1_ERROR_XOR 0xf11b0008 -#define FSTV0910_TS1_DPN_XOR 0xf11b0004 -#define FSTV0910_TS1_STROUT_XOR 0xf11b0002 +#define FSTV0910_TS2_ERROR_XOR 0xf11b7080 +#define FSTV0910_TS2_DPN_XOR 0xf11b6040 +#define FSTV0910_TS2_STROUT_XOR 0xf11b5020 +#define FSTV0910_TS2_CLOCKOUT_XOR 0xf11b4010 +#define FSTV0910_TS1_ERROR_XOR 0xf11b3008 +#define FSTV0910_TS1_DPN_XOR 0xf11b2004 +#define FSTV0910_TS1_STROUT_XOR 0xf11b1002 #define FSTV0910_TS1_CLOCKOUT_XOR 0xf11b0001 /* OUTCFG */ #define RSTV0910_OUTCFG 0xf11c -#define FSTV0910_TS2_OUTSER_HZ 0xf11c0020 -#define FSTV0910_TS1_OUTSER_HZ 0xf11c0010 -#define FSTV0910_TS2_OUTPAR_HZ 0xf11c0008 -#define FSTV0910_TS1_OUTPAR_HZ 0xf11c0004 -#define FSTV0910_TS_SERDATA0 0xf11c0002 +#define FSTV0910_TS2_OUTSER_HZ 0xf11c5020 +#define FSTV0910_TS1_OUTSER_HZ 0xf11c4010 +#define FSTV0910_TS2_OUTPAR_HZ 0xf11c3008 +#define FSTV0910_TS1_OUTPAR_HZ 0xf11c2004 +#define FSTV0910_TS_SERDATA0 0xf11c1002 /* IRQSTATUS3 */ #define RSTV0910_IRQSTATUS3 0xf120 -#define FSTV0910_SPLL_LOCK 0xf1200020 -#define FSTV0910_SSTREAM_LCK_1 0xf1200010 -#define FSTV0910_SSTREAM_LCK_2 0xf1200008 -#define FSTV0910_SDVBS1_PRF_2 0xf1200002 +#define FSTV0910_SPLL_LOCK 0xf1205020 +#define FSTV0910_SSTREAM_LCK_1 0xf1204010 +#define FSTV0910_SSTREAM_LCK_2 0xf1203008 +#define FSTV0910_SDVBS1_PRF_2 0xf1201002 #define FSTV0910_SDVBS1_PRF_1 0xf1200001 /* IRQSTATUS2 */ #define RSTV0910_IRQSTATUS2 0xf121 -#define FSTV0910_SSPY_ENDSIM_1 0xf1210080 -#define FSTV0910_SSPY_ENDSIM_2 0xf1210040 -#define FSTV0910_SPKTDEL_ERROR_2 0xf1210010 -#define FSTV0910_SPKTDEL_LOCKB_2 0xf1210008 -#define FSTV0910_SPKTDEL_LOCK_2 0xf1210004 -#define FSTV0910_SPKTDEL_ERROR_1 0xf1210002 +#define FSTV0910_SSPY_ENDSIM_1 0xf1217080 +#define FSTV0910_SSPY_ENDSIM_2 0xf1216040 +#define FSTV0910_SPKTDEL_ERROR_2 0xf1214010 +#define FSTV0910_SPKTDEL_LOCKB_2 0xf1213008 +#define FSTV0910_SPKTDEL_LOCK_2 0xf1212004 +#define FSTV0910_SPKTDEL_ERROR_1 0xf1211002 #define FSTV0910_SPKTDEL_LOCKB_1 0xf1210001 /* IRQSTATUS1 */ #define RSTV0910_IRQSTATUS1 0xf122 -#define FSTV0910_SPKTDEL_LOCK_1 0xf1220080 -#define FSTV0910_SFEC_LOCKB_2 0xf1220040 -#define FSTV0910_SFEC_LOCK_2 0xf1220020 -#define FSTV0910_SFEC_LOCKB_1 0xf1220010 -#define FSTV0910_SFEC_LOCK_1 0xf1220008 -#define FSTV0910_SDEMOD_LOCKB_2 0xf1220004 -#define FSTV0910_SDEMOD_LOCK_2 0xf1220002 +#define FSTV0910_SPKTDEL_LOCK_1 0xf1227080 +#define FSTV0910_SFEC_LOCKB_2 0xf1226040 +#define FSTV0910_SFEC_LOCK_2 0xf1225020 +#define FSTV0910_SFEC_LOCKB_1 0xf1224010 +#define FSTV0910_SFEC_LOCK_1 0xf1223008 +#define FSTV0910_SDEMOD_LOCKB_2 0xf1222004 +#define FSTV0910_SDEMOD_LOCK_2 0xf1221002 #define FSTV0910_SDEMOD_IRQ_2 0xf1220001 /* IRQSTATUS0 */ #define RSTV0910_IRQSTATUS0 0xf123 -#define FSTV0910_SDEMOD_LOCKB_1 0xf1230080 -#define FSTV0910_SDEMOD_LOCK_1 0xf1230040 -#define FSTV0910_SDEMOD_IRQ_1 0xf1230020 -#define FSTV0910_SBCH_ERRFLAG 0xf1230010 -#define FSTV0910_SDISEQC2_IRQ 0xf1230004 +#define FSTV0910_SDEMOD_LOCKB_1 0xf1237080 +#define FSTV0910_SDEMOD_LOCK_1 0xf1236040 +#define FSTV0910_SDEMOD_IRQ_1 0xf1235020 +#define FSTV0910_SBCH_ERRFLAG 0xf1234010 +#define FSTV0910_SDISEQC2_IRQ 0xf1232004 #define FSTV0910_SDISEQC1_IRQ 0xf1230001 /* IRQMASK3 */ #define RSTV0910_IRQMASK3 0xf124 -#define FSTV0910_MPLL_LOCK 0xf1240020 -#define FSTV0910_MSTREAM_LCK_1 0xf1240010 -#define FSTV0910_MSTREAM_LCK_2 0xf1240008 -#define FSTV0910_MDVBS1_PRF_2 0xf1240002 +#define FSTV0910_MPLL_LOCK 0xf1245020 +#define FSTV0910_MSTREAM_LCK_1 0xf1244010 +#define FSTV0910_MSTREAM_LCK_2 0xf1243008 +#define FSTV0910_MDVBS1_PRF_2 0xf1241002 #define FSTV0910_MDVBS1_PRF_1 0xf1240001 /* IRQMASK2 */ #define RSTV0910_IRQMASK2 0xf125 -#define FSTV0910_MSPY_ENDSIM_1 0xf1250080 -#define FSTV0910_MSPY_ENDSIM_2 0xf1250040 -#define FSTV0910_MPKTDEL_ERROR_2 0xf1250010 -#define FSTV0910_MPKTDEL_LOCKB_2 0xf1250008 -#define FSTV0910_MPKTDEL_LOCK_2 0xf1250004 -#define FSTV0910_MPKTDEL_ERROR_1 0xf1250002 +#define FSTV0910_MSPY_ENDSIM_1 0xf1257080 +#define FSTV0910_MSPY_ENDSIM_2 0xf1256040 +#define FSTV0910_MPKTDEL_ERROR_2 0xf1254010 +#define FSTV0910_MPKTDEL_LOCKB_2 0xf1253008 +#define FSTV0910_MPKTDEL_LOCK_2 0xf1252004 +#define FSTV0910_MPKTDEL_ERROR_1 0xf1251002 #define FSTV0910_MPKTDEL_LOCKB_1 0xf1250001 /* IRQMASK1 */ #define RSTV0910_IRQMASK1 0xf126 -#define FSTV0910_MPKTDEL_LOCK_1 0xf1260080 -#define FSTV0910_MFEC_LOCKB_2 0xf1260040 -#define FSTV0910_MFEC_LOCK_2 0xf1260020 -#define FSTV0910_MFEC_LOCKB_1 0xf1260010 -#define FSTV0910_MFEC_LOCK_1 0xf1260008 -#define FSTV0910_MDEMOD_LOCKB_2 0xf1260004 -#define FSTV0910_MDEMOD_LOCK_2 0xf1260002 +#define FSTV0910_MPKTDEL_LOCK_1 0xf1267080 +#define FSTV0910_MFEC_LOCKB_2 0xf1266040 +#define FSTV0910_MFEC_LOCK_2 0xf1265020 +#define FSTV0910_MFEC_LOCKB_1 0xf1264010 +#define FSTV0910_MFEC_LOCK_1 0xf1263008 +#define FSTV0910_MDEMOD_LOCKB_2 0xf1262004 +#define FSTV0910_MDEMOD_LOCK_2 0xf1261002 #define FSTV0910_MDEMOD_IRQ_2 0xf1260001 /* IRQMASK0 */ #define RSTV0910_IRQMASK0 0xf127 -#define FSTV0910_MDEMOD_LOCKB_1 0xf1270080 -#define FSTV0910_MDEMOD_LOCK_1 0xf1270040 -#define FSTV0910_MDEMOD_IRQ_1 0xf1270020 -#define FSTV0910_MBCH_ERRFLAG 0xf1270010 -#define FSTV0910_MDISEQC2_IRQ 0xf1270004 +#define FSTV0910_MDEMOD_LOCKB_1 0xf1277080 +#define FSTV0910_MDEMOD_LOCK_1 0xf1276040 +#define FSTV0910_MDEMOD_IRQ_1 0xf1275020 +#define FSTV0910_MBCH_ERRFLAG 0xf1274010 +#define FSTV0910_MDISEQC2_IRQ 0xf1272004 #define FSTV0910_MDISEQC1_IRQ 0xf1270001 /* I2CCFG */ #define RSTV0910_I2CCFG 0xf129 -#define FSTV0910_I2C_FASTMODE 0xf1290008 +#define FSTV0910_I2C_FASTMODE 0xf1293008 #define FSTV0910_I2CADDR_INC 0xf1290003 /* P1_I2CRPT */ #define RSTV0910_P1_I2CRPT 0xf12a -#define FSTV0910_P1_I2CT_ON 0xf12a0080 -#define FSTV0910_P1_ENARPT_LEVEL 0xf12a0070 -#define FSTV0910_P1_SCLT_DELAY 0xf12a0008 -#define FSTV0910_P1_STOP_ENABLE 0xf12a0004 -#define FSTV0910_P1_STOP_SDAT2SDA 0xf12a0002 +#define FSTV0910_P1_I2CT_ON 0xf12a7080 +#define FSTV0910_P1_ENARPT_LEVEL 0xf12a4070 +#define FSTV0910_P1_SCLT_DELAY 0xf12a3008 +#define FSTV0910_P1_STOP_ENABLE 0xf12a2004 +#define FSTV0910_P1_STOP_SDAT2SDA 0xf12a1002 /* P2_I2CRPT */ #define RSTV0910_P2_I2CRPT 0xf12b -#define FSTV0910_P2_I2CT_ON 0xf12b0080 -#define FSTV0910_P2_ENARPT_LEVEL 0xf12b0070 -#define FSTV0910_P2_SCLT_DELAY 0xf12b0008 -#define FSTV0910_P2_STOP_ENABLE 0xf12b0004 -#define FSTV0910_P2_STOP_SDAT2SDA 0xf12b0002 +#define FSTV0910_P2_I2CT_ON 0xf12b7080 +#define FSTV0910_P2_ENARPT_LEVEL 0xf12b4070 +#define FSTV0910_P2_SCLT_DELAY 0xf12b3008 +#define FSTV0910_P2_STOP_ENABLE 0xf12b2004 +#define FSTV0910_P2_STOP_SDAT2SDA 0xf12b1002 /* GPIO0CFG */ #define RSTV0910_GPIO0CFG 0xf140 -#define FSTV0910_GPIO0_OPD 0xf1400080 -#define FSTV0910_GPIO0_CONFIG 0xf140007e +#define FSTV0910_GPIO0_OPD 0xf1407080 +#define FSTV0910_GPIO0_CONFIG 0xf140107e #define FSTV0910_GPIO0_XOR 0xf1400001 /* GPIO1CFG */ #define RSTV0910_GPIO1CFG 0xf141 -#define FSTV0910_GPIO1_OPD 0xf1410080 -#define FSTV0910_GPIO1_CONFIG 0xf141007e +#define FSTV0910_GPIO1_OPD 0xf1417080 +#define FSTV0910_GPIO1_CONFIG 0xf141107e #define FSTV0910_GPIO1_XOR 0xf1410001 /* GPIO2CFG */ #define RSTV0910_GPIO2CFG 0xf142 -#define FSTV0910_GPIO2_OPD 0xf1420080 -#define FSTV0910_GPIO2_CONFIG 0xf142007e +#define FSTV0910_GPIO2_OPD 0xf1427080 +#define FSTV0910_GPIO2_CONFIG 0xf142107e #define FSTV0910_GPIO2_XOR 0xf1420001 /* GPIO3CFG */ #define RSTV0910_GPIO3CFG 0xf143 -#define FSTV0910_GPIO3_OPD 0xf1430080 -#define FSTV0910_GPIO3_CONFIG 0xf143007e +#define FSTV0910_GPIO3_OPD 0xf1437080 +#define FSTV0910_GPIO3_CONFIG 0xf143107e #define FSTV0910_GPIO3_XOR 0xf1430001 /* GPIO4CFG */ #define RSTV0910_GPIO4CFG 0xf144 -#define FSTV0910_GPIO4_OPD 0xf1440080 -#define FSTV0910_GPIO4_CONFIG 0xf144007e +#define FSTV0910_GPIO4_OPD 0xf1447080 +#define FSTV0910_GPIO4_CONFIG 0xf144107e #define FSTV0910_GPIO4_XOR 0xf1440001 /* GPIO5CFG */ #define RSTV0910_GPIO5CFG 0xf145 -#define FSTV0910_GPIO5_OPD 0xf1450080 -#define FSTV0910_GPIO5_CONFIG 0xf145007e +#define FSTV0910_GPIO5_OPD 0xf1457080 +#define FSTV0910_GPIO5_CONFIG 0xf145107e #define FSTV0910_GPIO5_XOR 0xf1450001 /* GPIO6CFG */ #define RSTV0910_GPIO6CFG 0xf146 -#define FSTV0910_GPIO6_OPD 0xf1460080 -#define FSTV0910_GPIO6_CONFIG 0xf146007e +#define FSTV0910_GPIO6_OPD 0xf1467080 +#define FSTV0910_GPIO6_CONFIG 0xf146107e #define FSTV0910_GPIO6_XOR 0xf1460001 /* GPIO7CFG */ #define RSTV0910_GPIO7CFG 0xf147 -#define FSTV0910_GPIO7_OPD 0xf1470080 -#define FSTV0910_GPIO7_CONFIG 0xf147007e +#define FSTV0910_GPIO7_OPD 0xf1477080 +#define FSTV0910_GPIO7_CONFIG 0xf147107e #define FSTV0910_GPIO7_XOR 0xf1470001 /* GPIO8CFG */ #define RSTV0910_GPIO8CFG 0xf148 -#define FSTV0910_GPIO8_OPD 0xf1480080 -#define FSTV0910_GPIO8_CONFIG 0xf148007e +#define FSTV0910_GPIO8_OPD 0xf1487080 +#define FSTV0910_GPIO8_CONFIG 0xf148107e #define FSTV0910_GPIO8_XOR 0xf1480001 /* GPIO9CFG */ #define RSTV0910_GPIO9CFG 0xf149 -#define FSTV0910_GPIO9_OPD 0xf1490080 -#define FSTV0910_GPIO9_CONFIG 0xf149007e +#define FSTV0910_GPIO9_OPD 0xf1497080 +#define FSTV0910_GPIO9_CONFIG 0xf149107e #define FSTV0910_GPIO9_XOR 0xf1490001 /* GPIO10CFG */ #define RSTV0910_GPIO10CFG 0xf14a -#define FSTV0910_GPIO10_OPD 0xf14a0080 -#define FSTV0910_GPIO10_CONFIG 0xf14a007e +#define FSTV0910_GPIO10_OPD 0xf14a7080 +#define FSTV0910_GPIO10_CONFIG 0xf14a107e #define FSTV0910_GPIO10_XOR 0xf14a0001 /* GPIO11CFG */ #define RSTV0910_GPIO11CFG 0xf14b -#define FSTV0910_GPIO11_OPD 0xf14b0080 -#define FSTV0910_GPIO11_CONFIG 0xf14b007e +#define FSTV0910_GPIO11_OPD 0xf14b7080 +#define FSTV0910_GPIO11_CONFIG 0xf14b107e #define FSTV0910_GPIO11_XOR 0xf14b0001 /* GPIO12CFG */ #define RSTV0910_GPIO12CFG 0xf14c -#define FSTV0910_GPIO12_OPD 0xf14c0080 -#define FSTV0910_GPIO12_CONFIG 0xf14c007e +#define FSTV0910_GPIO12_OPD 0xf14c7080 +#define FSTV0910_GPIO12_CONFIG 0xf14c107e #define FSTV0910_GPIO12_XOR 0xf14c0001 /* GPIO13CFG */ #define RSTV0910_GPIO13CFG 0xf14d -#define FSTV0910_GPIO13_OPD 0xf14d0080 -#define FSTV0910_GPIO13_CONFIG 0xf14d007e +#define FSTV0910_GPIO13_OPD 0xf14d7080 +#define FSTV0910_GPIO13_CONFIG 0xf14d107e #define FSTV0910_GPIO13_XOR 0xf14d0001 /* GPIO14CFG */ #define RSTV0910_GPIO14CFG 0xf14e -#define FSTV0910_GPIO14_OPD 0xf14e0080 -#define FSTV0910_GPIO14_CONFIG 0xf14e007e +#define FSTV0910_GPIO14_OPD 0xf14e7080 +#define FSTV0910_GPIO14_CONFIG 0xf14e107e #define FSTV0910_GPIO14_XOR 0xf14e0001 /* GPIO15CFG */ #define RSTV0910_GPIO15CFG 0xf14f -#define FSTV0910_GPIO15_OPD 0xf14f0080 -#define FSTV0910_GPIO15_CONFIG 0xf14f007e +#define FSTV0910_GPIO15_OPD 0xf14f7080 +#define FSTV0910_GPIO15_CONFIG 0xf14f107e #define FSTV0910_GPIO15_XOR 0xf14f0001 /* GPIO16CFG */ #define RSTV0910_GPIO16CFG 0xf150 -#define FSTV0910_GPIO16_OPD 0xf1500080 -#define FSTV0910_GPIO16_CONFIG 0xf150007e +#define FSTV0910_GPIO16_OPD 0xf1507080 +#define FSTV0910_GPIO16_CONFIG 0xf150107e #define FSTV0910_GPIO16_XOR 0xf1500001 /* GPIO17CFG */ #define RSTV0910_GPIO17CFG 0xf151 -#define FSTV0910_GPIO17_OPD 0xf1510080 -#define FSTV0910_GPIO17_CONFIG 0xf151007e +#define FSTV0910_GPIO17_OPD 0xf1517080 +#define FSTV0910_GPIO17_CONFIG 0xf151107e #define FSTV0910_GPIO17_XOR 0xf1510001 /* GPIO18CFG */ #define RSTV0910_GPIO18CFG 0xf152 -#define FSTV0910_GPIO18_OPD 0xf1520080 -#define FSTV0910_GPIO18_CONFIG 0xf152007e +#define FSTV0910_GPIO18_OPD 0xf1527080 +#define FSTV0910_GPIO18_CONFIG 0xf152107e #define FSTV0910_GPIO18_XOR 0xf1520001 /* GPIO19CFG */ #define RSTV0910_GPIO19CFG 0xf153 -#define FSTV0910_GPIO19_OPD 0xf1530080 -#define FSTV0910_GPIO19_CONFIG 0xf153007e +#define FSTV0910_GPIO19_OPD 0xf1537080 +#define FSTV0910_GPIO19_CONFIG 0xf153107e #define FSTV0910_GPIO19_XOR 0xf1530001 /* GPIO20CFG */ #define RSTV0910_GPIO20CFG 0xf154 -#define FSTV0910_GPIO20_OPD 0xf1540080 -#define FSTV0910_GPIO20_CONFIG 0xf154007e +#define FSTV0910_GPIO20_OPD 0xf1547080 +#define FSTV0910_GPIO20_CONFIG 0xf154107e #define FSTV0910_GPIO20_XOR 0xf1540001 /* GPIO21CFG */ #define RSTV0910_GPIO21CFG 0xf155 -#define FSTV0910_GPIO21_OPD 0xf1550080 -#define FSTV0910_GPIO21_CONFIG 0xf155007e +#define FSTV0910_GPIO21_OPD 0xf1557080 +#define FSTV0910_GPIO21_CONFIG 0xf155107e #define FSTV0910_GPIO21_XOR 0xf1550001 /* GPIO22CFG */ #define RSTV0910_GPIO22CFG 0xf156 -#define FSTV0910_GPIO22_OPD 0xf1560080 -#define FSTV0910_GPIO22_CONFIG 0xf156007e +#define FSTV0910_GPIO22_OPD 0xf1567080 +#define FSTV0910_GPIO22_CONFIG 0xf156107e #define FSTV0910_GPIO22_XOR 0xf1560001 /* STRSTATUS1 */ #define RSTV0910_STRSTATUS1 0xf16a -#define FSTV0910_STRSTATUS_SEL2 0xf16a00f0 +#define FSTV0910_STRSTATUS_SEL2 0xf16a40f0 #define FSTV0910_STRSTATUS_SEL1 0xf16a000f /* STRSTATUS2 */ #define RSTV0910_STRSTATUS2 0xf16b -#define FSTV0910_STRSTATUS_SEL4 0xf16b00f0 +#define FSTV0910_STRSTATUS_SEL4 0xf16b40f0 #define FSTV0910_STRSTATUS_SEL3 0xf16b000f /* STRSTATUS3 */ #define RSTV0910_STRSTATUS3 0xf16c -#define FSTV0910_STRSTATUS_SEL6 0xf16c00f0 +#define FSTV0910_STRSTATUS_SEL6 0xf16c40f0 #define FSTV0910_STRSTATUS_SEL5 0xf16c000f /* FSKTFC2 */ #define RSTV0910_FSKTFC2 0xf170 -#define FSTV0910_FSKT_KMOD 0xf17000fc +#define FSTV0910_FSKT_KMOD 0xf17020fc #define FSTV0910_FSKT_CAR2 0xf1700003 /* FSKTFC1 */ @@ -330,17 +330,17 @@ /* FSKTCTRL */ #define RSTV0910_FSKTCTRL 0xf175 -#define FSTV0910_FSKT_PINSEL 0xf1750080 -#define FSTV0910_FSKT_EN_SGN 0xf1750040 -#define FSTV0910_FSKT_MOD_SGN 0xf1750020 -#define FSTV0910_FSKT_MOD_EN 0xf175001c +#define FSTV0910_FSKT_PINSEL 0xf1757080 +#define FSTV0910_FSKT_EN_SGN 0xf1756040 +#define FSTV0910_FSKT_MOD_SGN 0xf1755020 +#define FSTV0910_FSKT_MOD_EN 0xf175201c #define FSTV0910_FSKT_DACMODE 0xf1750003 /* FSKRFC2 */ #define RSTV0910_FSKRFC2 0xf176 -#define FSTV0910_FSKR_DETSGN 0xf1760040 -#define FSTV0910_FSKR_OUTSGN 0xf1760020 -#define FSTV0910_FSKR_KAGC 0xf176001c +#define FSTV0910_FSKR_DETSGN 0xf1766040 +#define FSTV0910_FSKR_OUTSGN 0xf1765020 +#define FSTV0910_FSKR_KAGC 0xf176201c #define FSTV0910_FSKR_CAR2 0xf1760003 /* FSKRFC1 */ @@ -353,17 +353,17 @@ /* FSKRK1 */ #define RSTV0910_FSKRK1 0xf179 -#define FSTV0910_FSKR_K1_EXP 0xf17900e0 +#define FSTV0910_FSKR_K1_EXP 0xf17950e0 #define FSTV0910_FSKR_K1_MANT 0xf179001f /* FSKRK2 */ #define RSTV0910_FSKRK2 0xf17a -#define FSTV0910_FSKR_K2_EXP 0xf17a00e0 +#define FSTV0910_FSKR_K2_EXP 0xf17a50e0 #define FSTV0910_FSKR_K2_MANT 0xf17a001f /* FSKRAGCR */ #define RSTV0910_FSKRAGCR 0xf17b -#define FSTV0910_FSKR_OUTCTL 0xf17b00c0 +#define FSTV0910_FSKR_OUTCTL 0xf17b60c0 #define FSTV0910_FSKR_AGC_REF 0xf17b003f /* FSKRAGC */ @@ -372,12 +372,12 @@ /* FSKRALPHA */ #define RSTV0910_FSKRALPHA 0xf17d -#define FSTV0910_FSKR_ALPHA_EXP 0xf17d001c +#define FSTV0910_FSKR_ALPHA_EXP 0xf17d201c #define FSTV0910_FSKR_ALPHA_M 0xf17d0003 /* FSKRPLTH1 */ #define RSTV0910_FSKRPLTH1 0xf17e -#define FSTV0910_FSKR_BETA 0xf17e00f0 +#define FSTV0910_FSKR_BETA 0xf17e40f0 #define FSTV0910_FSKR_PLL_TRESH1 0xf17e000f /* FSKRPLTH0 */ @@ -386,8 +386,8 @@ /* FSKRDF1 */ #define RSTV0910_FSKRDF1 0xf180 -#define FSTV0910_FSKR_OUT 0xf1800080 -#define FSTV0910_FSKR_STATE 0xf1800060 +#define FSTV0910_FSKR_OUT 0xf1807080 +#define FSTV0910_FSKR_STATE 0xf1805060 #define FSTV0910_FSKR_DELTAF1 0xf180001f /* FSKRDF0 */ @@ -404,7 +404,7 @@ /* FSKRDET1 */ #define RSTV0910_FSKRDET1 0xf184 -#define FSTV0910_FSKR_DETECT 0xf1840080 +#define FSTV0910_FSKR_DETECT 0xf1847080 #define FSTV0910_FSKR_CARDET_ACCU1 0xf184000f /* FSKRDET0 */ @@ -413,7 +413,7 @@ /* FSKRDTH1 */ #define RSTV0910_FSKRDTH1 0xf186 -#define FSTV0910_FSKR_CARLOSS_THRESH1 0xf18600f0 +#define FSTV0910_FSKR_CARLOSS_THRESH1 0xf18640f0 #define FSTV0910_FSKR_CARDET_THRESH1 0xf186000f /* FSKRDTH0 */ @@ -426,7 +426,7 @@ /* NCOARSE */ #define RSTV0910_NCOARSE 0xf1b3 -#define FSTV0910_CP 0xf1b300f8 +#define FSTV0910_CP 0xf1b330f8 #define FSTV0910_IDF 0xf1b30007 /* NCOARSE1 */ @@ -439,14 +439,14 @@ /* SYNTCTRL */ #define RSTV0910_SYNTCTRL 0xf1b6 -#define FSTV0910_STANDBY 0xf1b60080 -#define FSTV0910_BYPASSPLLCORE 0xf1b60040 -#define FSTV0910_STOP_PLL 0xf1b60008 -#define FSTV0910_OSCI_E 0xf1b60002 +#define FSTV0910_STANDBY 0xf1b67080 +#define FSTV0910_BYPASSPLLCORE 0xf1b66040 +#define FSTV0910_STOP_PLL 0xf1b63008 +#define FSTV0910_OSCI_E 0xf1b61002 /* FILTCTRL */ #define RSTV0910_FILTCTRL 0xf1b7 -#define FSTV0910_INV_CLKFSK 0xf1b70002 +#define FSTV0910_INV_CLKFSK 0xf1b71002 #define FSTV0910_BYPASS_APPLI 0xf1b70001 /* PLLSTAT */ @@ -455,48 +455,48 @@ /* STOPCLK1 */ #define RSTV0910_STOPCLK1 0xf1c2 -#define FSTV0910_INV_CLKADCI2 0xf1c20004 +#define FSTV0910_INV_CLKADCI2 0xf1c22004 #define FSTV0910_INV_CLKADCI1 0xf1c20001 /* STOPCLK2 */ #define RSTV0910_STOPCLK2 0xf1c3 -#define FSTV0910_STOP_DVBS2FEC2 0xf1c30020 -#define FSTV0910_STOP_DVBS2FEC 0xf1c30010 -#define FSTV0910_STOP_DVBS1FEC2 0xf1c30008 -#define FSTV0910_STOP_DVBS1FEC 0xf1c30004 -#define FSTV0910_STOP_DEMOD2 0xf1c30002 +#define FSTV0910_STOP_DVBS2FEC2 0xf1c35020 +#define FSTV0910_STOP_DVBS2FEC 0xf1c34010 +#define FSTV0910_STOP_DVBS1FEC2 0xf1c33008 +#define FSTV0910_STOP_DVBS1FEC 0xf1c32004 +#define FSTV0910_STOP_DEMOD2 0xf1c31002 #define FSTV0910_STOP_DEMOD 0xf1c30001 /* PREGCTL */ #define RSTV0910_PREGCTL 0xf1c8 -#define FSTV0910_REG3V3TO2V5_POFF 0xf1c80080 +#define FSTV0910_REG3V3TO2V5_POFF 0xf1c87080 /* TSTTNR0 */ #define RSTV0910_TSTTNR0 0xf1df -#define FSTV0910_FSK_PON 0xf1df0004 +#define FSTV0910_FSK_PON 0xf1df2004 /* TSTTNR1 */ #define RSTV0910_TSTTNR1 0xf1e0 -#define FSTV0910_ADC1_PON 0xf1e00002 +#define FSTV0910_ADC1_PON 0xf1e01002 /* TSTTNR2 */ #define RSTV0910_TSTTNR2 0xf1e1 -#define FSTV0910_I2C_DISEQC_PON 0xf1e10020 +#define FSTV0910_I2C_DISEQC_PON 0xf1e15020 #define FSTV0910_DISEQC_CLKDIV 0xf1e1000f /* TSTTNR3 */ #define RSTV0910_TSTTNR3 0xf1e2 -#define FSTV0910_ADC2_PON 0xf1e20002 +#define FSTV0910_ADC2_PON 0xf1e21002 /* P2_IQCONST */ #define RSTV0910_P2_IQCONST 0xf200 -#define FSTV0910_P2_CONSTEL_SELECT 0xf2000060 +#define FSTV0910_P2_CONSTEL_SELECT 0xf2005060 #define FSTV0910_P2_IQSYMB_SEL 0xf200001f /* P2_NOSCFG */ #define RSTV0910_P2_NOSCFG 0xf201 -#define FSTV0910_P2_DUMMYPL_NOSDATA 0xf2010020 -#define FSTV0910_P2_NOSPLH_BETA 0xf2010018 +#define FSTV0910_P2_DUMMYPL_NOSDATA 0xf2015020 +#define FSTV0910_P2_NOSPLH_BETA 0xf2013018 #define FSTV0910_P2_NOSDATA_BETA 0xf2010007 /* P2_ISYMB */ @@ -509,18 +509,18 @@ /* P2_AGC1CFG */ #define RSTV0910_P2_AGC1CFG 0xf204 -#define FSTV0910_P2_DC_FROZEN 0xf2040080 -#define FSTV0910_P2_DC_CORRECT 0xf2040040 -#define FSTV0910_P2_AMM_FROZEN 0xf2040020 -#define FSTV0910_P2_AMM_CORRECT 0xf2040010 -#define FSTV0910_P2_QUAD_FROZEN 0xf2040008 -#define FSTV0910_P2_QUAD_CORRECT 0xf2040004 +#define FSTV0910_P2_DC_FROZEN 0xf2047080 +#define FSTV0910_P2_DC_CORRECT 0xf2046040 +#define FSTV0910_P2_AMM_FROZEN 0xf2045020 +#define FSTV0910_P2_AMM_CORRECT 0xf2044010 +#define FSTV0910_P2_QUAD_FROZEN 0xf2043008 +#define FSTV0910_P2_QUAD_CORRECT 0xf2042004 /* P2_AGC1CN */ #define RSTV0910_P2_AGC1CN 0xf206 -#define FSTV0910_P2_AGC1_LOCKED 0xf2060080 -#define FSTV0910_P2_AGC1_MINPOWER 0xf2060010 -#define FSTV0910_P2_AGCOUT_FAST 0xf2060008 +#define FSTV0910_P2_AGC1_LOCKED 0xf2067080 +#define FSTV0910_P2_AGC1_MINPOWER 0xf2064010 +#define FSTV0910_P2_AGCOUT_FAST 0xf2063008 #define FSTV0910_P2_AGCIQ_BETA 0xf2060007 /* P2_AGC1REF */ @@ -561,50 +561,50 @@ /* P2_DEMOD */ #define RSTV0910_P2_DEMOD 0xf210 -#define FSTV0910_P2_MANUALS2_ROLLOFF 0xf2100080 -#define FSTV0910_P2_SPECINV_CONTROL 0xf2100030 -#define FSTV0910_P2_MANUALSX_ROLLOFF 0xf2100004 +#define FSTV0910_P2_MANUALS2_ROLLOFF 0xf2107080 +#define FSTV0910_P2_SPECINV_CONTROL 0xf2104030 +#define FSTV0910_P2_MANUALSX_ROLLOFF 0xf2102004 #define FSTV0910_P2_ROLLOFF_CONTROL 0xf2100003 /* P2_DMDMODCOD */ #define RSTV0910_P2_DMDMODCOD 0xf211 -#define FSTV0910_P2_MANUAL_MODCOD 0xf2110080 -#define FSTV0910_P2_DEMOD_MODCOD 0xf211007c +#define FSTV0910_P2_MANUAL_MODCOD 0xf2117080 +#define FSTV0910_P2_DEMOD_MODCOD 0xf211207c #define FSTV0910_P2_DEMOD_TYPE 0xf2110003 /* P2_DSTATUS */ #define RSTV0910_P2_DSTATUS 0xf212 -#define FSTV0910_P2_CAR_LOCK 0xf2120080 -#define FSTV0910_P2_TMGLOCK_QUALITY 0xf2120060 -#define FSTV0910_P2_LOCK_DEFINITIF 0xf2120008 +#define FSTV0910_P2_CAR_LOCK 0xf2127080 +#define FSTV0910_P2_TMGLOCK_QUALITY 0xf2125060 +#define FSTV0910_P2_LOCK_DEFINITIF 0xf2123008 #define FSTV0910_P2_OVADC_DETECT 0xf2120001 /* P2_DSTATUS2 */ #define RSTV0910_P2_DSTATUS2 0xf213 -#define FSTV0910_P2_DEMOD_DELOCK 0xf2130080 -#define FSTV0910_P2_MODCODRQ_SYNCTAG 0xf2130020 -#define FSTV0910_P2_POLYPH_SATEVENT 0xf2130010 -#define FSTV0910_P2_AGC1_NOSIGNALACK 0xf2130008 -#define FSTV0910_P2_AGC2_OVERFLOW 0xf2130004 -#define FSTV0910_P2_CFR_OVERFLOW 0xf2130002 +#define FSTV0910_P2_DEMOD_DELOCK 0xf2137080 +#define FSTV0910_P2_MODCODRQ_SYNCTAG 0xf2135020 +#define FSTV0910_P2_POLYPH_SATEVENT 0xf2134010 +#define FSTV0910_P2_AGC1_NOSIGNALACK 0xf2133008 +#define FSTV0910_P2_AGC2_OVERFLOW 0xf2132004 +#define FSTV0910_P2_CFR_OVERFLOW 0xf2131002 #define FSTV0910_P2_GAMMA_OVERUNDER 0xf2130001 /* P2_DMDCFGMD */ #define RSTV0910_P2_DMDCFGMD 0xf214 -#define FSTV0910_P2_DVBS2_ENABLE 0xf2140080 -#define FSTV0910_P2_DVBS1_ENABLE 0xf2140040 -#define FSTV0910_P2_SCAN_ENABLE 0xf2140010 -#define FSTV0910_P2_CFR_AUTOSCAN 0xf2140008 +#define FSTV0910_P2_DVBS2_ENABLE 0xf2147080 +#define FSTV0910_P2_DVBS1_ENABLE 0xf2146040 +#define FSTV0910_P2_SCAN_ENABLE 0xf2144010 +#define FSTV0910_P2_CFR_AUTOSCAN 0xf2143008 #define FSTV0910_P2_TUN_RNG 0xf2140003 /* P2_DMDCFG2 */ #define RSTV0910_P2_DMDCFG2 0xf215 -#define FSTV0910_P2_S1S2_SEQUENTIAL 0xf2150040 -#define FSTV0910_P2_INFINITE_RELOCK 0xf2150010 +#define FSTV0910_P2_S1S2_SEQUENTIAL 0xf2156040 +#define FSTV0910_P2_INFINITE_RELOCK 0xf2154010 /* P2_DMDISTATE */ #define RSTV0910_P2_DMDISTATE 0xf216 -#define FSTV0910_P2_I2C_NORESETDMODE 0xf2160080 +#define FSTV0910_P2_I2C_NORESETDMODE 0xf2167080 #define FSTV0910_P2_I2C_DEMOD_MODE 0xf216001f /* P2_DMDT0M */ @@ -613,27 +613,27 @@ /* P2_DMDSTATE */ #define RSTV0910_P2_DMDSTATE 0xf21b -#define FSTV0910_P2_HEADER_MODE 0xf21b0060 +#define FSTV0910_P2_HEADER_MODE 0xf21b5060 /* P2_DMDFLYW */ #define RSTV0910_P2_DMDFLYW 0xf21c -#define FSTV0910_P2_I2C_IRQVAL 0xf21c00f0 +#define FSTV0910_P2_I2C_IRQVAL 0xf21c40f0 #define FSTV0910_P2_FLYWHEEL_CPT 0xf21c000f /* P2_DSTATUS3 */ #define RSTV0910_P2_DSTATUS3 0xf21d -#define FSTV0910_P2_CFR_ZIGZAG 0xf21d0080 -#define FSTV0910_P2_DEMOD_CFGMODE 0xf21d0060 -#define FSTV0910_P2_GAMMA_LOWBAUDRATE 0xf21d0010 +#define FSTV0910_P2_CFR_ZIGZAG 0xf21d7080 +#define FSTV0910_P2_DEMOD_CFGMODE 0xf21d5060 +#define FSTV0910_P2_GAMMA_LOWBAUDRATE 0xf21d4010 /* P2_DMDCFG3 */ #define RSTV0910_P2_DMDCFG3 0xf21e -#define FSTV0910_P2_NOSTOP_FIFOFULL 0xf21e0008 +#define FSTV0910_P2_NOSTOP_FIFOFULL 0xf21e3008 /* P2_DMDCFG4 */ #define RSTV0910_P2_DMDCFG4 0xf21f -#define FSTV0910_P2_DIS_VITLOCK 0xf21f0080 -#define FSTV0910_P2_DIS_CLKENABLE 0xf21f0004 +#define FSTV0910_P2_DIS_VITLOCK 0xf21f7080 +#define FSTV0910_P2_DIS_CLKENABLE 0xf21f2004 /* P2_CORRELMANT */ #define RSTV0910_P2_CORRELMANT 0xf220 @@ -645,13 +645,13 @@ /* P2_CORRELEXP */ #define RSTV0910_P2_CORRELEXP 0xf222 -#define FSTV0910_P2_CORREL_ABSEXP 0xf22200f0 +#define FSTV0910_P2_CORREL_ABSEXP 0xf22240f0 #define FSTV0910_P2_CORREL_EXP 0xf222000f /* P2_PLHMODCOD */ #define RSTV0910_P2_PLHMODCOD 0xf224 -#define FSTV0910_P2_SPECINV_DEMOD 0xf2240080 -#define FSTV0910_P2_PLH_MODCOD 0xf224007c +#define FSTV0910_P2_SPECINV_DEMOD 0xf2247080 +#define FSTV0910_P2_PLH_MODCOD 0xf224207c #define FSTV0910_P2_PLH_TYPE 0xf2240003 /* P2_DMDREG */ @@ -660,19 +660,19 @@ /* P2_AGCNADJ */ #define RSTV0910_P2_AGCNADJ 0xf226 -#define FSTV0910_P2_RADJOFF_AGC2 0xf2260080 -#define FSTV0910_P2_RADJOFF_AGC1 0xf2260040 +#define FSTV0910_P2_RADJOFF_AGC2 0xf2267080 +#define FSTV0910_P2_RADJOFF_AGC1 0xf2266040 #define FSTV0910_P2_AGC_NADJ 0xf226013f /* P2_AGCKS */ #define RSTV0910_P2_AGCKS 0xf227 -#define FSTV0910_P2_RSADJ_MANUALCFG 0xf2270080 -#define FSTV0910_P2_RSADJ_CCMMODE 0xf2270040 +#define FSTV0910_P2_RSADJ_MANUALCFG 0xf2277080 +#define FSTV0910_P2_RSADJ_CCMMODE 0xf2276040 #define FSTV0910_P2_RADJ_SPSK 0xf227013f /* P2_AGCKQ */ #define RSTV0910_P2_AGCKQ 0xf228 -#define FSTV0910_P2_RADJON_DVBS1 0xf2280040 +#define FSTV0910_P2_RADJON_DVBS1 0xf2286040 #define FSTV0910_P2_RADJ_QPSK 0xf228013f /* P2_AGCK8 */ @@ -681,20 +681,20 @@ /* P2_AGCK16 */ #define RSTV0910_P2_AGCK16 0xf22a -#define FSTV0910_P2_R2ADJOFF_16APSK 0xf22a0040 -#define FSTV0910_P2_R1ADJOFF_16APSK 0xf22a0020 +#define FSTV0910_P2_R2ADJOFF_16APSK 0xf22a6040 +#define FSTV0910_P2_R1ADJOFF_16APSK 0xf22a5020 #define FSTV0910_P2_RADJ_16APSK 0xf22a011f /* P2_AGCK32 */ #define RSTV0910_P2_AGCK32 0xf22b -#define FSTV0910_P2_R3ADJOFF_32APSK 0xf22b0080 -#define FSTV0910_P2_R2ADJOFF_32APSK 0xf22b0040 -#define FSTV0910_P2_R1ADJOFF_32APSK 0xf22b0020 +#define FSTV0910_P2_R3ADJOFF_32APSK 0xf22b7080 +#define FSTV0910_P2_R2ADJOFF_32APSK 0xf22b6040 +#define FSTV0910_P2_R1ADJOFF_32APSK 0xf22b5020 #define FSTV0910_P2_RADJ_32APSK 0xf22b011f /* P2_AGC2O */ #define RSTV0910_P2_AGC2O 0xf22c -#define FSTV0910_P2_CSTENV_MODE 0xf22c00c0 +#define FSTV0910_P2_CSTENV_MODE 0xf22c60c0 #define FSTV0910_P2_AGC2_COEF 0xf22c0007 /* P2_AGC2REF */ @@ -743,32 +743,32 @@ /* P2_CARCFG */ #define RSTV0910_P2_CARCFG 0xf238 -#define FSTV0910_P2_ROTAON 0xf2380004 +#define FSTV0910_P2_ROTAON 0xf2382004 #define FSTV0910_P2_PH_DET_ALGO 0xf2380003 /* P2_ACLC */ #define RSTV0910_P2_ACLC 0xf239 -#define FSTV0910_P2_CAR_ALPHA_MANT 0xf2390030 +#define FSTV0910_P2_CAR_ALPHA_MANT 0xf2394030 #define FSTV0910_P2_CAR_ALPHA_EXP 0xf239000f /* P2_BCLC */ #define RSTV0910_P2_BCLC 0xf23a -#define FSTV0910_P2_CAR_BETA_MANT 0xf23a0030 +#define FSTV0910_P2_CAR_BETA_MANT 0xf23a4030 #define FSTV0910_P2_CAR_BETA_EXP 0xf23a000f /* P2_ACLCS2 */ #define RSTV0910_P2_ACLCS2 0xf23b -#define FSTV0910_P2_CARS2_APLHA_MANTISSE 0xf23b0030 +#define FSTV0910_P2_CARS2_APLHA_MANTISSE 0xf23b4030 #define FSTV0910_P2_CARS2_ALPHA_EXP 0xf23b000f /* P2_BCLCS2 */ #define RSTV0910_P2_BCLCS2 0xf23c -#define FSTV0910_P2_CARS2_BETA_MANTISSE 0xf23c0030 +#define FSTV0910_P2_CARS2_BETA_MANTISSE 0xf23c4030 #define FSTV0910_P2_CARS2_BETA_EXP 0xf23c000f /* P2_CARFREQ */ #define RSTV0910_P2_CARFREQ 0xf23d -#define FSTV0910_P2_KC_COARSE_EXP 0xf23d00f0 +#define FSTV0910_P2_KC_COARSE_EXP 0xf23d40f0 #define FSTV0910_P2_BETA_FREQ 0xf23d000f /* P2_CARHDR */ @@ -821,7 +821,7 @@ /* P2_CFRINC1 */ #define RSTV0910_P2_CFRINC1 0xf24a -#define FSTV0910_P2_MANUAL_CFRINC 0xf24a0080 +#define FSTV0910_P2_MANUAL_CFRINC 0xf24a7080 #define FSTV0910_P2_CFR_INC1 0xf24a003f /* P2_CFRINC0 */ @@ -846,18 +846,18 @@ /* P2_TMGCFG */ #define RSTV0910_P2_TMGCFG 0xf250 -#define FSTV0910_P2_TMGLOCK_BETA 0xf25000c0 -#define FSTV0910_P2_DO_TIMING_CORR 0xf2500010 +#define FSTV0910_P2_TMGLOCK_BETA 0xf25060c0 +#define FSTV0910_P2_DO_TIMING_CORR 0xf2504010 #define FSTV0910_P2_TMG_MINFREQ 0xf2500003 /* P2_RTC */ #define RSTV0910_P2_RTC 0xf251 -#define FSTV0910_P2_TMGALPHA_EXP 0xf25100f0 +#define FSTV0910_P2_TMGALPHA_EXP 0xf25140f0 #define FSTV0910_P2_TMGBETA_EXP 0xf251000f /* P2_RTCS2 */ #define RSTV0910_P2_RTCS2 0xf252 -#define FSTV0910_P2_TMGALPHAS2_EXP 0xf25200f0 +#define FSTV0910_P2_TMGALPHAS2_EXP 0xf25240f0 #define FSTV0910_P2_TMGBETAS2_EXP 0xf252000f /* P2_TMGTHRISE */ @@ -878,7 +878,7 @@ /* P2_KTTMG */ #define RSTV0910_P2_KTTMG 0xf257 -#define FSTV0910_P2_KT_TMG_EXP 0xf25700f0 +#define FSTV0910_P2_KT_TMG_EXP 0xf25740f0 /* P2_KREFTMG */ #define RSTV0910_P2_KREFTMG 0xf258 @@ -886,12 +886,12 @@ /* P2_SFRSTEP */ #define RSTV0910_P2_SFRSTEP 0xf259 -#define FSTV0910_P2_SFR_SCANSTEP 0xf25900f0 +#define FSTV0910_P2_SFR_SCANSTEP 0xf25940f0 #define FSTV0910_P2_SFR_CENTERSTEP 0xf259000f /* P2_TMGCFG2 */ #define RSTV0910_P2_TMGCFG2 0xf25a -#define FSTV0910_P2_DIS_AUTOSAMP 0xf25a0008 +#define FSTV0910_P2_DIS_AUTOSAMP 0xf25a3008 #define FSTV0910_P2_SFRRATIO_FINE 0xf25a0001 /* P2_KREFTMG2 */ @@ -900,9 +900,9 @@ /* P2_TMGCFG3 */ #define RSTV0910_P2_TMGCFG3 0xf25d -#define FSTV0910_P2_CONT_TMGCENTER 0xf25d0008 -#define FSTV0910_P2_AUTO_GUP 0xf25d0004 -#define FSTV0910_P2_AUTO_GLOW 0xf25d0002 +#define FSTV0910_P2_CONT_TMGCENTER 0xf25d3008 +#define FSTV0910_P2_AUTO_GUP 0xf25d2004 +#define FSTV0910_P2_AUTO_GLOW 0xf25d1002 /* P2_SFRINIT1 */ #define RSTV0910_P2_SFRINIT1 0xf25e @@ -966,11 +966,11 @@ /* P2_TMGOBS */ #define RSTV0910_P2_TMGOBS 0xf26d -#define FSTV0910_P2_ROLLOFF_STATUS 0xf26d00c0 +#define FSTV0910_P2_ROLLOFF_STATUS 0xf26d60c0 /* P2_EQUALCFG */ #define RSTV0910_P2_EQUALCFG 0xf26f -#define FSTV0910_P2_EQUAL_ON 0xf26f0040 +#define FSTV0910_P2_EQUAL_ON 0xf26f6040 #define FSTV0910_P2_MU_EQUALDFE 0xf26f0007 /* P2_EQUAI1 */ @@ -1095,33 +1095,33 @@ /* P2_NOSCFGF1 */ #define RSTV0910_P2_NOSCFGF1 0xf28e -#define FSTV0910_P2_LOWNOISE_MESURE 0xf28e0080 -#define FSTV0910_P2_NOS_DELFRAME 0xf28e0040 -#define FSTV0910_P2_NOSDATA_MODE 0xf28e0030 -#define FSTV0910_P2_FRAMESEL_TYPESEL 0xf28e000c +#define FSTV0910_P2_LOWNOISE_MESURE 0xf28e7080 +#define FSTV0910_P2_NOS_DELFRAME 0xf28e6040 +#define FSTV0910_P2_NOSDATA_MODE 0xf28e4030 +#define FSTV0910_P2_FRAMESEL_TYPESEL 0xf28e200c #define FSTV0910_P2_FRAMESEL_TYPE 0xf28e0003 /* P2_NOSCFGF2 */ #define RSTV0910_P2_NOSCFGF2 0xf28f -#define FSTV0910_P2_DIS_NOSPILOTS 0xf28f0080 -#define FSTV0910_P2_FRAMESEL_MODCODSEL 0xf28f0060 +#define FSTV0910_P2_DIS_NOSPILOTS 0xf28f7080 +#define FSTV0910_P2_FRAMESEL_MODCODSEL 0xf28f5060 #define FSTV0910_P2_FRAMESEL_MODCOD 0xf28f001f /* P2_CAR2CFG */ #define RSTV0910_P2_CAR2CFG 0xf290 -#define FSTV0910_P2_ROTA2ON 0xf2900004 +#define FSTV0910_P2_ROTA2ON 0xf2902004 #define FSTV0910_P2_PH_DET_ALGO2 0xf2900003 /* P2_CFR2CFR1 */ #define RSTV0910_P2_CFR2CFR1 0xf291 -#define FSTV0910_P2_EN_S2CAR2CENTER 0xf2910020 +#define FSTV0910_P2_EN_S2CAR2CENTER 0xf2915020 #define FSTV0910_P2_CFR2TOCFR1_BETA 0xf2910007 /* P2_CAR3CFG */ #define RSTV0910_P2_CAR3CFG 0xf292 -#define FSTV0910_P2_CARRIER23_MODE 0xf29200c0 -#define FSTV0910_P2_CAR3INTERM_DVBS1 0xf2920020 -#define FSTV0910_P2_ABAMPLIF_MODE 0xf2920018 +#define FSTV0910_P2_CARRIER23_MODE 0xf29260c0 +#define FSTV0910_P2_CAR3INTERM_DVBS1 0xf2925020 +#define FSTV0910_P2_ABAMPLIF_MODE 0xf2923018 #define FSTV0910_P2_CARRIER3_ALPHA3DL 0xf2920007 /* P2_CFR22 */ @@ -1138,50 +1138,50 @@ /* P2_ACLC2S2Q */ #define RSTV0910_P2_ACLC2S2Q 0xf297 -#define FSTV0910_P2_ENAB_SPSKSYMB 0xf2970080 -#define FSTV0910_P2_CAR2S2_Q_ALPH_M 0xf2970030 +#define FSTV0910_P2_ENAB_SPSKSYMB 0xf2977080 +#define FSTV0910_P2_CAR2S2_Q_ALPH_M 0xf2974030 #define FSTV0910_P2_CAR2S2_Q_ALPH_E 0xf297000f /* P2_ACLC2S28 */ #define RSTV0910_P2_ACLC2S28 0xf298 -#define FSTV0910_P2_CAR2S2_8_ALPH_M 0xf2980030 +#define FSTV0910_P2_CAR2S2_8_ALPH_M 0xf2984030 #define FSTV0910_P2_CAR2S2_8_ALPH_E 0xf298000f /* P2_ACLC2S216A */ #define RSTV0910_P2_ACLC2S216A 0xf299 -#define FSTV0910_P2_CAR2S2_16A_ALPH_M 0xf2990030 +#define FSTV0910_P2_CAR2S2_16A_ALPH_M 0xf2994030 #define FSTV0910_P2_CAR2S2_16A_ALPH_E 0xf299000f /* P2_ACLC2S232A */ #define RSTV0910_P2_ACLC2S232A 0xf29a -#define FSTV0910_P2_CAR2S2_32A_ALPH_M 0xf29a0030 +#define FSTV0910_P2_CAR2S2_32A_ALPH_M 0xf29a4030 #define FSTV0910_P2_CAR2S2_32A_ALPH_E 0xf29a000f /* P2_BCLC2S2Q */ #define RSTV0910_P2_BCLC2S2Q 0xf29c -#define FSTV0910_P2_CAR2S2_Q_BETA_M 0xf29c0030 +#define FSTV0910_P2_CAR2S2_Q_BETA_M 0xf29c4030 #define FSTV0910_P2_CAR2S2_Q_BETA_E 0xf29c000f /* P2_BCLC2S28 */ #define RSTV0910_P2_BCLC2S28 0xf29d -#define FSTV0910_P2_CAR2S2_8_BETA_M 0xf29d0030 +#define FSTV0910_P2_CAR2S2_8_BETA_M 0xf29d4030 #define FSTV0910_P2_CAR2S2_8_BETA_E 0xf29d000f /* P2_BCLC2S216A */ #define RSTV0910_P2_BCLC2S216A 0xf29e -#define FSTV0910_P2_DVBS2S216A_NIP 0xf29e0080 -#define FSTV0910_P2_CAR2S2_16A_BETA_M 0xf29e0030 +#define FSTV0910_P2_DVBS2S216A_NIP 0xf29e7080 +#define FSTV0910_P2_CAR2S2_16A_BETA_M 0xf29e4030 #define FSTV0910_P2_CAR2S2_16A_BETA_E 0xf29e000f /* P2_BCLC2S232A */ #define RSTV0910_P2_BCLC2S232A 0xf29f -#define FSTV0910_P2_DVBS2S232A_NIP 0xf29f0080 -#define FSTV0910_P2_CAR2S2_32A_BETA_M 0xf29f0030 +#define FSTV0910_P2_DVBS2S232A_NIP 0xf29f7080 +#define FSTV0910_P2_CAR2S2_32A_BETA_M 0xf29f4030 #define FSTV0910_P2_CAR2S2_32A_BETA_E 0xf29f000f /* P2_PLROOT2 */ #define RSTV0910_P2_PLROOT2 0xf2ac -#define FSTV0910_P2_PLSCRAMB_MODE 0xf2ac000c +#define FSTV0910_P2_PLSCRAMB_MODE 0xf2ac200c #define FSTV0910_P2_PLSCRAMB_ROOT2 0xf2ac0003 /* P2_PLROOT1 */ @@ -1198,100 +1198,100 @@ /* P2_MODCODLST1 */ #define RSTV0910_P2_MODCODLST1 0xf2b1 -#define FSTV0910_P2_SYMBRATE_FILTER 0xf2b10008 -#define FSTV0910_P2_NRESET_MODCODLST 0xf2b10004 +#define FSTV0910_P2_SYMBRATE_FILTER 0xf2b13008 +#define FSTV0910_P2_NRESET_MODCODLST 0xf2b12004 #define FSTV0910_P2_DIS_32PSK_9_10 0xf2b10003 /* P2_MODCODLST2 */ #define RSTV0910_P2_MODCODLST2 0xf2b2 -#define FSTV0910_P2_DIS_32PSK_8_9 0xf2b200f0 +#define FSTV0910_P2_DIS_32PSK_8_9 0xf2b240f0 #define FSTV0910_P2_DIS_32PSK_5_6 0xf2b2000f /* P2_MODCODLST3 */ #define RSTV0910_P2_MODCODLST3 0xf2b3 -#define FSTV0910_P2_DIS_32PSK_4_5 0xf2b300f0 +#define FSTV0910_P2_DIS_32PSK_4_5 0xf2b340f0 #define FSTV0910_P2_DIS_32PSK_3_4 0xf2b3000f /* P2_MODCODLST4 */ #define RSTV0910_P2_MODCODLST4 0xf2b4 -#define FSTV0910_P2_DUMMYPL_PILOT 0xf2b40080 -#define FSTV0910_P2_DUMMYPL_NOPILOT 0xf2b40040 -#define FSTV0910_P2_DIS_16PSK_9_10 0xf2b40030 +#define FSTV0910_P2_DUMMYPL_PILOT 0xf2b47080 +#define FSTV0910_P2_DUMMYPL_NOPILOT 0xf2b46040 +#define FSTV0910_P2_DIS_16PSK_9_10 0xf2b44030 #define FSTV0910_P2_DIS_16PSK_8_9 0xf2b4000f /* P2_MODCODLST5 */ #define RSTV0910_P2_MODCODLST5 0xf2b5 -#define FSTV0910_P2_DIS_16PSK_5_6 0xf2b500f0 +#define FSTV0910_P2_DIS_16PSK_5_6 0xf2b540f0 #define FSTV0910_P2_DIS_16PSK_4_5 0xf2b5000f /* P2_MODCODLST6 */ #define RSTV0910_P2_MODCODLST6 0xf2b6 -#define FSTV0910_P2_DIS_16PSK_3_4 0xf2b600f0 +#define FSTV0910_P2_DIS_16PSK_3_4 0xf2b640f0 #define FSTV0910_P2_DIS_16PSK_2_3 0xf2b6000f /* P2_MODCODLST7 */ #define RSTV0910_P2_MODCODLST7 0xf2b7 -#define FSTV0910_P2_MODCOD_NNOSFILTER 0xf2b70080 -#define FSTV0910_P2_DIS_8PSK_9_10 0xf2b70030 +#define FSTV0910_P2_MODCOD_NNOSFILTER 0xf2b77080 +#define FSTV0910_P2_DIS_8PSK_9_10 0xf2b74030 #define FSTV0910_P2_DIS_8PSK_8_9 0xf2b7000f /* P2_MODCODLST8 */ #define RSTV0910_P2_MODCODLST8 0xf2b8 -#define FSTV0910_P2_DIS_8PSK_5_6 0xf2b800f0 +#define FSTV0910_P2_DIS_8PSK_5_6 0xf2b840f0 #define FSTV0910_P2_DIS_8PSK_3_4 0xf2b8000f /* P2_MODCODLST9 */ #define RSTV0910_P2_MODCODLST9 0xf2b9 -#define FSTV0910_P2_DIS_8PSK_2_3 0xf2b900f0 +#define FSTV0910_P2_DIS_8PSK_2_3 0xf2b940f0 #define FSTV0910_P2_DIS_8PSK_3_5 0xf2b9000f /* P2_MODCODLSTA */ #define RSTV0910_P2_MODCODLSTA 0xf2ba -#define FSTV0910_P2_NOSFILTER_LIMITE 0xf2ba0080 -#define FSTV0910_P2_DIS_QPSK_9_10 0xf2ba0030 +#define FSTV0910_P2_NOSFILTER_LIMITE 0xf2ba7080 +#define FSTV0910_P2_DIS_QPSK_9_10 0xf2ba4030 #define FSTV0910_P2_DIS_QPSK_8_9 0xf2ba000f /* P2_MODCODLSTB */ #define RSTV0910_P2_MODCODLSTB 0xf2bb -#define FSTV0910_P2_DIS_QPSK_5_6 0xf2bb00f0 +#define FSTV0910_P2_DIS_QPSK_5_6 0xf2bb40f0 #define FSTV0910_P2_DIS_QPSK_4_5 0xf2bb000f /* P2_MODCODLSTC */ #define RSTV0910_P2_MODCODLSTC 0xf2bc -#define FSTV0910_P2_DIS_QPSK_3_4 0xf2bc00f0 +#define FSTV0910_P2_DIS_QPSK_3_4 0xf2bc40f0 #define FSTV0910_P2_DIS_QPSK_2_3 0xf2bc000f /* P2_MODCODLSTD */ #define RSTV0910_P2_MODCODLSTD 0xf2bd -#define FSTV0910_P2_DIS_QPSK_3_5 0xf2bd00f0 +#define FSTV0910_P2_DIS_QPSK_3_5 0xf2bd40f0 #define FSTV0910_P2_DIS_QPSK_1_2 0xf2bd000f /* P2_MODCODLSTE */ #define RSTV0910_P2_MODCODLSTE 0xf2be -#define FSTV0910_P2_DIS_QPSK_2_5 0xf2be00f0 +#define FSTV0910_P2_DIS_QPSK_2_5 0xf2be40f0 #define FSTV0910_P2_DIS_QPSK_1_3 0xf2be000f /* P2_MODCODLSTF */ #define RSTV0910_P2_MODCODLSTF 0xf2bf -#define FSTV0910_P2_DIS_QPSK_1_4 0xf2bf00f0 -#define FSTV0910_P2_DEMOD_INVMODLST 0xf2bf0008 -#define FSTV0910_P2_DEMODOUT_ENABLE 0xf2bf0004 -#define FSTV0910_P2_DDEMOD_NSET 0xf2bf0002 +#define FSTV0910_P2_DIS_QPSK_1_4 0xf2bf40f0 +#define FSTV0910_P2_DEMOD_INVMODLST 0xf2bf3008 +#define FSTV0910_P2_DEMODOUT_ENABLE 0xf2bf2004 +#define FSTV0910_P2_DDEMOD_NSET 0xf2bf1002 #define FSTV0910_P2_MODCOD_NSTOCK 0xf2bf0001 /* P2_GAUSSR0 */ #define RSTV0910_P2_GAUSSR0 0xf2c0 -#define FSTV0910_P2_EN_CCIMODE 0xf2c00080 +#define FSTV0910_P2_EN_CCIMODE 0xf2c07080 #define FSTV0910_P2_R0_GAUSSIEN 0xf2c0007f /* P2_CCIR0 */ #define RSTV0910_P2_CCIR0 0xf2c1 -#define FSTV0910_P2_CCIDETECT_PLHONLY 0xf2c10080 +#define FSTV0910_P2_CCIDETECT_PLHONLY 0xf2c17080 #define FSTV0910_P2_R0_CCI 0xf2c1007f /* P2_CCIQUANT */ #define RSTV0910_P2_CCIQUANT 0xf2c2 -#define FSTV0910_P2_CCI_BETA 0xf2c200e0 +#define FSTV0910_P2_CCI_BETA 0xf2c250e0 #define FSTV0910_P2_CCI_QUANT 0xf2c2001f /* P2_CCITHRES */ @@ -1304,24 +1304,24 @@ /* P2_DSTATUS4 */ #define RSTV0910_P2_DSTATUS4 0xf2c5 -#define FSTV0910_P2_RAINFADE_DETECT 0xf2c50080 -#define FSTV0910_P2_NOTHRES2_FAIL 0xf2c50040 -#define FSTV0910_P2_NOTHRES1_FAIL 0xf2c50020 -#define FSTV0910_P2_DMDPROG_ERROR 0xf2c50004 -#define FSTV0910_P2_CSTENV_DETECT 0xf2c50002 +#define FSTV0910_P2_RAINFADE_DETECT 0xf2c57080 +#define FSTV0910_P2_NOTHRES2_FAIL 0xf2c56040 +#define FSTV0910_P2_NOTHRES1_FAIL 0xf2c55020 +#define FSTV0910_P2_DMDPROG_ERROR 0xf2c52004 +#define FSTV0910_P2_CSTENV_DETECT 0xf2c51002 #define FSTV0910_P2_DETECTION_TRIAX 0xf2c50001 /* P2_DMDRESCFG */ #define RSTV0910_P2_DMDRESCFG 0xf2c6 -#define FSTV0910_P2_DMDRES_RESET 0xf2c60080 -#define FSTV0910_P2_DMDRES_STRALL 0xf2c60008 -#define FSTV0910_P2_DMDRES_NEWONLY 0xf2c60004 -#define FSTV0910_P2_DMDRES_NOSTORE 0xf2c60002 +#define FSTV0910_P2_DMDRES_RESET 0xf2c67080 +#define FSTV0910_P2_DMDRES_STRALL 0xf2c63008 +#define FSTV0910_P2_DMDRES_NEWONLY 0xf2c62004 +#define FSTV0910_P2_DMDRES_NOSTORE 0xf2c61002 /* P2_DMDRESADR */ #define RSTV0910_P2_DMDRESADR 0xf2c7 -#define FSTV0910_P2_DMDRES_VALIDCFR 0xf2c70040 -#define FSTV0910_P2_DMDRES_MEMFULL 0xf2c70030 +#define FSTV0910_P2_DMDRES_VALIDCFR 0xf2c76040 +#define FSTV0910_P2_DMDRES_MEMFULL 0xf2c74030 #define FSTV0910_P2_DMDRES_RESNBR 0xf2c7000f /* P2_DMDRESDATA7 */ @@ -1390,29 +1390,29 @@ /* P2_FFECFG */ #define RSTV0910_P2_FFECFG 0xf2d8 -#define FSTV0910_P2_EQUALFFE_ON 0xf2d80040 -#define FSTV0910_P2_EQUAL_USEDSYMB 0xf2d80030 +#define FSTV0910_P2_EQUALFFE_ON 0xf2d86040 +#define FSTV0910_P2_EQUAL_USEDSYMB 0xf2d84030 #define FSTV0910_P2_MU_EQUALFFE 0xf2d80007 /* P2_TNRCFG2 */ #define RSTV0910_P2_TNRCFG2 0xf2e1 -#define FSTV0910_P2_TUN_IQSWAP 0xf2e10080 +#define FSTV0910_P2_TUN_IQSWAP 0xf2e17080 /* P2_SMAPCOEF7 */ #define RSTV0910_P2_SMAPCOEF7 0xf300 -#define FSTV0910_P2_DIS_QSCALE 0xf3000080 +#define FSTV0910_P2_DIS_QSCALE 0xf3007080 #define FSTV0910_P2_SMAPCOEF_Q_LLR12 0xf300017f /* P2_SMAPCOEF6 */ #define RSTV0910_P2_SMAPCOEF6 0xf301 -#define FSTV0910_P2_DIS_AGC2SCALE 0xf3010080 -#define FSTV0910_P2_ADJ_8PSKLLR1 0xf3010004 -#define FSTV0910_P2_OLD_8PSKLLR1 0xf3010002 +#define FSTV0910_P2_DIS_AGC2SCALE 0xf3017080 +#define FSTV0910_P2_ADJ_8PSKLLR1 0xf3012004 +#define FSTV0910_P2_OLD_8PSKLLR1 0xf3011002 #define FSTV0910_P2_DIS_AB8PSK 0xf3010001 /* P2_SMAPCOEF5 */ #define RSTV0910_P2_SMAPCOEF5 0xf302 -#define FSTV0910_P2_DIS_8SCALE 0xf3020080 +#define FSTV0910_P2_DIS_8SCALE 0xf3027080 #define FSTV0910_P2_SMAPCOEF_8P_LLR23 0xf302017f /* P2_SMAPCOEF4 */ @@ -1425,17 +1425,17 @@ /* P2_SMAPCOEF2 */ #define RSTV0910_P2_SMAPCOEF2 0xf305 -#define FSTV0910_P2_SMAPCOEF_32APSK_R2R3 0xf30501f0 +#define FSTV0910_P2_SMAPCOEF_32APSK_R2R3 0xf30541f0 #define FSTV0910_P2_SMAPCOEF_32APSK_LLR2 0xf305010f /* P2_SMAPCOEF1 */ #define RSTV0910_P2_SMAPCOEF1 0xf306 -#define FSTV0910_P2_DIS_16SCALE 0xf3060080 +#define FSTV0910_P2_DIS_16SCALE 0xf3067080 #define FSTV0910_P2_SMAPCOEF_32_LLR34 0xf306017f /* P2_SMAPCOEF0 */ #define RSTV0910_P2_SMAPCOEF0 0xf307 -#define FSTV0910_P2_DIS_32SCALE 0xf3070080 +#define FSTV0910_P2_DIS_32SCALE 0xf3077080 #define FSTV0910_P2_SMAPCOEF_32_LLR15 0xf307017f /* P2_NOSTHRES1 */ @@ -1452,20 +1452,20 @@ /* P2_RAINFADE */ #define RSTV0910_P2_RAINFADE 0xf30c -#define FSTV0910_P2_NOSTHRES_DATAT 0xf30c0080 -#define FSTV0910_P2_RAINFADE_CNLIMIT 0xf30c0070 +#define FSTV0910_P2_NOSTHRES_DATAT 0xf30c7080 +#define FSTV0910_P2_RAINFADE_CNLIMIT 0xf30c4070 #define FSTV0910_P2_RAINFADE_TIMEOUT 0xf30c0007 /* P2_NOSRAMCFG */ #define RSTV0910_P2_NOSRAMCFG 0xf30d -#define FSTV0910_P2_NOSRAM_ACTIVATION 0xf30d0030 -#define FSTV0910_P2_NOSRAM_CNRONLY 0xf30d0008 +#define FSTV0910_P2_NOSRAM_ACTIVATION 0xf30d4030 +#define FSTV0910_P2_NOSRAM_CNRONLY 0xf30d3008 #define FSTV0910_P2_NOSRAM_LGNCNR1 0xf30d0007 /* P2_NOSRAMPOS */ #define RSTV0910_P2_NOSRAMPOS 0xf30e -#define FSTV0910_P2_NOSRAM_LGNCNR0 0xf30e00f0 -#define FSTV0910_P2_NOSRAM_VALIDE 0xf30e0004 +#define FSTV0910_P2_NOSRAM_LGNCNR0 0xf30e40f0 +#define FSTV0910_P2_NOSRAM_VALIDE 0xf30e2004 #define FSTV0910_P2_NOSRAM_CNRVAL1 0xf30e0003 /* P2_NOSRAMVAL */ @@ -1494,16 +1494,16 @@ /* P2_VITSCALE */ #define RSTV0910_P2_VITSCALE 0xf332 -#define FSTV0910_P2_NVTH_NOSRANGE 0xf3320080 -#define FSTV0910_P2_VERROR_MAXMODE 0xf3320040 -#define FSTV0910_P2_NSLOWSN_LOCKED 0xf3320008 -#define FSTV0910_P2_DIS_RSFLOCK 0xf3320002 +#define FSTV0910_P2_NVTH_NOSRANGE 0xf3327080 +#define FSTV0910_P2_VERROR_MAXMODE 0xf3326040 +#define FSTV0910_P2_NSLOWSN_LOCKED 0xf3323008 +#define FSTV0910_P2_DIS_RSFLOCK 0xf3321002 /* P2_FECM */ #define RSTV0910_P2_FECM 0xf333 -#define FSTV0910_P2_DSS_DVB 0xf3330080 -#define FSTV0910_P2_DSS_SRCH 0xf3330010 -#define FSTV0910_P2_SYNCVIT 0xf3330002 +#define FSTV0910_P2_DSS_DVB 0xf3337080 +#define FSTV0910_P2_DSS_SRCH 0xf3334010 +#define FSTV0910_P2_SYNCVIT 0xf3331002 #define FSTV0910_P2_IQINV 0xf3330001 /* P2_VTH12 */ @@ -1540,26 +1540,26 @@ /* P2_PRVIT */ #define RSTV0910_P2_PRVIT 0xf33c -#define FSTV0910_P2_DIS_VTHLOCK 0xf33c0040 -#define FSTV0910_P2_E7_8VIT 0xf33c0020 -#define FSTV0910_P2_E6_7VIT 0xf33c0010 -#define FSTV0910_P2_E5_6VIT 0xf33c0008 -#define FSTV0910_P2_E3_4VIT 0xf33c0004 -#define FSTV0910_P2_E2_3VIT 0xf33c0002 +#define FSTV0910_P2_DIS_VTHLOCK 0xf33c6040 +#define FSTV0910_P2_E7_8VIT 0xf33c5020 +#define FSTV0910_P2_E6_7VIT 0xf33c4010 +#define FSTV0910_P2_E5_6VIT 0xf33c3008 +#define FSTV0910_P2_E3_4VIT 0xf33c2004 +#define FSTV0910_P2_E2_3VIT 0xf33c1002 #define FSTV0910_P2_E1_2VIT 0xf33c0001 /* P2_VAVSRVIT */ #define RSTV0910_P2_VAVSRVIT 0xf33d -#define FSTV0910_P2_AMVIT 0xf33d0080 -#define FSTV0910_P2_FROZENVIT 0xf33d0040 -#define FSTV0910_P2_SNVIT 0xf33d0030 -#define FSTV0910_P2_TOVVIT 0xf33d000c +#define FSTV0910_P2_AMVIT 0xf33d7080 +#define FSTV0910_P2_FROZENVIT 0xf33d6040 +#define FSTV0910_P2_SNVIT 0xf33d4030 +#define FSTV0910_P2_TOVVIT 0xf33d200c #define FSTV0910_P2_HYPVIT 0xf33d0003 /* P2_VSTATUSVIT */ #define RSTV0910_P2_VSTATUSVIT 0xf33e -#define FSTV0910_P2_PRFVIT 0xf33e0010 -#define FSTV0910_P2_LOCKEDVIT 0xf33e0008 +#define FSTV0910_P2_PRFVIT 0xf33e4010 +#define FSTV0910_P2_LOCKEDVIT 0xf33e3008 /* P2_VTHINUSE */ #define RSTV0910_P2_VTHINUSE 0xf33f @@ -1599,32 +1599,32 @@ /* P2_PDELCTRL0 */ #define RSTV0910_P2_PDELCTRL0 0xf34f -#define FSTV0910_P2_ISIOBS_MODE 0xf34f0030 +#define FSTV0910_P2_ISIOBS_MODE 0xf34f4030 /* P2_PDELCTRL1 */ #define RSTV0910_P2_PDELCTRL1 0xf350 -#define FSTV0910_P2_INV_MISMASK 0xf3500080 -#define FSTV0910_P2_FILTER_EN 0xf3500020 -#define FSTV0910_P2_HYSTEN 0xf3500008 -#define FSTV0910_P2_HYSTSWRST 0xf3500004 -#define FSTV0910_P2_EN_MIS00 0xf3500002 +#define FSTV0910_P2_INV_MISMASK 0xf3507080 +#define FSTV0910_P2_FILTER_EN 0xf3505020 +#define FSTV0910_P2_HYSTEN 0xf3503008 +#define FSTV0910_P2_HYSTSWRST 0xf3502004 +#define FSTV0910_P2_EN_MIS00 0xf3501002 #define FSTV0910_P2_ALGOSWRST 0xf3500001 /* P2_PDELCTRL2 */ #define RSTV0910_P2_PDELCTRL2 0xf351 -#define FSTV0910_P2_FORCE_CONTINUOUS 0xf3510080 -#define FSTV0910_P2_RESET_UPKO_COUNT 0xf3510040 -#define FSTV0910_P2_USER_PKTDELIN_NB 0xf3510020 -#define FSTV0910_P2_FRAME_MODE 0xf3510002 +#define FSTV0910_P2_FORCE_CONTINUOUS 0xf3517080 +#define FSTV0910_P2_RESET_UPKO_COUNT 0xf3516040 +#define FSTV0910_P2_USER_PKTDELIN_NB 0xf3515020 +#define FSTV0910_P2_FRAME_MODE 0xf3511002 /* P2_HYSTTHRESH */ #define RSTV0910_P2_HYSTTHRESH 0xf354 -#define FSTV0910_P2_DELIN_LOCKTHRES 0xf35400f0 +#define FSTV0910_P2_DELIN_LOCKTHRES 0xf35440f0 #define FSTV0910_P2_DELIN_UNLOCKTHRES 0xf354000f /* P2_UPLCCST0 */ #define RSTV0910_P2_UPLCCST0 0xf358 -#define FSTV0910_P2_UPL_CST0 0xf35800f8 +#define FSTV0910_P2_UPL_CST0 0xf35830f8 #define FSTV0910_P2_UPL_MODE 0xf3580007 /* P2_ISIENTRY */ @@ -1673,16 +1673,16 @@ /* P2_PDELSTATUS1 */ #define RSTV0910_P2_PDELSTATUS1 0xf369 -#define FSTV0910_P2_PKTDELIN_DELOCK 0xf3690080 -#define FSTV0910_P2_SYNCDUPDFL_BADDFL 0xf3690040 -#define FSTV0910_P2_UNACCEPTED_STREAM 0xf3690010 -#define FSTV0910_P2_BCH_ERROR_FLAG 0xf3690008 -#define FSTV0910_P2_PKTDELIN_LOCK 0xf3690002 +#define FSTV0910_P2_PKTDELIN_DELOCK 0xf3697080 +#define FSTV0910_P2_SYNCDUPDFL_BADDFL 0xf3696040 +#define FSTV0910_P2_UNACCEPTED_STREAM 0xf3694010 +#define FSTV0910_P2_BCH_ERROR_FLAG 0xf3693008 +#define FSTV0910_P2_PKTDELIN_LOCK 0xf3691002 #define FSTV0910_P2_FIRST_LOCK 0xf3690001 /* P2_PDELSTATUS2 */ #define RSTV0910_P2_PDELSTATUS2 0xf36a -#define FSTV0910_P2_FRAME_MODCOD 0xf36a007c +#define FSTV0910_P2_FRAME_MODCOD 0xf36a207c #define FSTV0910_P2_FRAME_TYPE 0xf36a0003 /* P2_BBFCRCKO1 */ @@ -1703,92 +1703,92 @@ /* P2_PDELCTRL3 */ #define RSTV0910_P2_PDELCTRL3 0xf36f -#define FSTV0910_P2_NOFIFO_BCHERR 0xf36f0020 -#define FSTV0910_P2_PKTDELIN_DELACMERR 0xf36f0010 +#define FSTV0910_P2_NOFIFO_BCHERR 0xf36f5020 +#define FSTV0910_P2_PKTDELIN_DELACMERR 0xf36f4010 /* P2_TSSTATEM */ #define RSTV0910_P2_TSSTATEM 0xf370 -#define FSTV0910_P2_TSDIL_ON 0xf3700080 -#define FSTV0910_P2_TSRS_ON 0xf3700020 -#define FSTV0910_P2_TSDESCRAMB_ON 0xf3700010 -#define FSTV0910_P2_TSFRAME_MODE 0xf3700008 -#define FSTV0910_P2_TS_DISABLE 0xf3700004 -#define FSTV0910_P2_TSACM_MODE 0xf3700002 +#define FSTV0910_P2_TSDIL_ON 0xf3707080 +#define FSTV0910_P2_TSRS_ON 0xf3705020 +#define FSTV0910_P2_TSDESCRAMB_ON 0xf3704010 +#define FSTV0910_P2_TSFRAME_MODE 0xf3703008 +#define FSTV0910_P2_TS_DISABLE 0xf3702004 +#define FSTV0910_P2_TSACM_MODE 0xf3701002 #define FSTV0910_P2_TSOUT_NOSYNC 0xf3700001 /* P2_TSSTATEL */ #define RSTV0910_P2_TSSTATEL 0xf371 -#define FSTV0910_P2_TSNOSYNCBYTE 0xf3710080 -#define FSTV0910_P2_TSPARITY_ON 0xf3710040 -#define FSTV0910_P2_TSISSYI_ON 0xf3710008 -#define FSTV0910_P2_TSNPD_ON 0xf3710004 -#define FSTV0910_P2_TSCRC8_ON 0xf3710002 +#define FSTV0910_P2_TSNOSYNCBYTE 0xf3717080 +#define FSTV0910_P2_TSPARITY_ON 0xf3716040 +#define FSTV0910_P2_TSISSYI_ON 0xf3713008 +#define FSTV0910_P2_TSNPD_ON 0xf3712004 +#define FSTV0910_P2_TSCRC8_ON 0xf3711002 #define FSTV0910_P2_TSDSS_PACKET 0xf3710001 /* P2_TSCFGH */ #define RSTV0910_P2_TSCFGH 0xf372 -#define FSTV0910_P2_TSFIFO_DVBCI 0xf3720080 -#define FSTV0910_P2_TSFIFO_SERIAL 0xf3720040 -#define FSTV0910_P2_TSFIFO_TEIUPDATE 0xf3720020 -#define FSTV0910_P2_TSFIFO_DUTY50 0xf3720010 -#define FSTV0910_P2_TSFIFO_HSGNLOUT 0xf3720008 -#define FSTV0910_P2_TSFIFO_ERRMODE 0xf3720006 +#define FSTV0910_P2_TSFIFO_DVBCI 0xf3727080 +#define FSTV0910_P2_TSFIFO_SERIAL 0xf3726040 +#define FSTV0910_P2_TSFIFO_TEIUPDATE 0xf3725020 +#define FSTV0910_P2_TSFIFO_DUTY50 0xf3724010 +#define FSTV0910_P2_TSFIFO_HSGNLOUT 0xf3723008 +#define FSTV0910_P2_TSFIFO_ERRMODE 0xf3721006 #define FSTV0910_P2_RST_HWARE 0xf3720001 /* P2_TSCFGM */ #define RSTV0910_P2_TSCFGM 0xf373 -#define FSTV0910_P2_TSFIFO_MANSPEED 0xf37300c0 -#define FSTV0910_P2_TSFIFO_PERMDATA 0xf3730020 -#define FSTV0910_P2_TSFIFO_NONEWSGNL 0xf3730010 +#define FSTV0910_P2_TSFIFO_MANSPEED 0xf37360c0 +#define FSTV0910_P2_TSFIFO_PERMDATA 0xf3735020 +#define FSTV0910_P2_TSFIFO_NONEWSGNL 0xf3734010 #define FSTV0910_P2_TSFIFO_INVDATA 0xf3730001 /* P2_TSCFGL */ #define RSTV0910_P2_TSCFGL 0xf374 -#define FSTV0910_P2_TSFIFO_BCLKDEL1CK 0xf37400c0 -#define FSTV0910_P2_BCHERROR_MODE 0xf3740030 -#define FSTV0910_P2_TSFIFO_NSGNL2DATA 0xf3740008 -#define FSTV0910_P2_TSFIFO_EMBINDVB 0xf3740004 +#define FSTV0910_P2_TSFIFO_BCLKDEL1CK 0xf37460c0 +#define FSTV0910_P2_BCHERROR_MODE 0xf3744030 +#define FSTV0910_P2_TSFIFO_NSGNL2DATA 0xf3743008 +#define FSTV0910_P2_TSFIFO_EMBINDVB 0xf3742004 #define FSTV0910_P2_TSFIFO_BITSPEED 0xf3740003 /* P2_TSSYNC */ #define RSTV0910_P2_TSSYNC 0xf375 -#define FSTV0910_P2_TSFIFO_SYNCMODE 0xf3750018 +#define FSTV0910_P2_TSFIFO_SYNCMODE 0xf3753018 /* P2_TSINSDELH */ #define RSTV0910_P2_TSINSDELH 0xf376 -#define FSTV0910_P2_TSDEL_SYNCBYTE 0xf3760080 -#define FSTV0910_P2_TSDEL_XXHEADER 0xf3760040 -#define FSTV0910_P2_TSDEL_DATAFIELD 0xf3760010 -#define FSTV0910_P2_TSINSDEL_RSPARITY 0xf3760002 +#define FSTV0910_P2_TSDEL_SYNCBYTE 0xf3767080 +#define FSTV0910_P2_TSDEL_XXHEADER 0xf3766040 +#define FSTV0910_P2_TSDEL_DATAFIELD 0xf3764010 +#define FSTV0910_P2_TSINSDEL_RSPARITY 0xf3761002 #define FSTV0910_P2_TSINSDEL_CRC8 0xf3760001 /* P2_TSINSDELM */ #define RSTV0910_P2_TSINSDELM 0xf377 -#define FSTV0910_P2_TSINS_EMODCOD 0xf3770010 -#define FSTV0910_P2_TSINS_TOKEN 0xf3770008 -#define FSTV0910_P2_TSINS_XXXERR 0xf3770004 -#define FSTV0910_P2_TSINS_MATYPE 0xf3770002 +#define FSTV0910_P2_TSINS_EMODCOD 0xf3774010 +#define FSTV0910_P2_TSINS_TOKEN 0xf3773008 +#define FSTV0910_P2_TSINS_XXXERR 0xf3772004 +#define FSTV0910_P2_TSINS_MATYPE 0xf3771002 #define FSTV0910_P2_TSINS_UPL 0xf3770001 /* P2_TSINSDELL */ #define RSTV0910_P2_TSINSDELL 0xf378 -#define FSTV0910_P2_TSINS_DFL 0xf3780080 -#define FSTV0910_P2_TSINS_SYNCD 0xf3780040 -#define FSTV0910_P2_TSINS_BLOCLEN 0xf3780020 -#define FSTV0910_P2_TSINS_SIGPCOUNT 0xf3780010 -#define FSTV0910_P2_TSINS_FIFO 0xf3780008 -#define FSTV0910_P2_TSINS_REALPACK 0xf3780004 -#define FSTV0910_P2_TSINS_TSCONFIG 0xf3780002 +#define FSTV0910_P2_TSINS_DFL 0xf3787080 +#define FSTV0910_P2_TSINS_SYNCD 0xf3786040 +#define FSTV0910_P2_TSINS_BLOCLEN 0xf3785020 +#define FSTV0910_P2_TSINS_SIGPCOUNT 0xf3784010 +#define FSTV0910_P2_TSINS_FIFO 0xf3783008 +#define FSTV0910_P2_TSINS_REALPACK 0xf3782004 +#define FSTV0910_P2_TSINS_TSCONFIG 0xf3781002 #define FSTV0910_P2_TSINS_LATENCY 0xf3780001 /* P2_TSDIVN */ #define RSTV0910_P2_TSDIVN 0xf379 -#define FSTV0910_P2_TSFIFO_SPEEDMODE 0xf37900c0 +#define FSTV0910_P2_TSFIFO_SPEEDMODE 0xf37960c0 #define FSTV0910_P2_TSFIFO_RISEOK 0xf3790007 /* P2_TSCFG4 */ #define RSTV0910_P2_TSCFG4 0xf37a -#define FSTV0910_P2_TSFIFO_TSSPEEDMODE 0xf37a00c0 +#define FSTV0910_P2_TSFIFO_TSSPEEDMODE 0xf37a60c0 /* P2_TSSPEED */ #define RSTV0910_P2_TSSPEED 0xf380 @@ -1796,18 +1796,18 @@ /* P2_TSSTATUS */ #define RSTV0910_P2_TSSTATUS 0xf381 -#define FSTV0910_P2_TSFIFO_LINEOK 0xf3810080 -#define FSTV0910_P2_TSFIFO_ERROR 0xf3810040 -#define FSTV0910_P2_TSFIFO_NOSYNC 0xf3810010 -#define FSTV0910_P2_TSREGUL_ERROR 0xf3810004 +#define FSTV0910_P2_TSFIFO_LINEOK 0xf3817080 +#define FSTV0910_P2_TSFIFO_ERROR 0xf3816040 +#define FSTV0910_P2_TSFIFO_NOSYNC 0xf3814010 +#define FSTV0910_P2_TSREGUL_ERROR 0xf3812004 #define FSTV0910_P2_DIL_READY 0xf3810001 /* P2_TSSTATUS2 */ #define RSTV0910_P2_TSSTATUS2 0xf382 -#define FSTV0910_P2_TSFIFO_DEMODSEL 0xf3820080 -#define FSTV0910_P2_TSFIFOSPEED_STORE 0xf3820040 -#define FSTV0910_P2_DILXX_RESET 0xf3820020 -#define FSTV0910_P2_SCRAMBDETECT 0xf3820002 +#define FSTV0910_P2_TSFIFO_DEMODSEL 0xf3827080 +#define FSTV0910_P2_TSFIFOSPEED_STORE 0xf3826040 +#define FSTV0910_P2_DILXX_RESET 0xf3825020 +#define FSTV0910_P2_SCRAMBDETECT 0xf3821002 /* P2_TSBITRATE1 */ #define RSTV0910_P2_TSBITRATE1 0xf383 @@ -1819,7 +1819,7 @@ /* P2_TSPACKLEN1 */ #define RSTV0910_P2_TSPACKLEN1 0xf385 -#define FSTV0910_P2_TSFIFO_PACKCPT 0xf38500e0 +#define FSTV0910_P2_TSFIFO_PACKCPT 0xf38550e0 /* P2_TSDLY2 */ #define RSTV0910_P2_TSDLY2 0xf389 @@ -1839,8 +1839,8 @@ /* P2_TSBUFSTAT2 */ #define RSTV0910_P2_TSBUFSTAT2 0xf38d -#define FSTV0910_P2_TSISCR_3BYTES 0xf38d0080 -#define FSTV0910_P2_TSISCR_NEWDATA 0xf38d0040 +#define FSTV0910_P2_TSISCR_3BYTES 0xf38d7080 +#define FSTV0910_P2_TSISCR_NEWDATA 0xf38d6040 #define FSTV0910_P2_TSISCR_BUFSTAT2 0xf38d003f /* P2_TSBUFSTAT1 */ @@ -1853,13 +1853,13 @@ /* P2_TSDEBUGL */ #define RSTV0910_P2_TSDEBUGL 0xf391 -#define FSTV0910_P2_TSFIFO_ERROR_EVNT 0xf3910004 +#define FSTV0910_P2_TSFIFO_ERROR_EVNT 0xf3912004 #define FSTV0910_P2_TSFIFO_OVERFLOWM 0xf3910001 /* P2_TSDLYSET2 */ #define RSTV0910_P2_TSDLYSET2 0xf392 -#define FSTV0910_P2_SOFFIFO_OFFSET 0xf39200c0 -#define FSTV0910_P2_HYSTERESIS_THRESHOLD 0xf3920030 +#define FSTV0910_P2_SOFFIFO_OFFSET 0xf39260c0 +#define FSTV0910_P2_HYSTERESIS_THRESHOLD 0xf3924030 #define FSTV0910_P2_SOFFIFO_SYMBOFFS2 0xf392000f /* P2_TSDLYSET1 */ @@ -1872,12 +1872,12 @@ /* P2_ERRCTRL1 */ #define RSTV0910_P2_ERRCTRL1 0xf398 -#define FSTV0910_P2_ERR_SOURCE1 0xf39800f0 +#define FSTV0910_P2_ERR_SOURCE1 0xf39840f0 #define FSTV0910_P2_NUM_EVENT1 0xf3980007 /* P2_ERRCNT12 */ #define RSTV0910_P2_ERRCNT12 0xf399 -#define FSTV0910_P2_ERRCNT1_OLDVALUE 0xf3990080 +#define FSTV0910_P2_ERRCNT1_OLDVALUE 0xf3997080 #define FSTV0910_P2_ERR_CNT12 0xf399007f /* P2_ERRCNT11 */ @@ -1890,12 +1890,12 @@ /* P2_ERRCTRL2 */ #define RSTV0910_P2_ERRCTRL2 0xf39c -#define FSTV0910_P2_ERR_SOURCE2 0xf39c00f0 +#define FSTV0910_P2_ERR_SOURCE2 0xf39c40f0 #define FSTV0910_P2_NUM_EVENT2 0xf39c0007 /* P2_ERRCNT22 */ #define RSTV0910_P2_ERRCNT22 0xf39d -#define FSTV0910_P2_ERRCNT2_OLDVALUE 0xf39d0080 +#define FSTV0910_P2_ERRCNT2_OLDVALUE 0xf39d7080 #define FSTV0910_P2_ERR_CNT22 0xf39d007f /* P2_ERRCNT21 */ @@ -1908,39 +1908,39 @@ /* P2_FECSPY */ #define RSTV0910_P2_FECSPY 0xf3a0 -#define FSTV0910_P2_SPY_ENABLE 0xf3a00080 -#define FSTV0910_P2_NO_SYNCBYTE 0xf3a00040 -#define FSTV0910_P2_SERIAL_MODE 0xf3a00020 -#define FSTV0910_P2_UNUSUAL_PACKET 0xf3a00010 -#define FSTV0910_P2_BERMETER_DATAMODE 0xf3a0000c -#define FSTV0910_P2_BERMETER_LMODE 0xf3a00002 +#define FSTV0910_P2_SPY_ENABLE 0xf3a07080 +#define FSTV0910_P2_NO_SYNCBYTE 0xf3a06040 +#define FSTV0910_P2_SERIAL_MODE 0xf3a05020 +#define FSTV0910_P2_UNUSUAL_PACKET 0xf3a04010 +#define FSTV0910_P2_BERMETER_DATAMODE 0xf3a0200c +#define FSTV0910_P2_BERMETER_LMODE 0xf3a01002 #define FSTV0910_P2_BERMETER_RESET 0xf3a00001 /* P2_FSPYCFG */ #define RSTV0910_P2_FSPYCFG 0xf3a1 -#define FSTV0910_P2_FECSPY_INPUT 0xf3a100c0 -#define FSTV0910_P2_RST_ON_ERROR 0xf3a10020 -#define FSTV0910_P2_ONE_SHOT 0xf3a10010 -#define FSTV0910_P2_I2C_MODE 0xf3a1000c +#define FSTV0910_P2_FECSPY_INPUT 0xf3a160c0 +#define FSTV0910_P2_RST_ON_ERROR 0xf3a15020 +#define FSTV0910_P2_ONE_SHOT 0xf3a14010 +#define FSTV0910_P2_I2C_MODE 0xf3a1200c #define FSTV0910_P2_SPY_HYSTERESIS 0xf3a10003 /* P2_FSPYDATA */ #define RSTV0910_P2_FSPYDATA 0xf3a2 -#define FSTV0910_P2_SPY_STUFFING 0xf3a20080 -#define FSTV0910_P2_SPY_CNULLPKT 0xf3a20020 +#define FSTV0910_P2_SPY_STUFFING 0xf3a27080 +#define FSTV0910_P2_SPY_CNULLPKT 0xf3a25020 #define FSTV0910_P2_SPY_OUTDATA_MODE 0xf3a2001f /* P2_FSPYOUT */ #define RSTV0910_P2_FSPYOUT 0xf3a3 -#define FSTV0910_P2_FSPY_DIRECT 0xf3a30080 +#define FSTV0910_P2_FSPY_DIRECT 0xf3a37080 #define FSTV0910_P2_STUFF_MODE 0xf3a30007 /* P2_FSTATUS */ #define RSTV0910_P2_FSTATUS 0xf3a4 -#define FSTV0910_P2_SPY_ENDSIM 0xf3a40080 -#define FSTV0910_P2_VALID_SIM 0xf3a40040 -#define FSTV0910_P2_FOUND_SIGNAL 0xf3a40020 -#define FSTV0910_P2_DSS_SYNCBYTE 0xf3a40010 +#define FSTV0910_P2_SPY_ENDSIM 0xf3a47080 +#define FSTV0910_P2_VALID_SIM 0xf3a46040 +#define FSTV0910_P2_FOUND_SIGNAL 0xf3a45020 +#define FSTV0910_P2_DSS_SYNCBYTE 0xf3a44010 #define FSTV0910_P2_RESULT_STATE 0xf3a4000f /* P2_FBERCPT4 */ @@ -1977,8 +1977,8 @@ /* P2_FSPYBER */ #define RSTV0910_P2_FSPYBER 0xf3b2 -#define FSTV0910_P2_FSPYBER_SYNCBYTE 0xf3b20010 -#define FSTV0910_P2_FSPYBER_UNSYNC 0xf3b20008 +#define FSTV0910_P2_FSPYBER_SYNCBYTE 0xf3b24010 +#define FSTV0910_P2_FSPYBER_UNSYNC 0xf3b23008 #define FSTV0910_P2_FSPYBER_CTIME 0xf3b20007 /* P2_SFERROR */ @@ -1987,60 +1987,60 @@ /* P2_SFECSTATUS */ #define RSTV0910_P2_SFECSTATUS 0xf3c3 -#define FSTV0910_P2_SFEC_ON 0xf3c30080 -#define FSTV0910_P2_SFEC_OFF 0xf3c30040 -#define FSTV0910_P2_LOCKEDSFEC 0xf3c30008 -#define FSTV0910_P2_SFEC_DELOCK 0xf3c30004 -#define FSTV0910_P2_SFEC_DEMODSEL 0xf3c30002 +#define FSTV0910_P2_SFEC_ON 0xf3c37080 +#define FSTV0910_P2_SFEC_OFF 0xf3c36040 +#define FSTV0910_P2_LOCKEDSFEC 0xf3c33008 +#define FSTV0910_P2_SFEC_DELOCK 0xf3c32004 +#define FSTV0910_P2_SFEC_DEMODSEL 0xf3c31002 #define FSTV0910_P2_SFEC_OVFON 0xf3c30001 /* P2_SFKDIV12 */ #define RSTV0910_P2_SFKDIV12 0xf3c4 -#define FSTV0910_P2_SFECKDIV12_MAN 0xf3c40080 +#define FSTV0910_P2_SFECKDIV12_MAN 0xf3c47080 /* P2_SFKDIV23 */ #define RSTV0910_P2_SFKDIV23 0xf3c5 -#define FSTV0910_P2_SFECKDIV23_MAN 0xf3c50080 +#define FSTV0910_P2_SFECKDIV23_MAN 0xf3c57080 /* P2_SFKDIV34 */ #define RSTV0910_P2_SFKDIV34 0xf3c6 -#define FSTV0910_P2_SFECKDIV34_MAN 0xf3c60080 +#define FSTV0910_P2_SFECKDIV34_MAN 0xf3c67080 /* P2_SFKDIV56 */ #define RSTV0910_P2_SFKDIV56 0xf3c7 -#define FSTV0910_P2_SFECKDIV56_MAN 0xf3c70080 +#define FSTV0910_P2_SFECKDIV56_MAN 0xf3c77080 /* P2_SFKDIV67 */ #define RSTV0910_P2_SFKDIV67 0xf3c8 -#define FSTV0910_P2_SFECKDIV67_MAN 0xf3c80080 +#define FSTV0910_P2_SFECKDIV67_MAN 0xf3c87080 /* P2_SFKDIV78 */ #define RSTV0910_P2_SFKDIV78 0xf3c9 -#define FSTV0910_P2_SFECKDIV78_MAN 0xf3c90080 +#define FSTV0910_P2_SFECKDIV78_MAN 0xf3c97080 /* P2_SFSTATUS */ #define RSTV0910_P2_SFSTATUS 0xf3cc -#define FSTV0910_P2_SFEC_LINEOK 0xf3cc0080 -#define FSTV0910_P2_SFEC_ERROR 0xf3cc0040 -#define FSTV0910_P2_SFEC_DATA7 0xf3cc0020 -#define FSTV0910_P2_SFEC_PKTDNBRFAIL 0xf3cc0010 -#define FSTV0910_P2_TSSFEC_DEMODSEL 0xf3cc0008 -#define FSTV0910_P2_SFEC_NOSYNC 0xf3cc0004 -#define FSTV0910_P2_SFEC_UNREGULA 0xf3cc0002 +#define FSTV0910_P2_SFEC_LINEOK 0xf3cc7080 +#define FSTV0910_P2_SFEC_ERROR 0xf3cc6040 +#define FSTV0910_P2_SFEC_DATA7 0xf3cc5020 +#define FSTV0910_P2_SFEC_PKTDNBRFAIL 0xf3cc4010 +#define FSTV0910_P2_TSSFEC_DEMODSEL 0xf3cc3008 +#define FSTV0910_P2_SFEC_NOSYNC 0xf3cc2004 +#define FSTV0910_P2_SFEC_UNREGULA 0xf3cc1002 #define FSTV0910_P2_SFEC_READY 0xf3cc0001 /* P2_SFDLYSET2 */ #define RSTV0910_P2_SFDLYSET2 0xf3d0 -#define FSTV0910_P2_SFEC_DISABLE 0xf3d00002 +#define FSTV0910_P2_SFEC_DISABLE 0xf3d01002 /* P2_SFERRCTRL */ #define RSTV0910_P2_SFERRCTRL 0xf3d8 -#define FSTV0910_P2_SFEC_ERR_SOURCE 0xf3d800f0 +#define FSTV0910_P2_SFEC_ERR_SOURCE 0xf3d840f0 #define FSTV0910_P2_SFEC_NUM_EVENT 0xf3d80007 /* P2_SFERRCNT2 */ #define RSTV0910_P2_SFERRCNT2 0xf3d9 -#define FSTV0910_P2_SFERRC_OLDVALUE 0xf3d90080 +#define FSTV0910_P2_SFERRC_OLDVALUE 0xf3d97080 #define FSTV0910_P2_SFEC_ERR_CNT2 0xf3d9007f /* P2_SFERRCNT1 */ @@ -2053,13 +2053,13 @@ /* P1_IQCONST */ #define RSTV0910_P1_IQCONST 0xf400 -#define FSTV0910_P1_CONSTEL_SELECT 0xf4000060 +#define FSTV0910_P1_CONSTEL_SELECT 0xf4005060 #define FSTV0910_P1_IQSYMB_SEL 0xf400001f /* P1_NOSCFG */ #define RSTV0910_P1_NOSCFG 0xf401 -#define FSTV0910_P1_DUMMYPL_NOSDATA 0xf4010020 -#define FSTV0910_P1_NOSPLH_BETA 0xf4010018 +#define FSTV0910_P1_DUMMYPL_NOSDATA 0xf4015020 +#define FSTV0910_P1_NOSPLH_BETA 0xf4013018 #define FSTV0910_P1_NOSDATA_BETA 0xf4010007 /* P1_ISYMB */ @@ -2072,18 +2072,18 @@ /* P1_AGC1CFG */ #define RSTV0910_P1_AGC1CFG 0xf404 -#define FSTV0910_P1_DC_FROZEN 0xf4040080 -#define FSTV0910_P1_DC_CORRECT 0xf4040040 -#define FSTV0910_P1_AMM_FROZEN 0xf4040020 -#define FSTV0910_P1_AMM_CORRECT 0xf4040010 -#define FSTV0910_P1_QUAD_FROZEN 0xf4040008 -#define FSTV0910_P1_QUAD_CORRECT 0xf4040004 +#define FSTV0910_P1_DC_FROZEN 0xf4047080 +#define FSTV0910_P1_DC_CORRECT 0xf4046040 +#define FSTV0910_P1_AMM_FROZEN 0xf4045020 +#define FSTV0910_P1_AMM_CORRECT 0xf4044010 +#define FSTV0910_P1_QUAD_FROZEN 0xf4043008 +#define FSTV0910_P1_QUAD_CORRECT 0xf4042004 /* P1_AGC1CN */ #define RSTV0910_P1_AGC1CN 0xf406 -#define FSTV0910_P1_AGC1_LOCKED 0xf4060080 -#define FSTV0910_P1_AGC1_MINPOWER 0xf4060010 -#define FSTV0910_P1_AGCOUT_FAST 0xf4060008 +#define FSTV0910_P1_AGC1_LOCKED 0xf4067080 +#define FSTV0910_P1_AGC1_MINPOWER 0xf4064010 +#define FSTV0910_P1_AGCOUT_FAST 0xf4063008 #define FSTV0910_P1_AGCIQ_BETA 0xf4060007 /* P1_AGC1REF */ @@ -2124,50 +2124,50 @@ /* P1_DEMOD */ #define RSTV0910_P1_DEMOD 0xf410 -#define FSTV0910_P1_MANUALS2_ROLLOFF 0xf4100080 -#define FSTV0910_P1_SPECINV_CONTROL 0xf4100030 -#define FSTV0910_P1_MANUALSX_ROLLOFF 0xf4100004 +#define FSTV0910_P1_MANUALS2_ROLLOFF 0xf4107080 +#define FSTV0910_P1_SPECINV_CONTROL 0xf4104030 +#define FSTV0910_P1_MANUALSX_ROLLOFF 0xf4102004 #define FSTV0910_P1_ROLLOFF_CONTROL 0xf4100003 /* P1_DMDMODCOD */ #define RSTV0910_P1_DMDMODCOD 0xf411 -#define FSTV0910_P1_MANUAL_MODCOD 0xf4110080 -#define FSTV0910_P1_DEMOD_MODCOD 0xf411007c +#define FSTV0910_P1_MANUAL_MODCOD 0xf4117080 +#define FSTV0910_P1_DEMOD_MODCOD 0xf411207c #define FSTV0910_P1_DEMOD_TYPE 0xf4110003 /* P1_DSTATUS */ #define RSTV0910_P1_DSTATUS 0xf412 -#define FSTV0910_P1_CAR_LOCK 0xf4120080 -#define FSTV0910_P1_TMGLOCK_QUALITY 0xf4120060 -#define FSTV0910_P1_LOCK_DEFINITIF 0xf4120008 +#define FSTV0910_P1_CAR_LOCK 0xf4127080 +#define FSTV0910_P1_TMGLOCK_QUALITY 0xf4125060 +#define FSTV0910_P1_LOCK_DEFINITIF 0xf4123008 #define FSTV0910_P1_OVADC_DETECT 0xf4120001 /* P1_DSTATUS2 */ #define RSTV0910_P1_DSTATUS2 0xf413 -#define FSTV0910_P1_DEMOD_DELOCK 0xf4130080 -#define FSTV0910_P1_MODCODRQ_SYNCTAG 0xf4130020 -#define FSTV0910_P1_POLYPH_SATEVENT 0xf4130010 -#define FSTV0910_P1_AGC1_NOSIGNALACK 0xf4130008 -#define FSTV0910_P1_AGC2_OVERFLOW 0xf4130004 -#define FSTV0910_P1_CFR_OVERFLOW 0xf4130002 +#define FSTV0910_P1_DEMOD_DELOCK 0xf4137080 +#define FSTV0910_P1_MODCODRQ_SYNCTAG 0xf4135020 +#define FSTV0910_P1_POLYPH_SATEVENT 0xf4134010 +#define FSTV0910_P1_AGC1_NOSIGNALACK 0xf4133008 +#define FSTV0910_P1_AGC2_OVERFLOW 0xf4132004 +#define FSTV0910_P1_CFR_OVERFLOW 0xf4131002 #define FSTV0910_P1_GAMMA_OVERUNDER 0xf4130001 /* P1_DMDCFGMD */ #define RSTV0910_P1_DMDCFGMD 0xf414 -#define FSTV0910_P1_DVBS2_ENABLE 0xf4140080 -#define FSTV0910_P1_DVBS1_ENABLE 0xf4140040 -#define FSTV0910_P1_SCAN_ENABLE 0xf4140010 -#define FSTV0910_P1_CFR_AUTOSCAN 0xf4140008 +#define FSTV0910_P1_DVBS2_ENABLE 0xf4147080 +#define FSTV0910_P1_DVBS1_ENABLE 0xf4146040 +#define FSTV0910_P1_SCAN_ENABLE 0xf4144010 +#define FSTV0910_P1_CFR_AUTOSCAN 0xf4143008 #define FSTV0910_P1_TUN_RNG 0xf4140003 /* P1_DMDCFG2 */ #define RSTV0910_P1_DMDCFG2 0xf415 -#define FSTV0910_P1_S1S2_SEQUENTIAL 0xf4150040 -#define FSTV0910_P1_INFINITE_RELOCK 0xf4150010 +#define FSTV0910_P1_S1S2_SEQUENTIAL 0xf4156040 +#define FSTV0910_P1_INFINITE_RELOCK 0xf4154010 /* P1_DMDISTATE */ #define RSTV0910_P1_DMDISTATE 0xf416 -#define FSTV0910_P1_I2C_NORESETDMODE 0xf4160080 +#define FSTV0910_P1_I2C_NORESETDMODE 0xf4167080 #define FSTV0910_P1_I2C_DEMOD_MODE 0xf416001f /* P1_DMDT0M */ @@ -2176,27 +2176,27 @@ /* P1_DMDSTATE */ #define RSTV0910_P1_DMDSTATE 0xf41b -#define FSTV0910_P1_HEADER_MODE 0xf41b0060 +#define FSTV0910_P1_HEADER_MODE 0xf41b5060 /* P1_DMDFLYW */ #define RSTV0910_P1_DMDFLYW 0xf41c -#define FSTV0910_P1_I2C_IRQVAL 0xf41c00f0 +#define FSTV0910_P1_I2C_IRQVAL 0xf41c40f0 #define FSTV0910_P1_FLYWHEEL_CPT 0xf41c000f /* P1_DSTATUS3 */ #define RSTV0910_P1_DSTATUS3 0xf41d -#define FSTV0910_P1_CFR_ZIGZAG 0xf41d0080 -#define FSTV0910_P1_DEMOD_CFGMODE 0xf41d0060 -#define FSTV0910_P1_GAMMA_LOWBAUDRATE 0xf41d0010 +#define FSTV0910_P1_CFR_ZIGZAG 0xf41d7080 +#define FSTV0910_P1_DEMOD_CFGMODE 0xf41d5060 +#define FSTV0910_P1_GAMMA_LOWBAUDRATE 0xf41d4010 /* P1_DMDCFG3 */ #define RSTV0910_P1_DMDCFG3 0xf41e -#define FSTV0910_P1_NOSTOP_FIFOFULL 0xf41e0008 +#define FSTV0910_P1_NOSTOP_FIFOFULL 0xf41e3008 /* P1_DMDCFG4 */ #define RSTV0910_P1_DMDCFG4 0xf41f -#define FSTV0910_P1_DIS_VITLOCK 0xf41f0080 -#define FSTV0910_P1_DIS_CLKENABLE 0xf41f0004 +#define FSTV0910_P1_DIS_VITLOCK 0xf41f7080 +#define FSTV0910_P1_DIS_CLKENABLE 0xf41f2004 /* P1_CORRELMANT */ #define RSTV0910_P1_CORRELMANT 0xf420 @@ -2208,13 +2208,13 @@ /* P1_CORRELEXP */ #define RSTV0910_P1_CORRELEXP 0xf422 -#define FSTV0910_P1_CORREL_ABSEXP 0xf42200f0 +#define FSTV0910_P1_CORREL_ABSEXP 0xf42240f0 #define FSTV0910_P1_CORREL_EXP 0xf422000f /* P1_PLHMODCOD */ #define RSTV0910_P1_PLHMODCOD 0xf424 -#define FSTV0910_P1_SPECINV_DEMOD 0xf4240080 -#define FSTV0910_P1_PLH_MODCOD 0xf424007c +#define FSTV0910_P1_SPECINV_DEMOD 0xf4247080 +#define FSTV0910_P1_PLH_MODCOD 0xf424207c #define FSTV0910_P1_PLH_TYPE 0xf4240003 /* P1_DMDREG */ @@ -2223,19 +2223,19 @@ /* P1_AGCNADJ */ #define RSTV0910_P1_AGCNADJ 0xf426 -#define FSTV0910_P1_RADJOFF_AGC2 0xf4260080 -#define FSTV0910_P1_RADJOFF_AGC1 0xf4260040 +#define FSTV0910_P1_RADJOFF_AGC2 0xf4267080 +#define FSTV0910_P1_RADJOFF_AGC1 0xf4266040 #define FSTV0910_P1_AGC_NADJ 0xf426013f /* P1_AGCKS */ #define RSTV0910_P1_AGCKS 0xf427 -#define FSTV0910_P1_RSADJ_MANUALCFG 0xf4270080 -#define FSTV0910_P1_RSADJ_CCMMODE 0xf4270040 +#define FSTV0910_P1_RSADJ_MANUALCFG 0xf4277080 +#define FSTV0910_P1_RSADJ_CCMMODE 0xf4276040 #define FSTV0910_P1_RADJ_SPSK 0xf427013f /* P1_AGCKQ */ #define RSTV0910_P1_AGCKQ 0xf428 -#define FSTV0910_P1_RADJON_DVBS1 0xf4280040 +#define FSTV0910_P1_RADJON_DVBS1 0xf4286040 #define FSTV0910_P1_RADJ_QPSK 0xf428013f /* P1_AGCK8 */ @@ -2244,20 +2244,20 @@ /* P1_AGCK16 */ #define RSTV0910_P1_AGCK16 0xf42a -#define FSTV0910_P1_R2ADJOFF_16APSK 0xf42a0040 -#define FSTV0910_P1_R1ADJOFF_16APSK 0xf42a0020 +#define FSTV0910_P1_R2ADJOFF_16APSK 0xf42a6040 +#define FSTV0910_P1_R1ADJOFF_16APSK 0xf42a5020 #define FSTV0910_P1_RADJ_16APSK 0xf42a011f /* P1_AGCK32 */ #define RSTV0910_P1_AGCK32 0xf42b -#define FSTV0910_P1_R3ADJOFF_32APSK 0xf42b0080 -#define FSTV0910_P1_R2ADJOFF_32APSK 0xf42b0040 -#define FSTV0910_P1_R1ADJOFF_32APSK 0xf42b0020 +#define FSTV0910_P1_R3ADJOFF_32APSK 0xf42b7080 +#define FSTV0910_P1_R2ADJOFF_32APSK 0xf42b6040 +#define FSTV0910_P1_R1ADJOFF_32APSK 0xf42b5020 #define FSTV0910_P1_RADJ_32APSK 0xf42b011f /* P1_AGC2O */ #define RSTV0910_P1_AGC2O 0xf42c -#define FSTV0910_P1_CSTENV_MODE 0xf42c00c0 +#define FSTV0910_P1_CSTENV_MODE 0xf42c60c0 #define FSTV0910_P1_AGC2_COEF 0xf42c0007 /* P1_AGC2REF */ @@ -2306,32 +2306,32 @@ /* P1_CARCFG */ #define RSTV0910_P1_CARCFG 0xf438 -#define FSTV0910_P1_ROTAON 0xf4380004 +#define FSTV0910_P1_ROTAON 0xf4382004 #define FSTV0910_P1_PH_DET_ALGO 0xf4380003 /* P1_ACLC */ #define RSTV0910_P1_ACLC 0xf439 -#define FSTV0910_P1_CAR_ALPHA_MANT 0xf4390030 +#define FSTV0910_P1_CAR_ALPHA_MANT 0xf4394030 #define FSTV0910_P1_CAR_ALPHA_EXP 0xf439000f /* P1_BCLC */ #define RSTV0910_P1_BCLC 0xf43a -#define FSTV0910_P1_CAR_BETA_MANT 0xf43a0030 +#define FSTV0910_P1_CAR_BETA_MANT 0xf43a4030 #define FSTV0910_P1_CAR_BETA_EXP 0xf43a000f /* P1_ACLCS2 */ #define RSTV0910_P1_ACLCS2 0xf43b -#define FSTV0910_P1_CARS2_APLHA_MANTISSE 0xf43b0030 +#define FSTV0910_P1_CARS2_APLHA_MANTISSE 0xf43b4030 #define FSTV0910_P1_CARS2_ALPHA_EXP 0xf43b000f /* P1_BCLCS2 */ #define RSTV0910_P1_BCLCS2 0xf43c -#define FSTV0910_P1_CARS2_BETA_MANTISSE 0xf43c0030 +#define FSTV0910_P1_CARS2_BETA_MANTISSE 0xf43c4030 #define FSTV0910_P1_CARS2_BETA_EXP 0xf43c000f /* P1_CARFREQ */ #define RSTV0910_P1_CARFREQ 0xf43d -#define FSTV0910_P1_KC_COARSE_EXP 0xf43d00f0 +#define FSTV0910_P1_KC_COARSE_EXP 0xf43d40f0 #define FSTV0910_P1_BETA_FREQ 0xf43d000f /* P1_CARHDR */ @@ -2384,7 +2384,7 @@ /* P1_CFRINC1 */ #define RSTV0910_P1_CFRINC1 0xf44a -#define FSTV0910_P1_MANUAL_CFRINC 0xf44a0080 +#define FSTV0910_P1_MANUAL_CFRINC 0xf44a7080 #define FSTV0910_P1_CFR_INC1 0xf44a003f /* P1_CFRINC0 */ @@ -2409,18 +2409,18 @@ /* P1_TMGCFG */ #define RSTV0910_P1_TMGCFG 0xf450 -#define FSTV0910_P1_TMGLOCK_BETA 0xf45000c0 -#define FSTV0910_P1_DO_TIMING_CORR 0xf4500010 +#define FSTV0910_P1_TMGLOCK_BETA 0xf45060c0 +#define FSTV0910_P1_DO_TIMING_CORR 0xf4504010 #define FSTV0910_P1_TMG_MINFREQ 0xf4500003 /* P1_RTC */ #define RSTV0910_P1_RTC 0xf451 -#define FSTV0910_P1_TMGALPHA_EXP 0xf45100f0 +#define FSTV0910_P1_TMGALPHA_EXP 0xf45140f0 #define FSTV0910_P1_TMGBETA_EXP 0xf451000f /* P1_RTCS2 */ #define RSTV0910_P1_RTCS2 0xf452 -#define FSTV0910_P1_TMGALPHAS2_EXP 0xf45200f0 +#define FSTV0910_P1_TMGALPHAS2_EXP 0xf45240f0 #define FSTV0910_P1_TMGBETAS2_EXP 0xf452000f /* P1_TMGTHRISE */ @@ -2441,7 +2441,7 @@ /* P1_KTTMG */ #define RSTV0910_P1_KTTMG 0xf457 -#define FSTV0910_P1_KT_TMG_EXP 0xf45700f0 +#define FSTV0910_P1_KT_TMG_EXP 0xf45740f0 /* P1_KREFTMG */ #define RSTV0910_P1_KREFTMG 0xf458 @@ -2449,12 +2449,12 @@ /* P1_SFRSTEP */ #define RSTV0910_P1_SFRSTEP 0xf459 -#define FSTV0910_P1_SFR_SCANSTEP 0xf45900f0 +#define FSTV0910_P1_SFR_SCANSTEP 0xf45940f0 #define FSTV0910_P1_SFR_CENTERSTEP 0xf459000f /* P1_TMGCFG2 */ #define RSTV0910_P1_TMGCFG2 0xf45a -#define FSTV0910_P1_DIS_AUTOSAMP 0xf45a0008 +#define FSTV0910_P1_DIS_AUTOSAMP 0xf45a3008 #define FSTV0910_P1_SFRRATIO_FINE 0xf45a0001 /* P1_KREFTMG2 */ @@ -2463,9 +2463,9 @@ /* P1_TMGCFG3 */ #define RSTV0910_P1_TMGCFG3 0xf45d -#define FSTV0910_P1_CONT_TMGCENTER 0xf45d0008 -#define FSTV0910_P1_AUTO_GUP 0xf45d0004 -#define FSTV0910_P1_AUTO_GLOW 0xf45d0002 +#define FSTV0910_P1_CONT_TMGCENTER 0xf45d3008 +#define FSTV0910_P1_AUTO_GUP 0xf45d2004 +#define FSTV0910_P1_AUTO_GLOW 0xf45d1002 /* P1_SFRINIT1 */ #define RSTV0910_P1_SFRINIT1 0xf45e @@ -2529,11 +2529,11 @@ /* P1_TMGOBS */ #define RSTV0910_P1_TMGOBS 0xf46d -#define FSTV0910_P1_ROLLOFF_STATUS 0xf46d00c0 +#define FSTV0910_P1_ROLLOFF_STATUS 0xf46d60c0 /* P1_EQUALCFG */ #define RSTV0910_P1_EQUALCFG 0xf46f -#define FSTV0910_P1_EQUAL_ON 0xf46f0040 +#define FSTV0910_P1_EQUAL_ON 0xf46f6040 #define FSTV0910_P1_MU_EQUALDFE 0xf46f0007 /* P1_EQUAI1 */ @@ -2658,33 +2658,33 @@ /* P1_NOSCFGF1 */ #define RSTV0910_P1_NOSCFGF1 0xf48e -#define FSTV0910_P1_LOWNOISE_MESURE 0xf48e0080 -#define FSTV0910_P1_NOS_DELFRAME 0xf48e0040 -#define FSTV0910_P1_NOSDATA_MODE 0xf48e0030 -#define FSTV0910_P1_FRAMESEL_TYPESEL 0xf48e000c +#define FSTV0910_P1_LOWNOISE_MESURE 0xf48e7080 +#define FSTV0910_P1_NOS_DELFRAME 0xf48e6040 +#define FSTV0910_P1_NOSDATA_MODE 0xf48e4030 +#define FSTV0910_P1_FRAMESEL_TYPESEL 0xf48e200c #define FSTV0910_P1_FRAMESEL_TYPE 0xf48e0003 /* P1_NOSCFGF2 */ #define RSTV0910_P1_NOSCFGF2 0xf48f -#define FSTV0910_P1_DIS_NOSPILOTS 0xf48f0080 -#define FSTV0910_P1_FRAMESEL_MODCODSEL 0xf48f0060 +#define FSTV0910_P1_DIS_NOSPILOTS 0xf48f7080 +#define FSTV0910_P1_FRAMESEL_MODCODSEL 0xf48f5060 #define FSTV0910_P1_FRAMESEL_MODCOD 0xf48f001f /* P1_CAR2CFG */ #define RSTV0910_P1_CAR2CFG 0xf490 -#define FSTV0910_P1_ROTA2ON 0xf4900004 +#define FSTV0910_P1_ROTA2ON 0xf4902004 #define FSTV0910_P1_PH_DET_ALGO2 0xf4900003 /* P1_CFR2CFR1 */ #define RSTV0910_P1_CFR2CFR1 0xf491 -#define FSTV0910_P1_EN_S2CAR2CENTER 0xf4910020 +#define FSTV0910_P1_EN_S2CAR2CENTER 0xf4915020 #define FSTV0910_P1_CFR2TOCFR1_BETA 0xf4910007 /* P1_CAR3CFG */ #define RSTV0910_P1_CAR3CFG 0xf492 -#define FSTV0910_P1_CARRIER23_MODE 0xf49200c0 -#define FSTV0910_P1_CAR3INTERM_DVBS1 0xf4920020 -#define FSTV0910_P1_ABAMPLIF_MODE 0xf4920018 +#define FSTV0910_P1_CARRIER23_MODE 0xf49260c0 +#define FSTV0910_P1_CAR3INTERM_DVBS1 0xf4925020 +#define FSTV0910_P1_ABAMPLIF_MODE 0xf4923018 #define FSTV0910_P1_CARRIER3_ALPHA3DL 0xf4920007 /* P1_CFR22 */ @@ -2701,50 +2701,50 @@ /* P1_ACLC2S2Q */ #define RSTV0910_P1_ACLC2S2Q 0xf497 -#define FSTV0910_P1_ENAB_SPSKSYMB 0xf4970080 -#define FSTV0910_P1_CAR2S2_Q_ALPH_M 0xf4970030 +#define FSTV0910_P1_ENAB_SPSKSYMB 0xf4977080 +#define FSTV0910_P1_CAR2S2_Q_ALPH_M 0xf4974030 #define FSTV0910_P1_CAR2S2_Q_ALPH_E 0xf497000f /* P1_ACLC2S28 */ #define RSTV0910_P1_ACLC2S28 0xf498 -#define FSTV0910_P1_CAR2S2_8_ALPH_M 0xf4980030 +#define FSTV0910_P1_CAR2S2_8_ALPH_M 0xf4984030 #define FSTV0910_P1_CAR2S2_8_ALPH_E 0xf498000f /* P1_ACLC2S216A */ #define RSTV0910_P1_ACLC2S216A 0xf499 -#define FSTV0910_P1_CAR2S2_16A_ALPH_M 0xf4990030 +#define FSTV0910_P1_CAR2S2_16A_ALPH_M 0xf4994030 #define FSTV0910_P1_CAR2S2_16A_ALPH_E 0xf499000f /* P1_ACLC2S232A */ #define RSTV0910_P1_ACLC2S232A 0xf49a -#define FSTV0910_P1_CAR2S2_32A_ALPH_M 0xf49a0030 +#define FSTV0910_P1_CAR2S2_32A_ALPH_M 0xf49a4030 #define FSTV0910_P1_CAR2S2_32A_ALPH_E 0xf49a000f /* P1_BCLC2S2Q */ #define RSTV0910_P1_BCLC2S2Q 0xf49c -#define FSTV0910_P1_CAR2S2_Q_BETA_M 0xf49c0030 +#define FSTV0910_P1_CAR2S2_Q_BETA_M 0xf49c4030 #define FSTV0910_P1_CAR2S2_Q_BETA_E 0xf49c000f /* P1_BCLC2S28 */ #define RSTV0910_P1_BCLC2S28 0xf49d -#define FSTV0910_P1_CAR2S2_8_BETA_M 0xf49d0030 +#define FSTV0910_P1_CAR2S2_8_BETA_M 0xf49d4030 #define FSTV0910_P1_CAR2S2_8_BETA_E 0xf49d000f /* P1_BCLC2S216A */ #define RSTV0910_P1_BCLC2S216A 0xf49e -#define FSTV0910_P1_DVBS2S216A_NIP 0xf49e0080 -#define FSTV0910_P1_CAR2S2_16A_BETA_M 0xf49e0030 +#define FSTV0910_P1_DVBS2S216A_NIP 0xf49e7080 +#define FSTV0910_P1_CAR2S2_16A_BETA_M 0xf49e4030 #define FSTV0910_P1_CAR2S2_16A_BETA_E 0xf49e000f /* P1_BCLC2S232A */ #define RSTV0910_P1_BCLC2S232A 0xf49f -#define FSTV0910_P1_DVBS2S232A_NIP 0xf49f0080 -#define FSTV0910_P1_CAR2S2_32A_BETA_M 0xf49f0030 +#define FSTV0910_P1_DVBS2S232A_NIP 0xf49f7080 +#define FSTV0910_P1_CAR2S2_32A_BETA_M 0xf49f4030 #define FSTV0910_P1_CAR2S2_32A_BETA_E 0xf49f000f /* P1_PLROOT2 */ #define RSTV0910_P1_PLROOT2 0xf4ac -#define FSTV0910_P1_PLSCRAMB_MODE 0xf4ac000c +#define FSTV0910_P1_PLSCRAMB_MODE 0xf4ac200c #define FSTV0910_P1_PLSCRAMB_ROOT2 0xf4ac0003 /* P1_PLROOT1 */ @@ -2761,100 +2761,100 @@ /* P1_MODCODLST1 */ #define RSTV0910_P1_MODCODLST1 0xf4b1 -#define FSTV0910_P1_SYMBRATE_FILTER 0xf4b10008 -#define FSTV0910_P1_NRESET_MODCODLST 0xf4b10004 +#define FSTV0910_P1_SYMBRATE_FILTER 0xf4b13008 +#define FSTV0910_P1_NRESET_MODCODLST 0xf4b12004 #define FSTV0910_P1_DIS_32PSK_9_10 0xf4b10003 /* P1_MODCODLST2 */ #define RSTV0910_P1_MODCODLST2 0xf4b2 -#define FSTV0910_P1_DIS_32PSK_8_9 0xf4b200f0 +#define FSTV0910_P1_DIS_32PSK_8_9 0xf4b240f0 #define FSTV0910_P1_DIS_32PSK_5_6 0xf4b2000f /* P1_MODCODLST3 */ #define RSTV0910_P1_MODCODLST3 0xf4b3 -#define FSTV0910_P1_DIS_32PSK_4_5 0xf4b300f0 +#define FSTV0910_P1_DIS_32PSK_4_5 0xf4b340f0 #define FSTV0910_P1_DIS_32PSK_3_4 0xf4b3000f /* P1_MODCODLST4 */ #define RSTV0910_P1_MODCODLST4 0xf4b4 -#define FSTV0910_P1_DUMMYPL_PILOT 0xf4b40080 -#define FSTV0910_P1_DUMMYPL_NOPILOT 0xf4b40040 -#define FSTV0910_P1_DIS_16PSK_9_10 0xf4b40030 +#define FSTV0910_P1_DUMMYPL_PILOT 0xf4b47080 +#define FSTV0910_P1_DUMMYPL_NOPILOT 0xf4b46040 +#define FSTV0910_P1_DIS_16PSK_9_10 0xf4b44030 #define FSTV0910_P1_DIS_16PSK_8_9 0xf4b4000f /* P1_MODCODLST5 */ #define RSTV0910_P1_MODCODLST5 0xf4b5 -#define FSTV0910_P1_DIS_16PSK_5_6 0xf4b500f0 +#define FSTV0910_P1_DIS_16PSK_5_6 0xf4b540f0 #define FSTV0910_P1_DIS_16PSK_4_5 0xf4b5000f /* P1_MODCODLST6 */ #define RSTV0910_P1_MODCODLST6 0xf4b6 -#define FSTV0910_P1_DIS_16PSK_3_4 0xf4b600f0 +#define FSTV0910_P1_DIS_16PSK_3_4 0xf4b640f0 #define FSTV0910_P1_DIS_16PSK_2_3 0xf4b6000f /* P1_MODCODLST7 */ #define RSTV0910_P1_MODCODLST7 0xf4b7 -#define FSTV0910_P1_MODCOD_NNOSFILTER 0xf4b70080 -#define FSTV0910_P1_DIS_8PSK_9_10 0xf4b70030 +#define FSTV0910_P1_MODCOD_NNOSFILTER 0xf4b77080 +#define FSTV0910_P1_DIS_8PSK_9_10 0xf4b74030 #define FSTV0910_P1_DIS_8PSK_8_9 0xf4b7000f /* P1_MODCODLST8 */ #define RSTV0910_P1_MODCODLST8 0xf4b8 -#define FSTV0910_P1_DIS_8PSK_5_6 0xf4b800f0 +#define FSTV0910_P1_DIS_8PSK_5_6 0xf4b840f0 #define FSTV0910_P1_DIS_8PSK_3_4 0xf4b8000f /* P1_MODCODLST9 */ #define RSTV0910_P1_MODCODLST9 0xf4b9 -#define FSTV0910_P1_DIS_8PSK_2_3 0xf4b900f0 +#define FSTV0910_P1_DIS_8PSK_2_3 0xf4b940f0 #define FSTV0910_P1_DIS_8PSK_3_5 0xf4b9000f /* P1_MODCODLSTA */ #define RSTV0910_P1_MODCODLSTA 0xf4ba -#define FSTV0910_P1_NOSFILTER_LIMITE 0xf4ba0080 -#define FSTV0910_P1_DIS_QPSK_9_10 0xf4ba0030 +#define FSTV0910_P1_NOSFILTER_LIMITE 0xf4ba7080 +#define FSTV0910_P1_DIS_QPSK_9_10 0xf4ba4030 #define FSTV0910_P1_DIS_QPSK_8_9 0xf4ba000f /* P1_MODCODLSTB */ #define RSTV0910_P1_MODCODLSTB 0xf4bb -#define FSTV0910_P1_DIS_QPSK_5_6 0xf4bb00f0 +#define FSTV0910_P1_DIS_QPSK_5_6 0xf4bb40f0 #define FSTV0910_P1_DIS_QPSK_4_5 0xf4bb000f /* P1_MODCODLSTC */ #define RSTV0910_P1_MODCODLSTC 0xf4bc -#define FSTV0910_P1_DIS_QPSK_3_4 0xf4bc00f0 +#define FSTV0910_P1_DIS_QPSK_3_4 0xf4bc40f0 #define FSTV0910_P1_DIS_QPSK_2_3 0xf4bc000f /* P1_MODCODLSTD */ #define RSTV0910_P1_MODCODLSTD 0xf4bd -#define FSTV0910_P1_DIS_QPSK_3_5 0xf4bd00f0 +#define FSTV0910_P1_DIS_QPSK_3_5 0xf4bd40f0 #define FSTV0910_P1_DIS_QPSK_1_2 0xf4bd000f /* P1_MODCODLSTE */ #define RSTV0910_P1_MODCODLSTE 0xf4be -#define FSTV0910_P1_DIS_QPSK_2_5 0xf4be00f0 +#define FSTV0910_P1_DIS_QPSK_2_5 0xf4be40f0 #define FSTV0910_P1_DIS_QPSK_1_3 0xf4be000f /* P1_MODCODLSTF */ #define RSTV0910_P1_MODCODLSTF 0xf4bf -#define FSTV0910_P1_DIS_QPSK_1_4 0xf4bf00f0 -#define FSTV0910_P1_DEMOD_INVMODLST 0xf4bf0008 -#define FSTV0910_P1_DEMODOUT_ENABLE 0xf4bf0004 -#define FSTV0910_P1_DDEMOD_NSET 0xf4bf0002 +#define FSTV0910_P1_DIS_QPSK_1_4 0xf4bf40f0 +#define FSTV0910_P1_DEMOD_INVMODLST 0xf4bf3008 +#define FSTV0910_P1_DEMODOUT_ENABLE 0xf4bf2004 +#define FSTV0910_P1_DDEMOD_NSET 0xf4bf1002 #define FSTV0910_P1_MODCOD_NSTOCK 0xf4bf0001 /* P1_GAUSSR0 */ #define RSTV0910_P1_GAUSSR0 0xf4c0 -#define FSTV0910_P1_EN_CCIMODE 0xf4c00080 +#define FSTV0910_P1_EN_CCIMODE 0xf4c07080 #define FSTV0910_P1_R0_GAUSSIEN 0xf4c0007f /* P1_CCIR0 */ #define RSTV0910_P1_CCIR0 0xf4c1 -#define FSTV0910_P1_CCIDETECT_PLHONLY 0xf4c10080 +#define FSTV0910_P1_CCIDETECT_PLHONLY 0xf4c17080 #define FSTV0910_P1_R0_CCI 0xf4c1007f /* P1_CCIQUANT */ #define RSTV0910_P1_CCIQUANT 0xf4c2 -#define FSTV0910_P1_CCI_BETA 0xf4c200e0 +#define FSTV0910_P1_CCI_BETA 0xf4c250e0 #define FSTV0910_P1_CCI_QUANT 0xf4c2001f /* P1_CCITHRES */ @@ -2867,24 +2867,24 @@ /* P1_DSTATUS4 */ #define RSTV0910_P1_DSTATUS4 0xf4c5 -#define FSTV0910_P1_RAINFADE_DETECT 0xf4c50080 -#define FSTV0910_P1_NOTHRES2_FAIL 0xf4c50040 -#define FSTV0910_P1_NOTHRES1_FAIL 0xf4c50020 -#define FSTV0910_P1_DMDPROG_ERROR 0xf4c50004 -#define FSTV0910_P1_CSTENV_DETECT 0xf4c50002 +#define FSTV0910_P1_RAINFADE_DETECT 0xf4c57080 +#define FSTV0910_P1_NOTHRES2_FAIL 0xf4c56040 +#define FSTV0910_P1_NOTHRES1_FAIL 0xf4c55020 +#define FSTV0910_P1_DMDPROG_ERROR 0xf4c52004 +#define FSTV0910_P1_CSTENV_DETECT 0xf4c51002 #define FSTV0910_P1_DETECTION_TRIAX 0xf4c50001 /* P1_DMDRESCFG */ #define RSTV0910_P1_DMDRESCFG 0xf4c6 -#define FSTV0910_P1_DMDRES_RESET 0xf4c60080 -#define FSTV0910_P1_DMDRES_STRALL 0xf4c60008 -#define FSTV0910_P1_DMDRES_NEWONLY 0xf4c60004 -#define FSTV0910_P1_DMDRES_NOSTORE 0xf4c60002 +#define FSTV0910_P1_DMDRES_RESET 0xf4c67080 +#define FSTV0910_P1_DMDRES_STRALL 0xf4c63008 +#define FSTV0910_P1_DMDRES_NEWONLY 0xf4c62004 +#define FSTV0910_P1_DMDRES_NOSTORE 0xf4c61002 /* P1_DMDRESADR */ #define RSTV0910_P1_DMDRESADR 0xf4c7 -#define FSTV0910_P1_DMDRES_VALIDCFR 0xf4c70040 -#define FSTV0910_P1_DMDRES_MEMFULL 0xf4c70030 +#define FSTV0910_P1_DMDRES_VALIDCFR 0xf4c76040 +#define FSTV0910_P1_DMDRES_MEMFULL 0xf4c74030 #define FSTV0910_P1_DMDRES_RESNBR 0xf4c7000f /* P1_DMDRESDATA7 */ @@ -2953,29 +2953,29 @@ /* P1_FFECFG */ #define RSTV0910_P1_FFECFG 0xf4d8 -#define FSTV0910_P1_EQUALFFE_ON 0xf4d80040 -#define FSTV0910_P1_EQUAL_USEDSYMB 0xf4d80030 +#define FSTV0910_P1_EQUALFFE_ON 0xf4d86040 +#define FSTV0910_P1_EQUAL_USEDSYMB 0xf4d84030 #define FSTV0910_P1_MU_EQUALFFE 0xf4d80007 /* P1_TNRCFG2 */ #define RSTV0910_P1_TNRCFG2 0xf4e1 -#define FSTV0910_P1_TUN_IQSWAP 0xf4e10080 +#define FSTV0910_P1_TUN_IQSWAP 0xf4e17080 /* P1_SMAPCOEF7 */ #define RSTV0910_P1_SMAPCOEF7 0xf500 -#define FSTV0910_P1_DIS_QSCALE 0xf5000080 +#define FSTV0910_P1_DIS_QSCALE 0xf5007080 #define FSTV0910_P1_SMAPCOEF_Q_LLR12 0xf500017f /* P1_SMAPCOEF6 */ #define RSTV0910_P1_SMAPCOEF6 0xf501 -#define FSTV0910_P1_DIS_AGC2SCALE 0xf5010080 -#define FSTV0910_P1_ADJ_8PSKLLR1 0xf5010004 -#define FSTV0910_P1_OLD_8PSKLLR1 0xf5010002 +#define FSTV0910_P1_DIS_AGC2SCALE 0xf5017080 +#define FSTV0910_P1_ADJ_8PSKLLR1 0xf5012004 +#define FSTV0910_P1_OLD_8PSKLLR1 0xf5011002 #define FSTV0910_P1_DIS_AB8PSK 0xf5010001 /* P1_SMAPCOEF5 */ #define RSTV0910_P1_SMAPCOEF5 0xf502 -#define FSTV0910_P1_DIS_8SCALE 0xf5020080 +#define FSTV0910_P1_DIS_8SCALE 0xf5027080 #define FSTV0910_P1_SMAPCOEF_8P_LLR23 0xf502017f /* P1_SMAPCOEF4 */ @@ -2988,17 +2988,17 @@ /* P1_SMAPCOEF2 */ #define RSTV0910_P1_SMAPCOEF2 0xf505 -#define FSTV0910_P1_SMAPCOEF_32APSK_R2R3 0xf50501f0 +#define FSTV0910_P1_SMAPCOEF_32APSK_R2R3 0xf50541f0 #define FSTV0910_P1_SMAPCOEF_32APSK_LLR2 0xf505010f /* P1_SMAPCOEF1 */ #define RSTV0910_P1_SMAPCOEF1 0xf506 -#define FSTV0910_P1_DIS_16SCALE 0xf5060080 +#define FSTV0910_P1_DIS_16SCALE 0xf5067080 #define FSTV0910_P1_SMAPCOEF_32_LLR34 0xf506017f /* P1_SMAPCOEF0 */ #define RSTV0910_P1_SMAPCOEF0 0xf507 -#define FSTV0910_P1_DIS_32SCALE 0xf5070080 +#define FSTV0910_P1_DIS_32SCALE 0xf5077080 #define FSTV0910_P1_SMAPCOEF_32_LLR15 0xf507017f /* P1_NOSTHRES1 */ @@ -3015,20 +3015,20 @@ /* P1_RAINFADE */ #define RSTV0910_P1_RAINFADE 0xf50c -#define FSTV0910_P1_NOSTHRES_DATAT 0xf50c0080 -#define FSTV0910_P1_RAINFADE_CNLIMIT 0xf50c0070 +#define FSTV0910_P1_NOSTHRES_DATAT 0xf50c7080 +#define FSTV0910_P1_RAINFADE_CNLIMIT 0xf50c4070 #define FSTV0910_P1_RAINFADE_TIMEOUT 0xf50c0007 /* P1_NOSRAMCFG */ #define RSTV0910_P1_NOSRAMCFG 0xf50d -#define FSTV0910_P1_NOSRAM_ACTIVATION 0xf50d0030 -#define FSTV0910_P1_NOSRAM_CNRONLY 0xf50d0008 +#define FSTV0910_P1_NOSRAM_ACTIVATION 0xf50d4030 +#define FSTV0910_P1_NOSRAM_CNRONLY 0xf50d3008 #define FSTV0910_P1_NOSRAM_LGNCNR1 0xf50d0007 /* P1_NOSRAMPOS */ #define RSTV0910_P1_NOSRAMPOS 0xf50e -#define FSTV0910_P1_NOSRAM_LGNCNR0 0xf50e00f0 -#define FSTV0910_P1_NOSRAM_VALIDE 0xf50e0004 +#define FSTV0910_P1_NOSRAM_LGNCNR0 0xf50e40f0 +#define FSTV0910_P1_NOSRAM_VALIDE 0xf50e2004 #define FSTV0910_P1_NOSRAM_CNRVAL1 0xf50e0003 /* P1_NOSRAMVAL */ @@ -3057,16 +3057,16 @@ /* P1_VITSCALE */ #define RSTV0910_P1_VITSCALE 0xf532 -#define FSTV0910_P1_NVTH_NOSRANGE 0xf5320080 -#define FSTV0910_P1_VERROR_MAXMODE 0xf5320040 -#define FSTV0910_P1_NSLOWSN_LOCKED 0xf5320008 -#define FSTV0910_P1_DIS_RSFLOCK 0xf5320002 +#define FSTV0910_P1_NVTH_NOSRANGE 0xf5327080 +#define FSTV0910_P1_VERROR_MAXMODE 0xf5326040 +#define FSTV0910_P1_NSLOWSN_LOCKED 0xf5323008 +#define FSTV0910_P1_DIS_RSFLOCK 0xf5321002 /* P1_FECM */ #define RSTV0910_P1_FECM 0xf533 -#define FSTV0910_P1_DSS_DVB 0xf5330080 -#define FSTV0910_P1_DSS_SRCH 0xf5330010 -#define FSTV0910_P1_SYNCVIT 0xf5330002 +#define FSTV0910_P1_DSS_DVB 0xf5337080 +#define FSTV0910_P1_DSS_SRCH 0xf5334010 +#define FSTV0910_P1_SYNCVIT 0xf5331002 #define FSTV0910_P1_IQINV 0xf5330001 /* P1_VTH12 */ @@ -3103,26 +3103,26 @@ /* P1_PRVIT */ #define RSTV0910_P1_PRVIT 0xf53c -#define FSTV0910_P1_DIS_VTHLOCK 0xf53c0040 -#define FSTV0910_P1_E7_8VIT 0xf53c0020 -#define FSTV0910_P1_E6_7VIT 0xf53c0010 -#define FSTV0910_P1_E5_6VIT 0xf53c0008 -#define FSTV0910_P1_E3_4VIT 0xf53c0004 -#define FSTV0910_P1_E2_3VIT 0xf53c0002 +#define FSTV0910_P1_DIS_VTHLOCK 0xf53c6040 +#define FSTV0910_P1_E7_8VIT 0xf53c5020 +#define FSTV0910_P1_E6_7VIT 0xf53c4010 +#define FSTV0910_P1_E5_6VIT 0xf53c3008 +#define FSTV0910_P1_E3_4VIT 0xf53c2004 +#define FSTV0910_P1_E2_3VIT 0xf53c1002 #define FSTV0910_P1_E1_2VIT 0xf53c0001 /* P1_VAVSRVIT */ #define RSTV0910_P1_VAVSRVIT 0xf53d -#define FSTV0910_P1_AMVIT 0xf53d0080 -#define FSTV0910_P1_FROZENVIT 0xf53d0040 -#define FSTV0910_P1_SNVIT 0xf53d0030 -#define FSTV0910_P1_TOVVIT 0xf53d000c +#define FSTV0910_P1_AMVIT 0xf53d7080 +#define FSTV0910_P1_FROZENVIT 0xf53d6040 +#define FSTV0910_P1_SNVIT 0xf53d4030 +#define FSTV0910_P1_TOVVIT 0xf53d200c #define FSTV0910_P1_HYPVIT 0xf53d0003 /* P1_VSTATUSVIT */ #define RSTV0910_P1_VSTATUSVIT 0xf53e -#define FSTV0910_P1_PRFVIT 0xf53e0010 -#define FSTV0910_P1_LOCKEDVIT 0xf53e0008 +#define FSTV0910_P1_PRFVIT 0xf53e4010 +#define FSTV0910_P1_LOCKEDVIT 0xf53e3008 /* P1_VTHINUSE */ #define RSTV0910_P1_VTHINUSE 0xf53f @@ -3162,32 +3162,32 @@ /* P1_PDELCTRL0 */ #define RSTV0910_P1_PDELCTRL0 0xf54f -#define FSTV0910_P1_ISIOBS_MODE 0xf54f0030 +#define FSTV0910_P1_ISIOBS_MODE 0xf54f4030 /* P1_PDELCTRL1 */ #define RSTV0910_P1_PDELCTRL1 0xf550 -#define FSTV0910_P1_INV_MISMASK 0xf5500080 -#define FSTV0910_P1_FILTER_EN 0xf5500020 -#define FSTV0910_P1_HYSTEN 0xf5500008 -#define FSTV0910_P1_HYSTSWRST 0xf5500004 -#define FSTV0910_P1_EN_MIS00 0xf5500002 +#define FSTV0910_P1_INV_MISMASK 0xf5507080 +#define FSTV0910_P1_FILTER_EN 0xf5505020 +#define FSTV0910_P1_HYSTEN 0xf5503008 +#define FSTV0910_P1_HYSTSWRST 0xf5502004 +#define FSTV0910_P1_EN_MIS00 0xf5501002 #define FSTV0910_P1_ALGOSWRST 0xf5500001 /* P1_PDELCTRL2 */ #define RSTV0910_P1_PDELCTRL2 0xf551 -#define FSTV0910_P1_FORCE_CONTINUOUS 0xf5510080 -#define FSTV0910_P1_RESET_UPKO_COUNT 0xf5510040 -#define FSTV0910_P1_USER_PKTDELIN_NB 0xf5510020 -#define FSTV0910_P1_FRAME_MODE 0xf5510002 +#define FSTV0910_P1_FORCE_CONTINUOUS 0xf5517080 +#define FSTV0910_P1_RESET_UPKO_COUNT 0xf5516040 +#define FSTV0910_P1_USER_PKTDELIN_NB 0xf5515020 +#define FSTV0910_P1_FRAME_MODE 0xf5511002 /* P1_HYSTTHRESH */ #define RSTV0910_P1_HYSTTHRESH 0xf554 -#define FSTV0910_P1_DELIN_LOCKTHRES 0xf55400f0 +#define FSTV0910_P1_DELIN_LOCKTHRES 0xf55440f0 #define FSTV0910_P1_DELIN_UNLOCKTHRES 0xf554000f /* P1_UPLCCST0 */ #define RSTV0910_P1_UPLCCST0 0xf558 -#define FSTV0910_P1_UPL_CST0 0xf55800f8 +#define FSTV0910_P1_UPL_CST0 0xf55830f8 #define FSTV0910_P1_UPL_MODE 0xf5580007 /* P1_ISIENTRY */ @@ -3236,16 +3236,16 @@ /* P1_PDELSTATUS1 */ #define RSTV0910_P1_PDELSTATUS1 0xf569 -#define FSTV0910_P1_PKTDELIN_DELOCK 0xf5690080 -#define FSTV0910_P1_SYNCDUPDFL_BADDFL 0xf5690040 -#define FSTV0910_P1_UNACCEPTED_STREAM 0xf5690010 -#define FSTV0910_P1_BCH_ERROR_FLAG 0xf5690008 -#define FSTV0910_P1_PKTDELIN_LOCK 0xf5690002 +#define FSTV0910_P1_PKTDELIN_DELOCK 0xf5697080 +#define FSTV0910_P1_SYNCDUPDFL_BADDFL 0xf5696040 +#define FSTV0910_P1_UNACCEPTED_STREAM 0xf5694010 +#define FSTV0910_P1_BCH_ERROR_FLAG 0xf5693008 +#define FSTV0910_P1_PKTDELIN_LOCK 0xf5691002 #define FSTV0910_P1_FIRST_LOCK 0xf5690001 /* P1_PDELSTATUS2 */ #define RSTV0910_P1_PDELSTATUS2 0xf56a -#define FSTV0910_P1_FRAME_MODCOD 0xf56a007c +#define FSTV0910_P1_FRAME_MODCOD 0xf56a207c #define FSTV0910_P1_FRAME_TYPE 0xf56a0003 /* P1_BBFCRCKO1 */ @@ -3266,92 +3266,92 @@ /* P1_PDELCTRL3 */ #define RSTV0910_P1_PDELCTRL3 0xf56f -#define FSTV0910_P1_NOFIFO_BCHERR 0xf56f0020 -#define FSTV0910_P1_PKTDELIN_DELACMERR 0xf56f0010 +#define FSTV0910_P1_NOFIFO_BCHERR 0xf56f5020 +#define FSTV0910_P1_PKTDELIN_DELACMERR 0xf56f4010 /* P1_TSSTATEM */ #define RSTV0910_P1_TSSTATEM 0xf570 -#define FSTV0910_P1_TSDIL_ON 0xf5700080 -#define FSTV0910_P1_TSRS_ON 0xf5700020 -#define FSTV0910_P1_TSDESCRAMB_ON 0xf5700010 -#define FSTV0910_P1_TSFRAME_MODE 0xf5700008 -#define FSTV0910_P1_TS_DISABLE 0xf5700004 -#define FSTV0910_P1_TSACM_MODE 0xf5700002 +#define FSTV0910_P1_TSDIL_ON 0xf5707080 +#define FSTV0910_P1_TSRS_ON 0xf5705020 +#define FSTV0910_P1_TSDESCRAMB_ON 0xf5704010 +#define FSTV0910_P1_TSFRAME_MODE 0xf5703008 +#define FSTV0910_P1_TS_DISABLE 0xf5702004 +#define FSTV0910_P1_TSACM_MODE 0xf5701002 #define FSTV0910_P1_TSOUT_NOSYNC 0xf5700001 /* P1_TSSTATEL */ #define RSTV0910_P1_TSSTATEL 0xf571 -#define FSTV0910_P1_TSNOSYNCBYTE 0xf5710080 -#define FSTV0910_P1_TSPARITY_ON 0xf5710040 -#define FSTV0910_P1_TSISSYI_ON 0xf5710008 -#define FSTV0910_P1_TSNPD_ON 0xf5710004 -#define FSTV0910_P1_TSCRC8_ON 0xf5710002 +#define FSTV0910_P1_TSNOSYNCBYTE 0xf5717080 +#define FSTV0910_P1_TSPARITY_ON 0xf5716040 +#define FSTV0910_P1_TSISSYI_ON 0xf5713008 +#define FSTV0910_P1_TSNPD_ON 0xf5712004 +#define FSTV0910_P1_TSCRC8_ON 0xf5711002 #define FSTV0910_P1_TSDSS_PACKET 0xf5710001 /* P1_TSCFGH */ #define RSTV0910_P1_TSCFGH 0xf572 -#define FSTV0910_P1_TSFIFO_DVBCI 0xf5720080 -#define FSTV0910_P1_TSFIFO_SERIAL 0xf5720040 -#define FSTV0910_P1_TSFIFO_TEIUPDATE 0xf5720020 -#define FSTV0910_P1_TSFIFO_DUTY50 0xf5720010 -#define FSTV0910_P1_TSFIFO_HSGNLOUT 0xf5720008 -#define FSTV0910_P1_TSFIFO_ERRMODE 0xf5720006 +#define FSTV0910_P1_TSFIFO_DVBCI 0xf5727080 +#define FSTV0910_P1_TSFIFO_SERIAL 0xf5726040 +#define FSTV0910_P1_TSFIFO_TEIUPDATE 0xf5725020 +#define FSTV0910_P1_TSFIFO_DUTY50 0xf5724010 +#define FSTV0910_P1_TSFIFO_HSGNLOUT 0xf5723008 +#define FSTV0910_P1_TSFIFO_ERRMODE 0xf5721006 #define FSTV0910_P1_RST_HWARE 0xf5720001 /* P1_TSCFGM */ #define RSTV0910_P1_TSCFGM 0xf573 -#define FSTV0910_P1_TSFIFO_MANSPEED 0xf57300c0 -#define FSTV0910_P1_TSFIFO_PERMDATA 0xf5730020 -#define FSTV0910_P1_TSFIFO_NONEWSGNL 0xf5730010 +#define FSTV0910_P1_TSFIFO_MANSPEED 0xf57360c0 +#define FSTV0910_P1_TSFIFO_PERMDATA 0xf5735020 +#define FSTV0910_P1_TSFIFO_NONEWSGNL 0xf5734010 #define FSTV0910_P1_TSFIFO_INVDATA 0xf5730001 /* P1_TSCFGL */ #define RSTV0910_P1_TSCFGL 0xf574 -#define FSTV0910_P1_TSFIFO_BCLKDEL1CK 0xf57400c0 -#define FSTV0910_P1_BCHERROR_MODE 0xf5740030 -#define FSTV0910_P1_TSFIFO_NSGNL2DATA 0xf5740008 -#define FSTV0910_P1_TSFIFO_EMBINDVB 0xf5740004 +#define FSTV0910_P1_TSFIFO_BCLKDEL1CK 0xf57460c0 +#define FSTV0910_P1_BCHERROR_MODE 0xf5744030 +#define FSTV0910_P1_TSFIFO_NSGNL2DATA 0xf5743008 +#define FSTV0910_P1_TSFIFO_EMBINDVB 0xf5742004 #define FSTV0910_P1_TSFIFO_BITSPEED 0xf5740003 /* P1_TSSYNC */ #define RSTV0910_P1_TSSYNC 0xf575 -#define FSTV0910_P1_TSFIFO_SYNCMODE 0xf5750018 +#define FSTV0910_P1_TSFIFO_SYNCMODE 0xf5753018 /* P1_TSINSDELH */ #define RSTV0910_P1_TSINSDELH 0xf576 -#define FSTV0910_P1_TSDEL_SYNCBYTE 0xf5760080 -#define FSTV0910_P1_TSDEL_XXHEADER 0xf5760040 -#define FSTV0910_P1_TSDEL_DATAFIELD 0xf5760010 -#define FSTV0910_P1_TSINSDEL_RSPARITY 0xf5760002 +#define FSTV0910_P1_TSDEL_SYNCBYTE 0xf5767080 +#define FSTV0910_P1_TSDEL_XXHEADER 0xf5766040 +#define FSTV0910_P1_TSDEL_DATAFIELD 0xf5764010 +#define FSTV0910_P1_TSINSDEL_RSPARITY 0xf5761002 #define FSTV0910_P1_TSINSDEL_CRC8 0xf5760001 /* P1_TSINSDELM */ #define RSTV0910_P1_TSINSDELM 0xf577 -#define FSTV0910_P1_TSINS_EMODCOD 0xf5770010 -#define FSTV0910_P1_TSINS_TOKEN 0xf5770008 -#define FSTV0910_P1_TSINS_XXXERR 0xf5770004 -#define FSTV0910_P1_TSINS_MATYPE 0xf5770002 +#define FSTV0910_P1_TSINS_EMODCOD 0xf5774010 +#define FSTV0910_P1_TSINS_TOKEN 0xf5773008 +#define FSTV0910_P1_TSINS_XXXERR 0xf5772004 +#define FSTV0910_P1_TSINS_MATYPE 0xf5771002 #define FSTV0910_P1_TSINS_UPL 0xf5770001 /* P1_TSINSDELL */ #define RSTV0910_P1_TSINSDELL 0xf578 -#define FSTV0910_P1_TSINS_DFL 0xf5780080 -#define FSTV0910_P1_TSINS_SYNCD 0xf5780040 -#define FSTV0910_P1_TSINS_BLOCLEN 0xf5780020 -#define FSTV0910_P1_TSINS_SIGPCOUNT 0xf5780010 -#define FSTV0910_P1_TSINS_FIFO 0xf5780008 -#define FSTV0910_P1_TSINS_REALPACK 0xf5780004 -#define FSTV0910_P1_TSINS_TSCONFIG 0xf5780002 +#define FSTV0910_P1_TSINS_DFL 0xf5787080 +#define FSTV0910_P1_TSINS_SYNCD 0xf5786040 +#define FSTV0910_P1_TSINS_BLOCLEN 0xf5785020 +#define FSTV0910_P1_TSINS_SIGPCOUNT 0xf5784010 +#define FSTV0910_P1_TSINS_FIFO 0xf5783008 +#define FSTV0910_P1_TSINS_REALPACK 0xf5782004 +#define FSTV0910_P1_TSINS_TSCONFIG 0xf5781002 #define FSTV0910_P1_TSINS_LATENCY 0xf5780001 /* P1_TSDIVN */ #define RSTV0910_P1_TSDIVN 0xf579 -#define FSTV0910_P1_TSFIFO_SPEEDMODE 0xf57900c0 +#define FSTV0910_P1_TSFIFO_SPEEDMODE 0xf57960c0 #define FSTV0910_P1_TSFIFO_RISEOK 0xf5790007 /* P1_TSCFG4 */ #define RSTV0910_P1_TSCFG4 0xf57a -#define FSTV0910_P1_TSFIFO_TSSPEEDMODE 0xf57a00c0 +#define FSTV0910_P1_TSFIFO_TSSPEEDMODE 0xf57a60c0 /* P1_TSSPEED */ #define RSTV0910_P1_TSSPEED 0xf580 @@ -3359,18 +3359,18 @@ /* P1_TSSTATUS */ #define RSTV0910_P1_TSSTATUS 0xf581 -#define FSTV0910_P1_TSFIFO_LINEOK 0xf5810080 -#define FSTV0910_P1_TSFIFO_ERROR 0xf5810040 -#define FSTV0910_P1_TSFIFO_NOSYNC 0xf5810010 -#define FSTV0910_P1_TSREGUL_ERROR 0xf5810004 +#define FSTV0910_P1_TSFIFO_LINEOK 0xf5817080 +#define FSTV0910_P1_TSFIFO_ERROR 0xf5816040 +#define FSTV0910_P1_TSFIFO_NOSYNC 0xf5814010 +#define FSTV0910_P1_TSREGUL_ERROR 0xf5812004 #define FSTV0910_P1_DIL_READY 0xf5810001 /* P1_TSSTATUS2 */ #define RSTV0910_P1_TSSTATUS2 0xf582 -#define FSTV0910_P1_TSFIFO_DEMODSEL 0xf5820080 -#define FSTV0910_P1_TSFIFOSPEED_STORE 0xf5820040 -#define FSTV0910_P1_DILXX_RESET 0xf5820020 -#define FSTV0910_P1_SCRAMBDETECT 0xf5820002 +#define FSTV0910_P1_TSFIFO_DEMODSEL 0xf5827080 +#define FSTV0910_P1_TSFIFOSPEED_STORE 0xf5826040 +#define FSTV0910_P1_DILXX_RESET 0xf5825020 +#define FSTV0910_P1_SCRAMBDETECT 0xf5821002 /* P1_TSBITRATE1 */ #define RSTV0910_P1_TSBITRATE1 0xf583 @@ -3382,7 +3382,7 @@ /* P1_TSPACKLEN1 */ #define RSTV0910_P1_TSPACKLEN1 0xf585 -#define FSTV0910_P1_TSFIFO_PACKCPT 0xf58500e0 +#define FSTV0910_P1_TSFIFO_PACKCPT 0xf58550e0 /* P1_TSDLY2 */ #define RSTV0910_P1_TSDLY2 0xf589 @@ -3402,8 +3402,8 @@ /* P1_TSBUFSTAT2 */ #define RSTV0910_P1_TSBUFSTAT2 0xf58d -#define FSTV0910_P1_TSISCR_3BYTES 0xf58d0080 -#define FSTV0910_P1_TSISCR_NEWDATA 0xf58d0040 +#define FSTV0910_P1_TSISCR_3BYTES 0xf58d7080 +#define FSTV0910_P1_TSISCR_NEWDATA 0xf58d6040 #define FSTV0910_P1_TSISCR_BUFSTAT2 0xf58d003f /* P1_TSBUFSTAT1 */ @@ -3416,13 +3416,13 @@ /* P1_TSDEBUGL */ #define RSTV0910_P1_TSDEBUGL 0xf591 -#define FSTV0910_P1_TSFIFO_ERROR_EVNT 0xf5910004 +#define FSTV0910_P1_TSFIFO_ERROR_EVNT 0xf5912004 #define FSTV0910_P1_TSFIFO_OVERFLOWM 0xf5910001 /* P1_TSDLYSET2 */ #define RSTV0910_P1_TSDLYSET2 0xf592 -#define FSTV0910_P1_SOFFIFO_OFFSET 0xf59200c0 -#define FSTV0910_P1_HYSTERESIS_THRESHOLD 0xf5920030 +#define FSTV0910_P1_SOFFIFO_OFFSET 0xf59260c0 +#define FSTV0910_P1_HYSTERESIS_THRESHOLD 0xf5924030 #define FSTV0910_P1_SOFFIFO_SYMBOFFS2 0xf592000f /* P1_TSDLYSET1 */ @@ -3435,12 +3435,12 @@ /* P1_ERRCTRL1 */ #define RSTV0910_P1_ERRCTRL1 0xf598 -#define FSTV0910_P1_ERR_SOURCE1 0xf59800f0 +#define FSTV0910_P1_ERR_SOURCE1 0xf59840f0 #define FSTV0910_P1_NUM_EVENT1 0xf5980007 /* P1_ERRCNT12 */ #define RSTV0910_P1_ERRCNT12 0xf599 -#define FSTV0910_P1_ERRCNT1_OLDVALUE 0xf5990080 +#define FSTV0910_P1_ERRCNT1_OLDVALUE 0xf5997080 #define FSTV0910_P1_ERR_CNT12 0xf599007f /* P1_ERRCNT11 */ @@ -3453,12 +3453,12 @@ /* P1_ERRCTRL2 */ #define RSTV0910_P1_ERRCTRL2 0xf59c -#define FSTV0910_P1_ERR_SOURCE2 0xf59c00f0 +#define FSTV0910_P1_ERR_SOURCE2 0xf59c40f0 #define FSTV0910_P1_NUM_EVENT2 0xf59c0007 /* P1_ERRCNT22 */ #define RSTV0910_P1_ERRCNT22 0xf59d -#define FSTV0910_P1_ERRCNT2_OLDVALUE 0xf59d0080 +#define FSTV0910_P1_ERRCNT2_OLDVALUE 0xf59d7080 #define FSTV0910_P1_ERR_CNT22 0xf59d007f /* P1_ERRCNT21 */ @@ -3471,39 +3471,39 @@ /* P1_FECSPY */ #define RSTV0910_P1_FECSPY 0xf5a0 -#define FSTV0910_P1_SPY_ENABLE 0xf5a00080 -#define FSTV0910_P1_NO_SYNCBYTE 0xf5a00040 -#define FSTV0910_P1_SERIAL_MODE 0xf5a00020 -#define FSTV0910_P1_UNUSUAL_PACKET 0xf5a00010 -#define FSTV0910_P1_BERMETER_DATAMODE 0xf5a0000c -#define FSTV0910_P1_BERMETER_LMODE 0xf5a00002 +#define FSTV0910_P1_SPY_ENABLE 0xf5a07080 +#define FSTV0910_P1_NO_SYNCBYTE 0xf5a06040 +#define FSTV0910_P1_SERIAL_MODE 0xf5a05020 +#define FSTV0910_P1_UNUSUAL_PACKET 0xf5a04010 +#define FSTV0910_P1_BERMETER_DATAMODE 0xf5a0200c +#define FSTV0910_P1_BERMETER_LMODE 0xf5a01002 #define FSTV0910_P1_BERMETER_RESET 0xf5a00001 /* P1_FSPYCFG */ #define RSTV0910_P1_FSPYCFG 0xf5a1 -#define FSTV0910_P1_FECSPY_INPUT 0xf5a100c0 -#define FSTV0910_P1_RST_ON_ERROR 0xf5a10020 -#define FSTV0910_P1_ONE_SHOT 0xf5a10010 -#define FSTV0910_P1_I2C_MODE 0xf5a1000c +#define FSTV0910_P1_FECSPY_INPUT 0xf5a160c0 +#define FSTV0910_P1_RST_ON_ERROR 0xf5a15020 +#define FSTV0910_P1_ONE_SHOT 0xf5a14010 +#define FSTV0910_P1_I2C_MODE 0xf5a1200c #define FSTV0910_P1_SPY_HYSTERESIS 0xf5a10003 /* P1_FSPYDATA */ #define RSTV0910_P1_FSPYDATA 0xf5a2 -#define FSTV0910_P1_SPY_STUFFING 0xf5a20080 -#define FSTV0910_P1_SPY_CNULLPKT 0xf5a20020 +#define FSTV0910_P1_SPY_STUFFING 0xf5a27080 +#define FSTV0910_P1_SPY_CNULLPKT 0xf5a25020 #define FSTV0910_P1_SPY_OUTDATA_MODE 0xf5a2001f /* P1_FSPYOUT */ #define RSTV0910_P1_FSPYOUT 0xf5a3 -#define FSTV0910_P1_FSPY_DIRECT 0xf5a30080 +#define FSTV0910_P1_FSPY_DIRECT 0xf5a37080 #define FSTV0910_P1_STUFF_MODE 0xf5a30007 /* P1_FSTATUS */ #define RSTV0910_P1_FSTATUS 0xf5a4 -#define FSTV0910_P1_SPY_ENDSIM 0xf5a40080 -#define FSTV0910_P1_VALID_SIM 0xf5a40040 -#define FSTV0910_P1_FOUND_SIGNAL 0xf5a40020 -#define FSTV0910_P1_DSS_SYNCBYTE 0xf5a40010 +#define FSTV0910_P1_SPY_ENDSIM 0xf5a47080 +#define FSTV0910_P1_VALID_SIM 0xf5a46040 +#define FSTV0910_P1_FOUND_SIGNAL 0xf5a45020 +#define FSTV0910_P1_DSS_SYNCBYTE 0xf5a44010 #define FSTV0910_P1_RESULT_STATE 0xf5a4000f /* P1_FBERCPT4 */ @@ -3540,8 +3540,8 @@ /* P1_FSPYBER */ #define RSTV0910_P1_FSPYBER 0xf5b2 -#define FSTV0910_P1_FSPYBER_SYNCBYTE 0xf5b20010 -#define FSTV0910_P1_FSPYBER_UNSYNC 0xf5b20008 +#define FSTV0910_P1_FSPYBER_SYNCBYTE 0xf5b24010 +#define FSTV0910_P1_FSPYBER_UNSYNC 0xf5b23008 #define FSTV0910_P1_FSPYBER_CTIME 0xf5b20007 /* P1_SFERROR */ @@ -3550,60 +3550,60 @@ /* P1_SFECSTATUS */ #define RSTV0910_P1_SFECSTATUS 0xf5c3 -#define FSTV0910_P1_SFEC_ON 0xf5c30080 -#define FSTV0910_P1_SFEC_OFF 0xf5c30040 -#define FSTV0910_P1_LOCKEDSFEC 0xf5c30008 -#define FSTV0910_P1_SFEC_DELOCK 0xf5c30004 -#define FSTV0910_P1_SFEC_DEMODSEL 0xf5c30002 +#define FSTV0910_P1_SFEC_ON 0xf5c37080 +#define FSTV0910_P1_SFEC_OFF 0xf5c36040 +#define FSTV0910_P1_LOCKEDSFEC 0xf5c33008 +#define FSTV0910_P1_SFEC_DELOCK 0xf5c32004 +#define FSTV0910_P1_SFEC_DEMODSEL 0xf5c31002 #define FSTV0910_P1_SFEC_OVFON 0xf5c30001 /* P1_SFKDIV12 */ #define RSTV0910_P1_SFKDIV12 0xf5c4 -#define FSTV0910_P1_SFECKDIV12_MAN 0xf5c40080 +#define FSTV0910_P1_SFECKDIV12_MAN 0xf5c47080 /* P1_SFKDIV23 */ #define RSTV0910_P1_SFKDIV23 0xf5c5 -#define FSTV0910_P1_SFECKDIV23_MAN 0xf5c50080 +#define FSTV0910_P1_SFECKDIV23_MAN 0xf5c57080 /* P1_SFKDIV34 */ #define RSTV0910_P1_SFKDIV34 0xf5c6 -#define FSTV0910_P1_SFECKDIV34_MAN 0xf5c60080 +#define FSTV0910_P1_SFECKDIV34_MAN 0xf5c67080 /* P1_SFKDIV56 */ #define RSTV0910_P1_SFKDIV56 0xf5c7 -#define FSTV0910_P1_SFECKDIV56_MAN 0xf5c70080 +#define FSTV0910_P1_SFECKDIV56_MAN 0xf5c77080 /* P1_SFKDIV67 */ #define RSTV0910_P1_SFKDIV67 0xf5c8 -#define FSTV0910_P1_SFECKDIV67_MAN 0xf5c80080 +#define FSTV0910_P1_SFECKDIV67_MAN 0xf5c87080 /* P1_SFKDIV78 */ #define RSTV0910_P1_SFKDIV78 0xf5c9 -#define FSTV0910_P1_SFECKDIV78_MAN 0xf5c90080 +#define FSTV0910_P1_SFECKDIV78_MAN 0xf5c97080 /* P1_SFSTATUS */ #define RSTV0910_P1_SFSTATUS 0xf5cc -#define FSTV0910_P1_SFEC_LINEOK 0xf5cc0080 -#define FSTV0910_P1_SFEC_ERROR 0xf5cc0040 -#define FSTV0910_P1_SFEC_DATA7 0xf5cc0020 -#define FSTV0910_P1_SFEC_PKTDNBRFAIL 0xf5cc0010 -#define FSTV0910_P1_TSSFEC_DEMODSEL 0xf5cc0008 -#define FSTV0910_P1_SFEC_NOSYNC 0xf5cc0004 -#define FSTV0910_P1_SFEC_UNREGULA 0xf5cc0002 +#define FSTV0910_P1_SFEC_LINEOK 0xf5cc7080 +#define FSTV0910_P1_SFEC_ERROR 0xf5cc6040 +#define FSTV0910_P1_SFEC_DATA7 0xf5cc5020 +#define FSTV0910_P1_SFEC_PKTDNBRFAIL 0xf5cc4010 +#define FSTV0910_P1_TSSFEC_DEMODSEL 0xf5cc3008 +#define FSTV0910_P1_SFEC_NOSYNC 0xf5cc2004 +#define FSTV0910_P1_SFEC_UNREGULA 0xf5cc1002 #define FSTV0910_P1_SFEC_READY 0xf5cc0001 /* P1_SFDLYSET2 */ #define RSTV0910_P1_SFDLYSET2 0xf5d0 -#define FSTV0910_P1_SFEC_DISABLE 0xf5d00002 +#define FSTV0910_P1_SFEC_DISABLE 0xf5d01002 /* P1_SFERRCTRL */ #define RSTV0910_P1_SFERRCTRL 0xf5d8 -#define FSTV0910_P1_SFEC_ERR_SOURCE 0xf5d800f0 +#define FSTV0910_P1_SFEC_ERR_SOURCE 0xf5d840f0 #define FSTV0910_P1_SFEC_NUM_EVENT 0xf5d80007 /* P1_SFERRCNT2 */ #define RSTV0910_P1_SFERRCNT2 0xf5d9 -#define FSTV0910_P1_SFERRC_OLDVALUE 0xf5d90080 +#define FSTV0910_P1_SFERRC_OLDVALUE 0xf5d97080 #define FSTV0910_P1_SFEC_ERR_CNT2 0xf5d9007f /* P1_SFERRCNT1 */ @@ -3616,66 +3616,66 @@ /* RCCFG2 */ #define RSTV0910_RCCFG2 0xf600 -#define FSTV0910_TSRCFIFO_DVBCI 0xf6000080 -#define FSTV0910_TSRCFIFO_SERIAL 0xf6000040 -#define FSTV0910_TSRCFIFO_DISABLE 0xf6000020 -#define FSTV0910_TSFIFO_2TORC 0xf6000010 -#define FSTV0910_TSRCFIFO_HSGNLOUT 0xf6000008 -#define FSTV0910_TSRCFIFO_ERRMODE 0xf6000006 +#define FSTV0910_TSRCFIFO_DVBCI 0xf6007080 +#define FSTV0910_TSRCFIFO_SERIAL 0xf6006040 +#define FSTV0910_TSRCFIFO_DISABLE 0xf6005020 +#define FSTV0910_TSFIFO_2TORC 0xf6004010 +#define FSTV0910_TSRCFIFO_HSGNLOUT 0xf6003008 +#define FSTV0910_TSRCFIFO_ERRMODE 0xf6001006 /* RCCFG1 */ #define RSTV0910_RCCFG1 0xf601 -#define FSTV0910_TSRCFIFO_MANSPEED 0xf60100c0 -#define FSTV0910_TSRCFIFO_PERMDATA 0xf6010020 -#define FSTV0910_TSRCFIFO_NONEWSGNL 0xf6010010 +#define FSTV0910_TSRCFIFO_MANSPEED 0xf60160c0 +#define FSTV0910_TSRCFIFO_PERMDATA 0xf6015020 +#define FSTV0910_TSRCFIFO_NONEWSGNL 0xf6014010 #define FSTV0910_TSRCFIFO_INVDATA 0xf6010001 /* RCCFG0 */ #define RSTV0910_RCCFG0 0xf602 -#define FSTV0910_TSRCFIFO_BCLKDEL1CK 0xf60200c0 -#define FSTV0910_TSRCFIFO_DUTY50 0xf6020010 -#define FSTV0910_TSRCFIFO_NSGNL2DATA 0xf6020008 -#define FSTV0910_TSRCFIFO_NPDSGNL 0xf6020004 +#define FSTV0910_TSRCFIFO_BCLKDEL1CK 0xf60260c0 +#define FSTV0910_TSRCFIFO_DUTY50 0xf6024010 +#define FSTV0910_TSRCFIFO_NSGNL2DATA 0xf6023008 +#define FSTV0910_TSRCFIFO_NPDSGNL 0xf6022004 /* RCINSDEL2 */ #define RSTV0910_RCINSDEL2 0xf603 -#define FSTV0910_TSRCDEL_SYNCBYTE 0xf6030080 -#define FSTV0910_TSRCDEL_XXHEADER 0xf6030040 -#define FSTV0910_TSRCDEL_BBHEADER 0xf6030020 -#define FSTV0910_TSRCDEL_DATAFIELD 0xf6030010 -#define FSTV0910_TSRCINSDEL_ISCR 0xf6030008 -#define FSTV0910_TSRCINSDEL_NPD 0xf6030004 -#define FSTV0910_TSRCINSDEL_RSPARITY 0xf6030002 +#define FSTV0910_TSRCDEL_SYNCBYTE 0xf6037080 +#define FSTV0910_TSRCDEL_XXHEADER 0xf6036040 +#define FSTV0910_TSRCDEL_BBHEADER 0xf6035020 +#define FSTV0910_TSRCDEL_DATAFIELD 0xf6034010 +#define FSTV0910_TSRCINSDEL_ISCR 0xf6033008 +#define FSTV0910_TSRCINSDEL_NPD 0xf6032004 +#define FSTV0910_TSRCINSDEL_RSPARITY 0xf6031002 #define FSTV0910_TSRCINSDEL_CRC8 0xf6030001 /* RCINSDEL1 */ #define RSTV0910_RCINSDEL1 0xf604 -#define FSTV0910_TSRCINS_BBPADDING 0xf6040080 -#define FSTV0910_TSRCINS_BCHFEC 0xf6040040 -#define FSTV0910_TSRCINS_EMODCOD 0xf6040010 -#define FSTV0910_TSRCINS_TOKEN 0xf6040008 -#define FSTV0910_TSRCINS_XXXERR 0xf6040004 -#define FSTV0910_TSRCINS_MATYPE 0xf6040002 +#define FSTV0910_TSRCINS_BBPADDING 0xf6047080 +#define FSTV0910_TSRCINS_BCHFEC 0xf6046040 +#define FSTV0910_TSRCINS_EMODCOD 0xf6044010 +#define FSTV0910_TSRCINS_TOKEN 0xf6043008 +#define FSTV0910_TSRCINS_XXXERR 0xf6042004 +#define FSTV0910_TSRCINS_MATYPE 0xf6041002 #define FSTV0910_TSRCINS_UPL 0xf6040001 /* RCINSDEL0 */ #define RSTV0910_RCINSDEL0 0xf605 -#define FSTV0910_TSRCINS_DFL 0xf6050080 -#define FSTV0910_TSRCINS_SYNCD 0xf6050040 -#define FSTV0910_TSRCINS_BLOCLEN 0xf6050020 -#define FSTV0910_TSRCINS_SIGPCOUNT 0xf6050010 -#define FSTV0910_TSRCINS_FIFO 0xf6050008 -#define FSTV0910_TSRCINS_REALPACK 0xf6050004 -#define FSTV0910_TSRCINS_TSCONFIG 0xf6050002 +#define FSTV0910_TSRCINS_DFL 0xf6057080 +#define FSTV0910_TSRCINS_SYNCD 0xf6056040 +#define FSTV0910_TSRCINS_BLOCLEN 0xf6055020 +#define FSTV0910_TSRCINS_SIGPCOUNT 0xf6054010 +#define FSTV0910_TSRCINS_FIFO 0xf6053008 +#define FSTV0910_TSRCINS_REALPACK 0xf6052004 +#define FSTV0910_TSRCINS_TSCONFIG 0xf6051002 #define FSTV0910_TSRCINS_LATENCY 0xf6050001 /* RCSTATUS */ #define RSTV0910_RCSTATUS 0xf606 -#define FSTV0910_TSRCFIFO_LINEOK 0xf6060080 -#define FSTV0910_TSRCFIFO_ERROR 0xf6060040 -#define FSTV0910_TSRCREGUL_ERROR 0xf6060010 -#define FSTV0910_TSRCFIFO_DEMODSEL 0xf6060008 -#define FSTV0910_TSRCFIFOSPEED_STORE 0xf6060004 +#define FSTV0910_TSRCFIFO_LINEOK 0xf6067080 +#define FSTV0910_TSRCFIFO_ERROR 0xf6066040 +#define FSTV0910_TSRCREGUL_ERROR 0xf6064010 +#define FSTV0910_TSRCFIFO_DEMODSEL 0xf6063008 +#define FSTV0910_TSRCFIFOSPEED_STORE 0xf6062004 #define FSTV0910_TSRCSPEED_IMPOSSIBLE 0xf6060001 /* RCSPEED */ @@ -3684,47 +3684,47 @@ /* TSGENERAL */ #define RSTV0910_TSGENERAL 0xf630 -#define FSTV0910_TSFIFO_DISTS2PAR 0xf6300040 -#define FSTV0910_MUXSTREAM_OUTMODE 0xf6300008 -#define FSTV0910_TSFIFO_PERMPARAL 0xf6300006 +#define FSTV0910_TSFIFO_DISTS2PAR 0xf6306040 +#define FSTV0910_MUXSTREAM_OUTMODE 0xf6303008 +#define FSTV0910_TSFIFO_PERMPARAL 0xf6301006 /* P1_DISIRQCFG */ #define RSTV0910_P1_DISIRQCFG 0xf700 -#define FSTV0910_P1_ENRXEND 0xf7000040 -#define FSTV0910_P1_ENRXFIFO8B 0xf7000020 -#define FSTV0910_P1_ENTRFINISH 0xf7000010 -#define FSTV0910_P1_ENTIMEOUT 0xf7000008 -#define FSTV0910_P1_ENTXEND 0xf7000004 -#define FSTV0910_P1_ENTXFIFO64B 0xf7000002 +#define FSTV0910_P1_ENRXEND 0xf7006040 +#define FSTV0910_P1_ENRXFIFO8B 0xf7005020 +#define FSTV0910_P1_ENTRFINISH 0xf7004010 +#define FSTV0910_P1_ENTIMEOUT 0xf7003008 +#define FSTV0910_P1_ENTXEND 0xf7002004 +#define FSTV0910_P1_ENTXFIFO64B 0xf7001002 #define FSTV0910_P1_ENGAPBURST 0xf7000001 /* P1_DISIRQSTAT */ #define RSTV0910_P1_DISIRQSTAT 0xf701 -#define FSTV0910_P1_IRQRXEND 0xf7010040 -#define FSTV0910_P1_IRQRXFIFO8B 0xf7010020 -#define FSTV0910_P1_IRQTRFINISH 0xf7010010 -#define FSTV0910_P1_IRQTIMEOUT 0xf7010008 -#define FSTV0910_P1_IRQTXEND 0xf7010004 -#define FSTV0910_P1_IRQTXFIFO64B 0xf7010002 +#define FSTV0910_P1_IRQRXEND 0xf7016040 +#define FSTV0910_P1_IRQRXFIFO8B 0xf7015020 +#define FSTV0910_P1_IRQTRFINISH 0xf7014010 +#define FSTV0910_P1_IRQTIMEOUT 0xf7013008 +#define FSTV0910_P1_IRQTXEND 0xf7012004 +#define FSTV0910_P1_IRQTXFIFO64B 0xf7011002 #define FSTV0910_P1_IRQGAPBURST 0xf7010001 /* P1_DISTXCFG */ #define RSTV0910_P1_DISTXCFG 0xf702 -#define FSTV0910_P1_DISTX_RESET 0xf7020080 -#define FSTV0910_P1_TIM_OFF 0xf7020040 -#define FSTV0910_P1_TIM_CMD 0xf7020030 -#define FSTV0910_P1_ENVELOP 0xf7020008 -#define FSTV0910_P1_DIS_PRECHARGE 0xf7020004 +#define FSTV0910_P1_DISTX_RESET 0xf7027080 +#define FSTV0910_P1_TIM_OFF 0xf7026040 +#define FSTV0910_P1_TIM_CMD 0xf7024030 +#define FSTV0910_P1_ENVELOP 0xf7023008 +#define FSTV0910_P1_DIS_PRECHARGE 0xf7022004 #define FSTV0910_P1_DISEQC_MODE 0xf7020003 /* P1_DISTXSTATUS */ #define RSTV0910_P1_DISTXSTATUS 0xf703 -#define FSTV0910_P1_TX_FIFO_FULL 0xf7030040 -#define FSTV0910_P1_TX_IDLE 0xf7030020 -#define FSTV0910_P1_GAP_BURST 0xf7030010 -#define FSTV0910_P1_TX_FIFO64B 0xf7030008 -#define FSTV0910_P1_TX_END 0xf7030004 -#define FSTV0910_P1_TR_TIMEOUT 0xf7030002 +#define FSTV0910_P1_TX_FIFO_FULL 0xf7036040 +#define FSTV0910_P1_TX_IDLE 0xf7035020 +#define FSTV0910_P1_GAP_BURST 0xf7034010 +#define FSTV0910_P1_TX_FIFO64B 0xf7033008 +#define FSTV0910_P1_TX_END 0xf7032004 +#define FSTV0910_P1_TR_TIMEOUT 0xf7031002 #define FSTV0910_P1_TR_FINISH 0xf7030001 /* P1_DISTXBYTES */ @@ -3741,7 +3741,7 @@ /* P1_DISTIMEOCFG */ #define RSTV0910_P1_DISTIMEOCFG 0xf708 -#define FSTV0910_P1_RXCHOICE 0xf7080006 +#define FSTV0910_P1_RXCHOICE 0xf7081006 #define FSTV0910_P1_TIMEOUT_OFF 0xf7080001 /* P1_DISTIMEOUT */ @@ -3750,30 +3750,30 @@ /* P1_DISRXCFG */ #define RSTV0910_P1_DISRXCFG 0xf70a -#define FSTV0910_P1_DISRX_RESET 0xf70a0080 -#define FSTV0910_P1_EXTENVELOP 0xf70a0040 -#define FSTV0910_P1_PINSELECT 0xf70a0038 -#define FSTV0910_P1_IGNORE_SHORT22K 0xf70a0004 -#define FSTV0910_P1_SIGNED_RXIN 0xf70a0002 +#define FSTV0910_P1_DISRX_RESET 0xf70a7080 +#define FSTV0910_P1_EXTENVELOP 0xf70a6040 +#define FSTV0910_P1_PINSELECT 0xf70a3038 +#define FSTV0910_P1_IGNORE_SHORT22K 0xf70a2004 +#define FSTV0910_P1_SIGNED_RXIN 0xf70a1002 #define FSTV0910_P1_DISRX_ON 0xf70a0001 /* P1_DISRXSTAT1 */ #define RSTV0910_P1_DISRXSTAT1 0xf70b -#define FSTV0910_P1_RXEND 0xf70b0080 -#define FSTV0910_P1_RXACTIVE 0xf70b0040 -#define FSTV0910_P1_RXDETECT 0xf70b0020 -#define FSTV0910_P1_CONTTONE 0xf70b0010 -#define FSTV0910_P1_8BFIFOREADY 0xf70b0008 -#define FSTV0910_P1_FIFOEMPTY 0xf70b0004 +#define FSTV0910_P1_RXEND 0xf70b7080 +#define FSTV0910_P1_RXACTIVE 0xf70b6040 +#define FSTV0910_P1_RXDETECT 0xf70b5020 +#define FSTV0910_P1_CONTTONE 0xf70b4010 +#define FSTV0910_P1_8BFIFOREADY 0xf70b3008 +#define FSTV0910_P1_FIFOEMPTY 0xf70b2004 /* P1_DISRXSTAT0 */ #define RSTV0910_P1_DISRXSTAT0 0xf70c -#define FSTV0910_P1_RXFAIL 0xf70c0080 -#define FSTV0910_P1_FIFOPFAIL 0xf70c0040 -#define FSTV0910_P1_RXNONBYTE 0xf70c0020 -#define FSTV0910_P1_FIFOOVF 0xf70c0010 -#define FSTV0910_P1_SHORT22K 0xf70c0008 -#define FSTV0910_P1_RXMSGLOST 0xf70c0004 +#define FSTV0910_P1_RXFAIL 0xf70c7080 +#define FSTV0910_P1_FIFOPFAIL 0xf70c6040 +#define FSTV0910_P1_RXNONBYTE 0xf70c5020 +#define FSTV0910_P1_FIFOOVF 0xf70c4010 +#define FSTV0910_P1_SHORT22K 0xf70c3008 +#define FSTV0910_P1_RXMSGLOST 0xf70c2004 /* P1_DISRXBYTES */ #define RSTV0910_P1_DISRXBYTES 0xf70d @@ -3825,41 +3825,41 @@ /* P2_DISIRQCFG */ #define RSTV0910_P2_DISIRQCFG 0xf740 -#define FSTV0910_P2_ENRXEND 0xf7400040 -#define FSTV0910_P2_ENRXFIFO8B 0xf7400020 -#define FSTV0910_P2_ENTRFINISH 0xf7400010 -#define FSTV0910_P2_ENTIMEOUT 0xf7400008 -#define FSTV0910_P2_ENTXEND 0xf7400004 -#define FSTV0910_P2_ENTXFIFO64B 0xf7400002 +#define FSTV0910_P2_ENRXEND 0xf7406040 +#define FSTV0910_P2_ENRXFIFO8B 0xf7405020 +#define FSTV0910_P2_ENTRFINISH 0xf7404010 +#define FSTV0910_P2_ENTIMEOUT 0xf7403008 +#define FSTV0910_P2_ENTXEND 0xf7402004 +#define FSTV0910_P2_ENTXFIFO64B 0xf7401002 #define FSTV0910_P2_ENGAPBURST 0xf7400001 /* P2_DISIRQSTAT */ #define RSTV0910_P2_DISIRQSTAT 0xf741 -#define FSTV0910_P2_IRQRXEND 0xf7410040 -#define FSTV0910_P2_IRQRXFIFO8B 0xf7410020 -#define FSTV0910_P2_IRQTRFINISH 0xf7410010 -#define FSTV0910_P2_IRQTIMEOUT 0xf7410008 -#define FSTV0910_P2_IRQTXEND 0xf7410004 -#define FSTV0910_P2_IRQTXFIFO64B 0xf7410002 +#define FSTV0910_P2_IRQRXEND 0xf7416040 +#define FSTV0910_P2_IRQRXFIFO8B 0xf7415020 +#define FSTV0910_P2_IRQTRFINISH 0xf7414010 +#define FSTV0910_P2_IRQTIMEOUT 0xf7413008 +#define FSTV0910_P2_IRQTXEND 0xf7412004 +#define FSTV0910_P2_IRQTXFIFO64B 0xf7411002 #define FSTV0910_P2_IRQGAPBURST 0xf7410001 /* P2_DISTXCFG */ #define RSTV0910_P2_DISTXCFG 0xf742 -#define FSTV0910_P2_DISTX_RESET 0xf7420080 -#define FSTV0910_P2_TIM_OFF 0xf7420040 -#define FSTV0910_P2_TIM_CMD 0xf7420030 -#define FSTV0910_P2_ENVELOP 0xf7420008 -#define FSTV0910_P2_DIS_PRECHARGE 0xf7420004 +#define FSTV0910_P2_DISTX_RESET 0xf7427080 +#define FSTV0910_P2_TIM_OFF 0xf7426040 +#define FSTV0910_P2_TIM_CMD 0xf7424030 +#define FSTV0910_P2_ENVELOP 0xf7423008 +#define FSTV0910_P2_DIS_PRECHARGE 0xf7422004 #define FSTV0910_P2_DISEQC_MODE 0xf7420003 /* P2_DISTXSTATUS */ #define RSTV0910_P2_DISTXSTATUS 0xf743 -#define FSTV0910_P2_TX_FIFO_FULL 0xf7430040 -#define FSTV0910_P2_TX_IDLE 0xf7430020 -#define FSTV0910_P2_GAP_BURST 0xf7430010 -#define FSTV0910_P2_TX_FIFO64B 0xf7430008 -#define FSTV0910_P2_TX_END 0xf7430004 -#define FSTV0910_P2_TR_TIMEOUT 0xf7430002 +#define FSTV0910_P2_TX_FIFO_FULL 0xf7436040 +#define FSTV0910_P2_TX_IDLE 0xf7435020 +#define FSTV0910_P2_GAP_BURST 0xf7434010 +#define FSTV0910_P2_TX_FIFO64B 0xf7433008 +#define FSTV0910_P2_TX_END 0xf7432004 +#define FSTV0910_P2_TR_TIMEOUT 0xf7431002 #define FSTV0910_P2_TR_FINISH 0xf7430001 /* P2_DISTXBYTES */ @@ -3876,7 +3876,7 @@ /* P2_DISTIMEOCFG */ #define RSTV0910_P2_DISTIMEOCFG 0xf748 -#define FSTV0910_P2_RXCHOICE 0xf7480006 +#define FSTV0910_P2_RXCHOICE 0xf7481006 #define FSTV0910_P2_TIMEOUT_OFF 0xf7480001 /* P2_DISTIMEOUT */ @@ -3885,30 +3885,30 @@ /* P2_DISRXCFG */ #define RSTV0910_P2_DISRXCFG 0xf74a -#define FSTV0910_P2_DISRX_RESET 0xf74a0080 -#define FSTV0910_P2_EXTENVELOP 0xf74a0040 -#define FSTV0910_P2_PINSELECT 0xf74a0038 -#define FSTV0910_P2_IGNORE_SHORT22K 0xf74a0004 -#define FSTV0910_P2_SIGNED_RXIN 0xf74a0002 +#define FSTV0910_P2_DISRX_RESET 0xf74a7080 +#define FSTV0910_P2_EXTENVELOP 0xf74a6040 +#define FSTV0910_P2_PINSELECT 0xf74a3038 +#define FSTV0910_P2_IGNORE_SHORT22K 0xf74a2004 +#define FSTV0910_P2_SIGNED_RXIN 0xf74a1002 #define FSTV0910_P2_DISRX_ON 0xf74a0001 /* P2_DISRXSTAT1 */ #define RSTV0910_P2_DISRXSTAT1 0xf74b -#define FSTV0910_P2_RXEND 0xf74b0080 -#define FSTV0910_P2_RXACTIVE 0xf74b0040 -#define FSTV0910_P2_RXDETECT 0xf74b0020 -#define FSTV0910_P2_CONTTONE 0xf74b0010 -#define FSTV0910_P2_8BFIFOREADY 0xf74b0008 -#define FSTV0910_P2_FIFOEMPTY 0xf74b0004 +#define FSTV0910_P2_RXEND 0xf74b7080 +#define FSTV0910_P2_RXACTIVE 0xf74b6040 +#define FSTV0910_P2_RXDETECT 0xf74b5020 +#define FSTV0910_P2_CONTTONE 0xf74b4010 +#define FSTV0910_P2_8BFIFOREADY 0xf74b3008 +#define FSTV0910_P2_FIFOEMPTY 0xf74b2004 /* P2_DISRXSTAT0 */ #define RSTV0910_P2_DISRXSTAT0 0xf74c -#define FSTV0910_P2_RXFAIL 0xf74c0080 -#define FSTV0910_P2_FIFOPFAIL 0xf74c0040 -#define FSTV0910_P2_RXNONBYTE 0xf74c0020 -#define FSTV0910_P2_FIFOOVF 0xf74c0010 -#define FSTV0910_P2_SHORT22K 0xf74c0008 -#define FSTV0910_P2_RXMSGLOST 0xf74c0004 +#define FSTV0910_P2_RXFAIL 0xf74c7080 +#define FSTV0910_P2_FIFOPFAIL 0xf74c6040 +#define FSTV0910_P2_RXNONBYTE 0xf74c5020 +#define FSTV0910_P2_FIFOOVF 0xf74c4010 +#define FSTV0910_P2_SHORT22K 0xf74c3008 +#define FSTV0910_P2_RXMSGLOST 0xf74c2004 /* P2_DISRXBYTES */ #define RSTV0910_P2_DISRXBYTES 0xf74d @@ -4168,75 +4168,75 @@ /* SELSATUR6 */ #define RSTV0910_SELSATUR6 0xfa34 -#define FSTV0910_SSAT_SF27 0xfa340008 -#define FSTV0910_SSAT_SF26 0xfa340004 -#define FSTV0910_SSAT_SF25 0xfa340002 +#define FSTV0910_SSAT_SF27 0xfa343008 +#define FSTV0910_SSAT_SF26 0xfa342004 +#define FSTV0910_SSAT_SF25 0xfa341002 #define FSTV0910_SSAT_SF24 0xfa340001 /* SELSATUR5 */ #define RSTV0910_SELSATUR5 0xfa35 -#define FSTV0910_SSAT_SF22 0xfa350080 -#define FSTV0910_SSAT_SF21 0xfa350040 -#define FSTV0910_SSAT_SF20 0xfa350020 -#define FSTV0910_SSAT_SF19 0xfa350010 -#define FSTV0910_SSAT_SF18 0xfa350008 -#define FSTV0910_SSAT_SF16 0xfa350004 -#define FSTV0910_SSAT_SF15 0xfa350002 +#define FSTV0910_SSAT_SF22 0xfa357080 +#define FSTV0910_SSAT_SF21 0xfa356040 +#define FSTV0910_SSAT_SF20 0xfa355020 +#define FSTV0910_SSAT_SF19 0xfa354010 +#define FSTV0910_SSAT_SF18 0xfa353008 +#define FSTV0910_SSAT_SF16 0xfa352004 +#define FSTV0910_SSAT_SF15 0xfa351002 #define FSTV0910_SSAT_SF14 0xfa350001 /* SELSATUR4 */ #define RSTV0910_SELSATUR4 0xfa36 -#define FSTV0910_SSAT_SF13 0xfa360080 -#define FSTV0910_SSAT_SF12 0xfa360040 -#define FSTV0910_SSAT_SF10 0xfa360020 -#define FSTV0910_SSAT_SF9 0xfa360010 -#define FSTV0910_SSAT_SF8 0xfa360008 -#define FSTV0910_SSAT_SF7 0xfa360004 -#define FSTV0910_SSAT_SF6 0xfa360002 +#define FSTV0910_SSAT_SF13 0xfa367080 +#define FSTV0910_SSAT_SF12 0xfa366040 +#define FSTV0910_SSAT_SF10 0xfa365020 +#define FSTV0910_SSAT_SF9 0xfa364010 +#define FSTV0910_SSAT_SF8 0xfa363008 +#define FSTV0910_SSAT_SF7 0xfa362004 +#define FSTV0910_SSAT_SF6 0xfa361002 #define FSTV0910_SSAT_SF5 0xfa360001 /* SELSATUR3 */ #define RSTV0910_SELSATUR3 0xfa37 -#define FSTV0910_SSAT_SF4 0xfa370080 -#define FSTV0910_SSAT_SF3 0xfa370040 -#define FSTV0910_SSAT_SF2 0xfa370020 -#define FSTV0910_SSAT_SF1 0xfa370010 -#define FSTV0910_SSAT_NF28 0xfa370008 -#define FSTV0910_SSAT_NF27 0xfa370004 -#define FSTV0910_SSAT_NF26 0xfa370002 +#define FSTV0910_SSAT_SF4 0xfa377080 +#define FSTV0910_SSAT_SF3 0xfa376040 +#define FSTV0910_SSAT_SF2 0xfa375020 +#define FSTV0910_SSAT_SF1 0xfa374010 +#define FSTV0910_SSAT_NF28 0xfa373008 +#define FSTV0910_SSAT_NF27 0xfa372004 +#define FSTV0910_SSAT_NF26 0xfa371002 #define FSTV0910_SSAT_NF25 0xfa370001 /* SELSATUR2 */ #define RSTV0910_SELSATUR2 0xfa38 -#define FSTV0910_SSAT_NF24 0xfa380080 -#define FSTV0910_SSAT_NF23 0xfa380040 -#define FSTV0910_SSAT_NF22 0xfa380020 -#define FSTV0910_SSAT_NF21 0xfa380010 -#define FSTV0910_SSAT_NF20 0xfa380008 -#define FSTV0910_SSAT_NF19 0xfa380004 -#define FSTV0910_SSAT_NF18 0xfa380002 +#define FSTV0910_SSAT_NF24 0xfa387080 +#define FSTV0910_SSAT_NF23 0xfa386040 +#define FSTV0910_SSAT_NF22 0xfa385020 +#define FSTV0910_SSAT_NF21 0xfa384010 +#define FSTV0910_SSAT_NF20 0xfa383008 +#define FSTV0910_SSAT_NF19 0xfa382004 +#define FSTV0910_SSAT_NF18 0xfa381002 #define FSTV0910_SSAT_NF17 0xfa380001 /* SELSATUR1 */ #define RSTV0910_SELSATUR1 0xfa39 -#define FSTV0910_SSAT_NF16 0xfa390080 -#define FSTV0910_SSAT_NF15 0xfa390040 -#define FSTV0910_SSAT_NF14 0xfa390020 -#define FSTV0910_SSAT_NF13 0xfa390010 -#define FSTV0910_SSAT_NF12 0xfa390008 -#define FSTV0910_SSAT_NF11 0xfa390004 -#define FSTV0910_SSAT_NF10 0xfa390002 +#define FSTV0910_SSAT_NF16 0xfa397080 +#define FSTV0910_SSAT_NF15 0xfa396040 +#define FSTV0910_SSAT_NF14 0xfa395020 +#define FSTV0910_SSAT_NF13 0xfa394010 +#define FSTV0910_SSAT_NF12 0xfa393008 +#define FSTV0910_SSAT_NF11 0xfa392004 +#define FSTV0910_SSAT_NF10 0xfa391002 #define FSTV0910_SSAT_NF9 0xfa390001 /* SELSATUR0 */ #define RSTV0910_SELSATUR0 0xfa3a -#define FSTV0910_SSAT_NF8 0xfa3a0080 -#define FSTV0910_SSAT_NF7 0xfa3a0040 -#define FSTV0910_SSAT_NF6 0xfa3a0020 -#define FSTV0910_SSAT_NF5 0xfa3a0010 -#define FSTV0910_SSAT_NF4 0xfa3a0008 -#define FSTV0910_SSAT_NF3 0xfa3a0004 -#define FSTV0910_SSAT_NF2 0xfa3a0002 +#define FSTV0910_SSAT_NF8 0xfa3a7080 +#define FSTV0910_SSAT_NF7 0xfa3a6040 +#define FSTV0910_SSAT_NF6 0xfa3a5020 +#define FSTV0910_SSAT_NF5 0xfa3a4010 +#define FSTV0910_SSAT_NF4 0xfa3a3008 +#define FSTV0910_SSAT_NF3 0xfa3a2004 +#define FSTV0910_SSAT_NF2 0xfa3a1002 #define FSTV0910_SSAT_NF1 0xfa3a0001 /* GAINLLR_NF1 */ @@ -4449,14 +4449,14 @@ /* CFGEXT */ #define RSTV0910_CFGEXT 0xfa80 -#define FSTV0910_BYPBCH 0xfa800040 -#define FSTV0910_BYPLDPC 0xfa800020 -#define FSTV0910_SHORTMULT 0xfa800004 +#define FSTV0910_BYPBCH 0xfa806040 +#define FSTV0910_BYPLDPC 0xfa805020 +#define FSTV0910_SHORTMULT 0xfa802004 /* GENCFG */ #define RSTV0910_GENCFG 0xfa86 -#define FSTV0910_BROADCAST 0xfa860010 -#define FSTV0910_CROSSINPUT 0xfa860002 +#define FSTV0910_BROADCAST 0xfa864010 +#define FSTV0910_CROSSINPUT 0xfa861002 #define FSTV0910_DDEMOD 0xfa860001 /* LDPCERR1 */ @@ -4469,7 +4469,7 @@ /* BCHERR */ #define RSTV0910_BCHERR 0xfa98 -#define FSTV0910_ERRORFLAG 0xfa980010 +#define FSTV0910_ERRORFLAG 0xfa984010 #define FSTV0910_BCH_ERRORS_COUNTER 0xfa98000f /* P1_MAXEXTRAITER */ @@ -4706,22 +4706,22 @@ /* TSTRES0 */ #define RSTV0910_TSTRES0 0xff11 -#define FSTV0910_FRESFEC 0xff110080 -#define FSTV0910_FRESSYM1 0xff110008 -#define FSTV0910_FRESSYM2 0xff110004 +#define FSTV0910_FRESFEC 0xff117080 +#define FSTV0910_FRESSYM1 0xff113008 +#define FSTV0910_FRESSYM2 0xff112004 /* TSTOUT */ #define RSTV0910_TSTOUT 0xff12 -#define FSTV0910_TS 0xff12003e +#define FSTV0910_TS 0xff12103e #define FSTV0910_TEST_OUT 0xff120001 /* TSTIN */ #define RSTV0910_TSTIN 0xff13 -#define FSTV0910_TEST_IN 0xff130080 +#define FSTV0910_TEST_IN 0xff137080 /* P2_TSTDMD */ #define RSTV0910_P2_TSTDMD 0xff20 -#define FSTV0910_P2_CFRINIT_INVZIGZAG 0xff200008 +#define FSTV0910_P2_CFRINIT_INVZIGZAG 0xff203008 /* P2_TCTL1 */ #define RSTV0910_P2_TCTL1 0xff24 @@ -4729,15 +4729,15 @@ /* P2_TCTL4 */ #define RSTV0910_P2_TCTL4 0xff28 -#define FSTV0910_P2_CFR2TOCFR1_DVBS1 0xff2800c0 +#define FSTV0910_P2_CFR2TOCFR1_DVBS1 0xff2860c0 /* P2_TPKTDELIN */ #define RSTV0910_P2_TPKTDELIN 0xff37 -#define FSTV0910_P2_CFG_RSPARITYON 0xff370080 +#define FSTV0910_P2_CFG_RSPARITYON 0xff377080 /* P1_TSTDMD */ #define RSTV0910_P1_TSTDMD 0xff40 -#define FSTV0910_P1_CFRINIT_INVZIGZAG 0xff400008 +#define FSTV0910_P1_CFRINIT_INVZIGZAG 0xff403008 /* P1_TCTL1 */ #define RSTV0910_P1_TCTL1 0xff44 @@ -4745,16 +4745,16 @@ /* P1_TCTL4 */ #define RSTV0910_P1_TCTL4 0xff48 -#define FSTV0910_P1_CFR2TOCFR1_DVBS1 0xff4800c0 +#define FSTV0910_P1_CFR2TOCFR1_DVBS1 0xff4860c0 /* P1_TPKTDELIN */ #define RSTV0910_P1_TPKTDELIN 0xff57 -#define FSTV0910_P1_CFG_RSPARITYON 0xff570080 +#define FSTV0910_P1_CFG_RSPARITYON 0xff577080 /* TSTTSRS */ #define RSTV0910_TSTTSRS 0xff6d -#define FSTV0910_TSTRS_DISRS2 0xff6d0002 +#define FSTV0910_TSTRS_DISRS2 0xff6d1002 #define FSTV0910_TSTRS_DISRS1 0xff6d0001 -#define STV0910_NBREGS 975 -#define STV0910_NBFIELDS 1818 +#define STV0910_NBREGS 975 +#define STV0910_NBFIELDS 1818 -- GitLab From aea16005f4081a745c2178e6e4e5825c01a6226e Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:04 -0500 Subject: [PATCH 0167/1190] media: dvb-frontends/stv0910: WARN_ON() on consecutive mutex_unlock() Stack dump when gate_ctrl() is called in a way that consecutive unlocks happen. This is a clear indication that other drivers interfacing with the stv0910 driver don't do things properly or don't check for failures, so dump stack so that those drivers can be identified and fixed. Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 73f6df0abbfe1..4b7e901220e4d 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -1241,7 +1241,8 @@ static int gate_ctrl(struct dvb_frontend *fe, int enable) if (write_reg(state, state->nr ? RSTV0910_P2_I2CRPT : RSTV0910_P1_I2CRPT, i2crpt) < 0) { /* don't hold the I2C bus lock on failure */ - mutex_unlock(&state->base->i2c_lock); + if (!WARN_ON(!mutex_is_locked(&state->base->i2c_lock))) + mutex_unlock(&state->base->i2c_lock); dev_err(&state->base->i2c->dev, "%s() write_reg failure (enable=%d)\n", __func__, enable); @@ -1251,7 +1252,8 @@ static int gate_ctrl(struct dvb_frontend *fe, int enable) state->i2crpt = i2crpt; if (!enable) - mutex_unlock(&state->base->i2c_lock); + if (!WARN_ON(!mutex_is_locked(&state->base->i2c_lock))) + mutex_unlock(&state->base->i2c_lock); return 0; } -- GitLab From fd7849d7d8a48bf017b058b7852b524ec4cd38af Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:05 -0500 Subject: [PATCH 0168/1190] media: dvb-frontends/stv6111: handle gate_ctrl errors When a parent (demod) driver encounters and signals a problem with gate_ctrl(), don't blindly continue poking the I2C bus. Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv6111.c | 44 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/media/dvb-frontends/stv6111.c b/drivers/media/dvb-frontends/stv6111.c index e3e90070e2933..789f7b61e628a 100644 --- a/drivers/media/dvb-frontends/stv6111.c +++ b/drivers/media/dvb-frontends/stv6111.c @@ -424,6 +424,7 @@ static int set_bandwidth(struct dvb_frontend *fe, u32 cutoff_frequency) { struct stv *state = fe->tuner_priv; u32 index = (cutoff_frequency + 999999) / 1000000; + int stat = 0; if (index < 6) index = 6; @@ -435,12 +436,14 @@ static int set_bandwidth(struct dvb_frontend *fe, u32 cutoff_frequency) state->reg[0x08] = (state->reg[0x08] & ~0xFC) | ((index - 6) << 2); state->reg[0x09] = (state->reg[0x09] & ~0x0C) | 0x08; if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - write_regs(state, 0x08, 2); - wait_for_call_done(state, 0x08); - if (fe->ops.i2c_gate_ctrl) + stat = fe->ops.i2c_gate_ctrl(fe, 1); + if (!stat) { + write_regs(state, 0x08, 2); + wait_for_call_done(state, 0x08); + } + if (fe->ops.i2c_gate_ctrl && !stat) fe->ops.i2c_gate_ctrl(fe, 0); - return 0; + return stat; } static int set_lof(struct stv *state, u32 local_frequency, u32 cutoff_frequency) @@ -518,6 +521,7 @@ static int set_params(struct dvb_frontend *fe) struct stv *state = fe->tuner_priv; struct dtv_frontend_properties *p = &fe->dtv_property_cache; u32 freq, cutoff; + int stat = 0; if (p->delivery_system != SYS_DVBS && p->delivery_system != SYS_DVBS2) return -EINVAL; @@ -526,9 +530,10 @@ static int set_params(struct dvb_frontend *fe) cutoff = 5000000 + muldiv32(p->symbol_rate, 135, 200); if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - set_lof(state, freq, cutoff); - if (fe->ops.i2c_gate_ctrl) + stat = fe->ops.i2c_gate_ctrl(fe, 1); + if (!stat) + set_lof(state, freq, cutoff); + if (fe->ops.i2c_gate_ctrl && !stat) fe->ops.i2c_gate_ctrl(fe, 0); return 0; } @@ -575,14 +580,17 @@ static int get_rf_strength(struct dvb_frontend *fe, u16 *st) if ((state->reg[0x03] & 0x60) == 0) { /* RF Mode, Read AGC ADC */ u8 reg = 0; + int stat = 0; if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - write_reg(state, 0x02, state->reg[0x02] | 0x20); - read_reg(state, 2, ®); - if (reg & 0x20) + stat = fe->ops.i2c_gate_ctrl(fe, 1); + if (!stat) { + write_reg(state, 0x02, state->reg[0x02] | 0x20); read_reg(state, 2, ®); - if (fe->ops.i2c_gate_ctrl) + if (reg & 0x20) + read_reg(state, 2, ®); + } + if (fe->ops.i2c_gate_ctrl && !stat) fe->ops.i2c_gate_ctrl(fe, 0); if ((state->reg[0x02] & 0x80) == 0) @@ -652,7 +660,8 @@ struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 adr) { struct stv *state; - int stat; + int stat = -ENODEV; + int gatestat = 0; state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) @@ -663,9 +672,10 @@ struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe, init_state(state); if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - stat = attach_init(state); - if (fe->ops.i2c_gate_ctrl) + gatestat = fe->ops.i2c_gate_ctrl(fe, 1); + if (!gatestat) + stat = attach_init(state); + if (fe->ops.i2c_gate_ctrl && !gatestat) fe->ops.i2c_gate_ctrl(fe, 0); if (stat < 0) { kfree(state); -- GitLab From 471dd695dcc04aca77aa1ad5b81a93fed8dbb7fd Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:06 -0500 Subject: [PATCH 0169/1190] media: dvb-frontends/stv0910: remove unneeded check/call to get_if_freq The result (if any) isn't used anywhere besides being assigned to a local variable (and the only current companion stv6111 doesn't even implement get_if_frequency()), thus remove the ptr check and the call, and also remove the now unused iffreq variable. Reported-by: Richard Scobie Cc: Ralph Metzler Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 4b7e901220e4d..299dd3533720d 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -1273,14 +1273,11 @@ static int set_parameters(struct dvb_frontend *fe) { int stat = 0; struct stv *state = fe->demodulator_priv; - u32 iffreq; struct dtv_frontend_properties *p = &fe->dtv_property_cache; stop(state); if (fe->ops.tuner_ops.set_params) fe->ops.tuner_ops.set_params(fe); - if (fe->ops.tuner_ops.get_if_frequency) - fe->ops.tuner_ops.get_if_frequency(fe, &iffreq); state->symbol_rate = p->symbol_rate; stat = start(state, p); return stat; -- GitLab From 0b885ded9c6a9d991d217a8dacca45141cb46825 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:07 -0500 Subject: [PATCH 0170/1190] media: dvb-frontends/stv0910: read symbolrate in get_frontend() Utilise get_cur_symbol_rate() in get_frontend() to update the dtv_frontend_properties with the current symbol rate as reported by the demodulator. Reported-by: Richard Scobie Cc: Ralph Metzler Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 299dd3533720d..55cddd01f779f 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -1539,6 +1539,7 @@ static int get_frontend(struct dvb_frontend *fe, { struct stv *state = fe->demodulator_priv; u8 tmp; + u32 symbolrate; if (state->receive_mode == RCVMODE_DVBS2) { u32 mc; @@ -1592,6 +1593,10 @@ static int get_frontend(struct dvb_frontend *fe, p->rolloff = ROLLOFF_35; } + if (state->receive_mode != RCVMODE_NONE) { + get_cur_symbol_rate(state, &symbolrate); + p->symbol_rate = symbolrate; + } return 0; } -- GitLab From 5dd70f5a6a2dacf501d8b16f714455d3a35b1b11 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:08 -0500 Subject: [PATCH 0171/1190] media: dvb-frontends/stv0910: remove unneeded symbol rate inquiry tracking_optimization() doesn't make use of the symbol rate reported by the demodulator, so remove the unneeded inquiry and the now unneeded variable. Reported-by: Richard Scobie Cc: Ralph Metzler Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 55cddd01f779f..681349a5aea8f 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -533,10 +533,8 @@ static int get_signal_parameters(struct stv *state) static int tracking_optimization(struct stv *state) { - u32 symbol_rate = 0; u8 tmp; - get_cur_symbol_rate(state, &symbol_rate); read_reg(state, RSTV0910_P2_DMDCFGMD + state->regoff, &tmp); tmp &= ~0xC0; -- GitLab From 22f584c5c665461d6bb3d4e242084e4a5b87d5b6 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Sun, 26 Nov 2017 08:00:09 -0500 Subject: [PATCH 0172/1190] media: dvb-frontends/stv0910: remove unneeded dvb_math.h include Since nothing from dvb_math.h is used, remove the unneeded include. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stv0910.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index 681349a5aea8f..a8c99f41478b1 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -24,7 +24,6 @@ #include #include -#include "dvb_math.h" #include "dvb_frontend.h" #include "stv0910.h" #include "stv0910_regs.h" -- GitLab From b1728ff617f88a1f7a5d8c8f21fe17a2f6af5d16 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Mon, 27 Nov 2017 04:25:29 -0500 Subject: [PATCH 0173/1190] media: dvb_frontend: fix ifnullfree.cocci warnings drivers/media/dvb-core/dvb_frontend.c:154:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. NULL check before some freeing functions is not needed. Based on checkpatch warning "kfree(NULL) is safe this check is probably not required" and kfreeaddr.cocci by Julia Lawall. Generated by: scripts/coccinelle/free/ifnullfree.cocci Fixes: b1cb7372fa82 ("dvb_frontend: don't use-after-free the frontend struct") Signed-off-by: Fengguang Wu Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 4eedaa5922ebf..e8c7ded5570b0 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -150,8 +150,7 @@ static void __dvb_frontend_free(struct dvb_frontend *fe) dvb_frontend_invoke_release(fe, fe->ops.release); - if (fepriv) - kfree(fepriv); + kfree(fepriv); } static void dvb_frontend_free(struct kref *ref) -- GitLab From 6cdeaed3b1420bd2569891be0c4123ff59628e9e Mon Sep 17 00:00:00 2001 From: Wolfgang Rohdewald Date: Tue, 28 Nov 2017 06:33:52 -0500 Subject: [PATCH 0174/1190] media: dvb_usb_pctv452e: module refcount changes were unbalanced dvb_frontend will call dvb_detach for: - stb0899_detach in dvb_frontend_release and - stb0899_release in __dvb_frontend_free But we only do dvb_attach(stb0899_attach). Increment the module refcount instead. Signed-off-by: Wolfgang Rohdewald Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb/pctv452e.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c index 601ade7ca48d1..3b7f8298b24db 100644 --- a/drivers/media/usb/dvb-usb/pctv452e.c +++ b/drivers/media/usb/dvb-usb/pctv452e.c @@ -913,6 +913,14 @@ static int pctv452e_frontend_attach(struct dvb_usb_adapter *a) &a->dev->i2c_adap); if (!a->fe_adap[0].fe) return -ENODEV; + + /* + * dvb_frontend will call dvb_detach for both stb0899_detach + * and stb0899_release but we only do dvb_attach(stb0899_attach). + * Increment the module refcount instead. + */ + symbol_get(stb0899_attach); + if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe, &a->dev->i2c_adap)) == NULL) err("Cannot attach lnbp22\n"); -- GitLab From a2282fd1fe2ebcda480426dbfaaa7c4e87e27399 Mon Sep 17 00:00:00 2001 From: Jaedon Shin Date: Fri, 1 Dec 2017 07:31:28 -0500 Subject: [PATCH 0175/1190] media: dvb_frontend: Add unlocked_ioctl in dvb_frontend.c Adds unlocked ioctl function directly in dvb_frontend.c instead of using dvb_generic_ioctl(). Signed-off-by: Jaedon Shin Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index e8c7ded5570b0..8f07b623070c5 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -1922,7 +1922,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe, return r; } -static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg) +static int dvb_frontend_do_ioctl(struct file *file, unsigned int cmd, + void *parg) { struct dvb_device *dvbdev = file->private_data; struct dvb_frontend *fe = dvbdev->priv; @@ -1965,6 +1966,17 @@ static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg) return err; } +static long dvb_frontend_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct dvb_device *dvbdev = file->private_data; + + if (!dvbdev) + return -ENODEV; + + return dvb_usercopy(file, cmd, arg, dvb_frontend_do_ioctl); +} + static int dtv_set_frontend(struct dvb_frontend *fe) { struct dvb_frontend_private *fepriv = fe->frontend_priv; @@ -2648,7 +2660,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) static const struct file_operations dvb_frontend_fops = { .owner = THIS_MODULE, - .unlocked_ioctl = dvb_generic_ioctl, + .unlocked_ioctl = dvb_frontend_ioctl, .poll = dvb_frontend_poll, .open = dvb_frontend_open, .release = dvb_frontend_release, @@ -2716,7 +2728,6 @@ int dvb_register_frontend(struct dvb_adapter* dvb, #if defined(CONFIG_MEDIA_CONTROLLER_DVB) .name = fe->ops.info.name, #endif - .kernel_ioctl = dvb_frontend_ioctl }; dev_dbg(dvb->device, "%s:\n", __func__); -- GitLab From c2dfd2276cec63a0c6f6ce18ed83800d96fde542 Mon Sep 17 00:00:00 2001 From: Jaedon Shin Date: Fri, 1 Dec 2017 07:31:29 -0500 Subject: [PATCH 0176/1190] media: dvb_frontend: Add compat_ioctl callback Adds compat_ioctl for 32-bit user space applications on a 64-bit system. [m.chehab@osg.samsung.com: add missing include compat.h] Signed-off-by: Jaedon Shin Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 12 ++++++++++++ fs/compat_ioctl.c | 17 ----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 8f07b623070c5..130e9d225536b 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "dvb_frontend.h" @@ -1977,6 +1978,14 @@ static long dvb_frontend_ioctl(struct file *file, unsigned int cmd, return dvb_usercopy(file, cmd, arg, dvb_frontend_do_ioctl); } +#ifdef CONFIG_COMPAT +static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static int dtv_set_frontend(struct dvb_frontend *fe) { struct dvb_frontend_private *fepriv = fe->frontend_priv; @@ -2661,6 +2670,9 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) static const struct file_operations dvb_frontend_fops = { .owner = THIS_MODULE, .unlocked_ioctl = dvb_frontend_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = dvb_frontend_compat_ioctl, +#endif .poll = dvb_frontend_poll, .open = dvb_frontend_open, .release = dvb_frontend_release, diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 5fc5dc6606005..9a1fe60cce9a5 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -1218,23 +1218,6 @@ COMPATIBLE_IOCTL(DMX_SET_PES_FILTER) COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE) COMPATIBLE_IOCTL(DMX_GET_PES_PIDS) COMPATIBLE_IOCTL(DMX_GET_STC) -COMPATIBLE_IOCTL(FE_GET_INFO) -COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD) -COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD) -COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY) -COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST) -COMPATIBLE_IOCTL(FE_SET_TONE) -COMPATIBLE_IOCTL(FE_SET_VOLTAGE) -COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE) -COMPATIBLE_IOCTL(FE_READ_STATUS) -COMPATIBLE_IOCTL(FE_READ_BER) -COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH) -COMPATIBLE_IOCTL(FE_READ_SNR) -COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS) -COMPATIBLE_IOCTL(FE_SET_FRONTEND) -COMPATIBLE_IOCTL(FE_GET_FRONTEND) -COMPATIBLE_IOCTL(FE_GET_EVENT) -COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD) COMPATIBLE_IOCTL(VIDEO_STOP) COMPATIBLE_IOCTL(VIDEO_PLAY) COMPATIBLE_IOCTL(VIDEO_FREEZE) -- GitLab From 18192a77f0810933ab71a46c1b260d230d7352ee Mon Sep 17 00:00:00 2001 From: Jaedon Shin Date: Fri, 1 Dec 2017 07:31:30 -0500 Subject: [PATCH 0177/1190] media: dvb_frontend: Add commands implementation for compat ioct The dtv_properties structure and the dtv_property structure are different sizes in 32-bit and 64-bit system. This patch provides FE_SET_PROPERTY and FE_GET_PROPERTY ioctl commands implementation for 32-bit user space applications. Signed-off-by: Jaedon Shin Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 131 ++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 130e9d225536b..ee3ea4dcd9c14 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -1979,9 +1979,140 @@ static long dvb_frontend_ioctl(struct file *file, unsigned int cmd, } #ifdef CONFIG_COMPAT +struct compat_dtv_property { + __u32 cmd; + __u32 reserved[3]; + union { + __u32 data; + struct dtv_fe_stats st; + struct { + __u8 data[32]; + __u32 len; + __u32 reserved1[3]; + compat_uptr_t reserved2; + } buffer; + } u; + int result; +} __attribute__ ((packed)); + +struct compat_dtv_properties { + __u32 num; + compat_uptr_t props; +}; + +#define COMPAT_FE_SET_PROPERTY _IOW('o', 82, struct compat_dtv_properties) +#define COMPAT_FE_GET_PROPERTY _IOR('o', 83, struct compat_dtv_properties) + +static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct dvb_device *dvbdev = file->private_data; + struct dvb_frontend *fe = dvbdev->priv; + struct dvb_frontend_private *fepriv = fe->frontend_priv; + int i, err = 0; + + if (cmd == COMPAT_FE_SET_PROPERTY) { + struct compat_dtv_properties prop, *tvps = NULL; + struct compat_dtv_property *tvp = NULL; + + if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop))) + return -EFAULT; + + tvps = ∝ + + /* + * Put an arbitrary limit on the number of messages that can + * be sent at once + */ + if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) + return -EINVAL; + + tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); + if (IS_ERR(tvp)) + return PTR_ERR(tvp); + + for (i = 0; i < tvps->num; i++) { + err = dtv_property_process_set(fe, file, + (tvp + i)->cmd, + (tvp + i)->u.data); + if (err < 0) { + kfree(tvp); + return err; + } + } + kfree(tvp); + } else if (cmd == COMPAT_FE_GET_PROPERTY) { + struct compat_dtv_properties prop, *tvps = NULL; + struct compat_dtv_property *tvp = NULL; + struct dtv_frontend_properties getp = fe->dtv_property_cache; + + if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop))) + return -EFAULT; + + tvps = ∝ + + /* + * Put an arbitrary limit on the number of messages that can + * be sent at once + */ + if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) + return -EINVAL; + + tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); + if (IS_ERR(tvp)) + return PTR_ERR(tvp); + + /* + * Let's use our own copy of property cache, in order to + * avoid mangling with DTV zigzag logic, as drivers might + * return crap, if they don't check if the data is available + * before updating the properties cache. + */ + if (fepriv->state != FESTATE_IDLE) { + err = dtv_get_frontend(fe, &getp, NULL); + if (err < 0) { + kfree(tvp); + return err; + } + } + for (i = 0; i < tvps->num; i++) { + err = dtv_property_process_get( + fe, &getp, (struct dtv_property *)tvp + i, file); + if (err < 0) { + kfree(tvp); + return err; + } + } + + if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp, + tvps->num * sizeof(struct compat_dtv_property))) { + kfree(tvp); + return -EFAULT; + } + kfree(tvp); + } + + return err; +} + static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { + struct dvb_device *dvbdev = file->private_data; + struct dvb_frontend *fe = dvbdev->priv; + struct dvb_frontend_private *fepriv = fe->frontend_priv; + int err; + + if (cmd == COMPAT_FE_SET_PROPERTY || cmd == COMPAT_FE_GET_PROPERTY) { + if (down_interruptible(&fepriv->sem)) + return -ERESTARTSYS; + + err = dvb_frontend_handle_compat_ioctl(file, cmd, arg); + + up(&fepriv->sem); + return err; + } + return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); } #endif -- GitLab From 9ed785a926843ca5a954d3324082afa2b96f5824 Mon Sep 17 00:00:00 2001 From: Benjamin Gaignard Date: Tue, 5 Dec 2017 09:52:39 -0500 Subject: [PATCH 0178/1190] media: platform: sti: Adopt SPDX identifier Add SPDX identifiers to files under sti directory Signed-off-by: Benjamin Gaignard Reviewed-by: Fabien Dessenne Acked-by: Philippe Ombredanne Acked-by: Hugues Fruchet Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/bdisp/bdisp-debug.c | 2 +- drivers/media/platform/sti/bdisp/bdisp-filter.h | 2 +- drivers/media/platform/sti/bdisp/bdisp-hw.c | 2 +- drivers/media/platform/sti/bdisp/bdisp-reg.h | 2 +- drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 2 +- drivers/media/platform/sti/bdisp/bdisp.h | 2 +- .../media/platform/sti/c8sectpfe/c8sectpfe-common.c | 5 +---- .../media/platform/sti/c8sectpfe/c8sectpfe-common.h | 5 +---- drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 5 +---- drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h | 5 +---- .../media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c | 9 +-------- .../media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h | 9 +-------- drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c | 11 +---------- drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h | 5 +---- drivers/media/platform/sti/cec/stih-cec.c | 5 +---- drivers/media/platform/sti/delta/delta-cfg.h | 2 +- drivers/media/platform/sti/delta/delta-debug.c | 2 +- drivers/media/platform/sti/delta/delta-debug.h | 2 +- drivers/media/platform/sti/delta/delta-ipc.c | 2 +- drivers/media/platform/sti/delta/delta-ipc.h | 2 +- drivers/media/platform/sti/delta/delta-mem.c | 2 +- drivers/media/platform/sti/delta/delta-mem.h | 2 +- drivers/media/platform/sti/delta/delta-mjpeg-dec.c | 2 +- drivers/media/platform/sti/delta/delta-mjpeg-fw.h | 2 +- drivers/media/platform/sti/delta/delta-mjpeg-hdr.c | 2 +- drivers/media/platform/sti/delta/delta-mjpeg.h | 2 +- drivers/media/platform/sti/delta/delta-v4l2.c | 2 +- drivers/media/platform/sti/delta/delta.h | 2 +- drivers/media/platform/sti/hva/hva-debugfs.c | 2 +- drivers/media/platform/sti/hva/hva-h264.c | 2 +- drivers/media/platform/sti/hva/hva-hw.c | 2 +- drivers/media/platform/sti/hva/hva-hw.h | 2 +- drivers/media/platform/sti/hva/hva-mem.c | 2 +- drivers/media/platform/sti/hva/hva-mem.h | 2 +- drivers/media/platform/sti/hva/hva-v4l2.c | 2 +- drivers/media/platform/sti/hva/hva.h | 2 +- 36 files changed, 36 insertions(+), 77 deletions(-) diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c b/drivers/media/platform/sti/bdisp/bdisp-debug.c index 2cc289e4dea1d..c6a4e2de5c0cf 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h b/drivers/media/platform/sti/bdisp/bdisp-filter.h index 53e52fb4127fd..d25adb57e3d08 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-filter.h +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #define BDISP_HF_NB 64 diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c index b7892f3efd988..e7836b307d218 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/bdisp/bdisp-reg.h b/drivers/media/platform/sti/bdisp/bdisp-reg.h index e7e1a425f65a9..b07ecc9037077 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-reg.h +++ b/drivers/media/platform/sti/bdisp/bdisp-reg.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ struct bdisp_node { diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c index 7e9ed9c7b3e13..bf4ca16db4406 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/bdisp/bdisp.h b/drivers/media/platform/sti/bdisp/bdisp.h index b3fbf9902595f..e309cde379cae 100644 --- a/drivers/media/platform/sti/bdisp/bdisp.h +++ b/drivers/media/platform/sti/bdisp/bdisp.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Fabien Dessenne for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c index 2dfbe8ab52143..c64909e5ab646 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * c8sectpfe-common.c - C8SECTPFE STi DVB driver * @@ -5,10 +6,6 @@ * * Author: Peter Griffin * - * 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. */ #include #include diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h index da21c0ac0fc14..694f63832d3f4 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * c8sectpfe-common.h - C8SECTPFE STi DVB driver * @@ -5,10 +6,6 @@ * * Author: Peter Griffin * - * 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. */ #ifndef _C8SECTPFE_COMMON_H_ #define _C8SECTPFE_COMMON_H_ diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index ef529dfe1e8c0..34a9cca6b7078 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * c8sectpfe-core.c - C8SECTPFE STi DVB driver * @@ -6,10 +7,6 @@ * Author:Peter Bennett * Peter Griffin * - * 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. */ #include #include diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h index 39e7a221a941c..3dbb3a287cc0b 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * c8sectpfe-core.h - C8SECTPFE STi DVB driver * @@ -6,10 +7,6 @@ * Author:Peter Bennett * Peter Griffin * - * 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. */ #ifndef _C8SECTPFE_CORE_H_ #define _C8SECTPFE_CORE_H_ diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c index e9ba13db49cdf..8f0ddcbeed9df 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * c8sectpfe-debugfs.c - C8SECTPFE STi DVB driver * @@ -5,14 +6,6 @@ * * Author: Peter Griffin * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License as published by the Free Software Foundation. - * - * 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. */ #include #include diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h index 8af1ac1378c8a..b8c30bcc8df95 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /** * c8sectpfe-debugfs.h - C8SECTPFE STi DVB driver debugfs header * @@ -5,14 +6,6 @@ * * Authors: Peter Griffin * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License as published by the Free Software Foundation. - * - * 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. */ #ifndef __C8SECTPFE_DEBUG_H diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c index 2c0015b1264d3..075d4695ee4d7 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * c8sectpfe-dvb.c - C8SECTPFE STi DVB driver * @@ -5,16 +6,6 @@ * * Author Peter Griffin * - * 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. */ #include #include diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h index bd366dbc82b37..3d87a9ae8702d 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * c8sectpfe-common.h - C8SECTPFE STi DVB driver * @@ -5,10 +6,6 @@ * * Author: Peter Griffin * - * 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. */ #ifndef _C8SECTPFE_DVB_H_ #define _C8SECTPFE_DVB_H_ diff --git a/drivers/media/platform/sti/cec/stih-cec.c b/drivers/media/platform/sti/cec/stih-cec.c index 70160df36de98..d34099f759901 100644 --- a/drivers/media/platform/sti/cec/stih-cec.c +++ b/drivers/media/platform/sti/cec/stih-cec.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * STIH4xx CEC driver * Copyright (C) STMicroelectronics SA 2016 * - * 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. */ #include #include diff --git a/drivers/media/platform/sti/delta/delta-cfg.h b/drivers/media/platform/sti/delta/delta-cfg.h index c6388f575800a..f47c6e6ff0838 100644 --- a/drivers/media/platform/sti/delta/delta-cfg.h +++ b/drivers/media/platform/sti/delta/delta-cfg.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_CFG_H diff --git a/drivers/media/platform/sti/delta/delta-debug.c b/drivers/media/platform/sti/delta/delta-debug.c index a7ebf2cc77839..4b2eb6b63aa25 100644 --- a/drivers/media/platform/sti/delta/delta-debug.c +++ b/drivers/media/platform/sti/delta/delta-debug.c @@ -1,9 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Hugues Fruchet * Fabrice Lecoultre * for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include "delta.h" diff --git a/drivers/media/platform/sti/delta/delta-debug.h b/drivers/media/platform/sti/delta/delta-debug.h index 955c1587ac2d1..fa90252623e1b 100644 --- a/drivers/media/platform/sti/delta/delta-debug.h +++ b/drivers/media/platform/sti/delta/delta-debug.h @@ -1,9 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Hugues Fruchet * Fabrice Lecoultre * for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_DEBUG_H diff --git a/drivers/media/platform/sti/delta/delta-ipc.c b/drivers/media/platform/sti/delta/delta-ipc.c index 41e4a4c259b32..a4603d573c34a 100644 --- a/drivers/media/platform/sti/delta/delta-ipc.c +++ b/drivers/media/platform/sti/delta/delta-ipc.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/delta/delta-ipc.h b/drivers/media/platform/sti/delta/delta-ipc.h index cef2019c72d47..9fba6b5d169a2 100644 --- a/drivers/media/platform/sti/delta/delta-ipc.h +++ b/drivers/media/platform/sti/delta/delta-ipc.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_IPC_H diff --git a/drivers/media/platform/sti/delta/delta-mem.c b/drivers/media/platform/sti/delta/delta-mem.c index d7b53d31caa6a..aeccd50583da8 100644 --- a/drivers/media/platform/sti/delta/delta-mem.c +++ b/drivers/media/platform/sti/delta/delta-mem.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include "delta.h" diff --git a/drivers/media/platform/sti/delta/delta-mem.h b/drivers/media/platform/sti/delta/delta-mem.h index f8ca109e1241b..ff7d02f00b280 100644 --- a/drivers/media/platform/sti/delta/delta-mem.h +++ b/drivers/media/platform/sti/delta/delta-mem.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_MEM_H diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-dec.c b/drivers/media/platform/sti/delta/delta-mjpeg-dec.c index 84ea43c0eb463..0533d4a083d24 100644 --- a/drivers/media/platform/sti/delta/delta-mjpeg-dec.c +++ b/drivers/media/platform/sti/delta/delta-mjpeg-dec.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2013 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-fw.h b/drivers/media/platform/sti/delta/delta-mjpeg-fw.h index de803d0c2fe86..5a9404f4d055a 100644 --- a/drivers/media/platform/sti/delta/delta-mjpeg-fw.h +++ b/drivers/media/platform/sti/delta/delta-mjpeg-fw.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_MJPEG_FW_H diff --git a/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c b/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c index a8fd8fa0ecb5d..90e5b2f72c82b 100644 --- a/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c +++ b/drivers/media/platform/sti/delta/delta-mjpeg-hdr.c @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2013 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include "delta.h" diff --git a/drivers/media/platform/sti/delta/delta-mjpeg.h b/drivers/media/platform/sti/delta/delta-mjpeg.h index 18e6b37217ee4..43f7a88b6e591 100644 --- a/drivers/media/platform/sti/delta/delta-mjpeg.h +++ b/drivers/media/platform/sti/delta/delta-mjpeg.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2013 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_MJPEG_H diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c index b2dc3d223a9c9..232d508c5b660 100644 --- a/drivers/media/platform/sti/delta/delta-v4l2.c +++ b/drivers/media/platform/sti/delta/delta-v4l2.c @@ -1,9 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Hugues Fruchet * Jean-Christophe Trotin * for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/delta/delta.h b/drivers/media/platform/sti/delta/delta.h index 60c073246a01a..2ba99922c05b0 100644 --- a/drivers/media/platform/sti/delta/delta.h +++ b/drivers/media/platform/sti/delta/delta.h @@ -1,7 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Author: Hugues Fruchet for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #ifndef DELTA_H diff --git a/drivers/media/platform/sti/hva/hva-debugfs.c b/drivers/media/platform/sti/hva/hva-debugfs.c index 83a6258a155bb..9f7e8ac875d16 100644 --- a/drivers/media/platform/sti/hva/hva-debugfs.c +++ b/drivers/media/platform/sti/hva/hva-debugfs.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/hva/hva-h264.c b/drivers/media/platform/sti/hva/hva-h264.c index 17f1eb0ba957f..b61a5d337d2a1 100644 --- a/drivers/media/platform/sti/hva/hva-h264.c +++ b/drivers/media/platform/sti/hva/hva-h264.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #include "hva.h" diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c index ec25bdcfa3d1e..7917fd2c4bd4b 100644 --- a/drivers/media/platform/sti/hva/hva-hw.c +++ b/drivers/media/platform/sti/hva/hva-hw.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/hva/hva-hw.h b/drivers/media/platform/sti/hva/hva-hw.h index b46017dcfae95..b298990264d5f 100644 --- a/drivers/media/platform/sti/hva/hva-hw.h +++ b/drivers/media/platform/sti/hva/hva-hw.h @@ -1,8 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #ifndef HVA_HW_H diff --git a/drivers/media/platform/sti/hva/hva-mem.c b/drivers/media/platform/sti/hva/hva-mem.c index 821c78ed208c0..caf50cd4bb77b 100644 --- a/drivers/media/platform/sti/hva/hva-mem.c +++ b/drivers/media/platform/sti/hva/hva-mem.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #include "hva.h" diff --git a/drivers/media/platform/sti/hva/hva-mem.h b/drivers/media/platform/sti/hva/hva-mem.h index a95c728a45e66..fec549dff2b3f 100644 --- a/drivers/media/platform/sti/hva/hva-mem.h +++ b/drivers/media/platform/sti/hva/hva-mem.h @@ -1,8 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #ifndef HVA_MEM_H diff --git a/drivers/media/platform/sti/hva/hva-v4l2.c b/drivers/media/platform/sti/hva/hva-v4l2.c index 1c4fc33cbcb5a..2ab0b5cc5c22c 100644 --- a/drivers/media/platform/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/sti/hva/hva-v4l2.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #include diff --git a/drivers/media/platform/sti/hva/hva.h b/drivers/media/platform/sti/hva/hva.h index 0d749b257a211..8882d901d119a 100644 --- a/drivers/media/platform/sti/hva/hva.h +++ b/drivers/media/platform/sti/hva/hva.h @@ -1,8 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) STMicroelectronics SA 2015 * Authors: Yannick Fertre * Hugues Fruchet - * License terms: GNU General Public License (GPL), version 2 */ #ifndef HVA_H -- GitLab From 6738d3bbab999d7d9d77a185d62bd146d9a257f2 Mon Sep 17 00:00:00 2001 From: Pravin Shedge Date: Wed, 6 Dec 2017 11:52:02 -0500 Subject: [PATCH 0179/1190] media: drivers: media: remove duplicate includes These duplicate includes have been found with scripts/checkincludes.pl but they have been removed manually to avoid removing false positives. Signed-off-by: Pravin Shedge Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/pxa_camera.c | 1 - drivers/media/platform/ti-vpe/cal.c | 3 --- drivers/media/v4l2-core/v4l2-mc.c | 2 -- 3 files changed, 6 deletions(-) diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index 295f34ad10800..32047aefa1e83 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index 8b586c8645244..719ed1d799573 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -28,10 +28,7 @@ #include #include #include -#include #include -#include -#include #include #include #include "cal_regs.h" diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 303980b71aae2..1d550afeda13f 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include int v4l2_mc_create_media_graph(struct media_device *mdev) -- GitLab From b32a2b42f76cdfd06b4b58a1ddf987ba329ae34e Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Wed, 6 Dec 2017 12:59:14 -0500 Subject: [PATCH 0180/1190] media: ddbridge: improve error handling logic on fe attach failures This change makes sure that demod frontends are always detached whenever a tuner frontend attach failed. Achieve this by moving the detach-on- failure logic at the end of dvb_input_attach(), and adding a goto to this block on every tuner attach failure case, so if an error occurs, there are no stray attached frontends left. As a side effect, this removes some duplicated code. Signed-off-by: Daniel Scheller Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-core.c | 49 ++++++++++------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 348cc8b3d1f93..11c5cae92408b 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1449,48 +1449,43 @@ static int dvb_input_attach(struct ddb_input *input) if (demod_attach_stv0900(input, 0) < 0) return -ENODEV; if (tuner_attach_stv6110(input, 0) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBS_ST_AA: if (demod_attach_stv0900(input, 1) < 0) return -ENODEV; if (tuner_attach_stv6110(input, 1) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBS_STV0910: if (demod_attach_stv0910(input, 0) < 0) return -ENODEV; if (tuner_attach_stv6111(input, 0) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBS_STV0910_PR: if (demod_attach_stv0910(input, 1) < 0) return -ENODEV; if (tuner_attach_stv6111(input, 1) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBS_STV0910_P: if (demod_attach_stv0910(input, 0) < 0) return -ENODEV; if (tuner_attach_stv6111(input, 1) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBCT_TR: if (demod_attach_drxk(input) < 0) return -ENODEV; if (tuner_attach_tda18271(input) < 0) - return -ENODEV; + goto err_tuner; break; case DDB_TUNER_DVBCT_ST: if (demod_attach_stv0367(input) < 0) return -ENODEV; - if (tuner_attach_tda18212(input, port->type) < 0) { - if (dvb->fe2) - dvb_frontend_detach(dvb->fe2); - if (dvb->fe) - dvb_frontend_detach(dvb->fe); - return -ENODEV; - } + if (tuner_attach_tda18212(input, port->type) < 0) + goto err_tuner; break; case DDB_TUNER_DVBC2T2I_SONY_P: if (input->port->dev->link[input->port->lnr].info->ts_quirks & @@ -1509,13 +1504,8 @@ static int dvb_input_attach(struct ddb_input *input) par = 1; if (demod_attach_cxd28xx(input, par, osc24) < 0) return -ENODEV; - if (tuner_attach_tda18212(input, port->type) < 0) { - if (dvb->fe2) - dvb_frontend_detach(dvb->fe2); - if (dvb->fe) - dvb_frontend_detach(dvb->fe); - return -ENODEV; - } + if (tuner_attach_tda18212(input, port->type) < 0) + goto err_tuner; break; case DDB_TUNER_DVBC2T2I_SONY: osc24 = 1; @@ -1525,13 +1515,8 @@ static int dvb_input_attach(struct ddb_input *input) case DDB_TUNER_ISDBT_SONY: if (demod_attach_cxd28xx(input, 0, osc24) < 0) return -ENODEV; - if (tuner_attach_tda18212(input, port->type) < 0) { - if (dvb->fe2) - dvb_frontend_detach(dvb->fe2); - if (dvb->fe) - dvb_frontend_detach(dvb->fe); - return -ENODEV; - } + if (tuner_attach_tda18212(input, port->type) < 0) + goto err_tuner; break; default: return 0; @@ -1554,6 +1539,16 @@ static int dvb_input_attach(struct ddb_input *input) dvb->attached = 0x31; return 0; + +err_tuner: + dev_warn(port->dev->dev, "tuner attach failed!\n"); + + if (dvb->fe2) + dvb_frontend_detach(dvb->fe2); + if (dvb->fe) + dvb_frontend_detach(dvb->fe); + + return -ENODEV; } static int port_has_encti(struct ddb_port *port) -- GitLab From 94e53262a2ac32f4afe8c9b07badf513b0540dd8 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Mon, 11 Dec 2017 19:26:07 -0500 Subject: [PATCH 0181/1190] media: dt: bindings: Add binding for NVIDIA Tegra Video Decoder Engine Add binding documentation for the Video Decoder Engine which is found on NVIDIA Tegra20/30/114/124/132 SoC's. Signed-off-by: Dmitry Osipenko Acked-by: Rob Herring Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../bindings/media/nvidia,tegra-vde.txt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt diff --git a/Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt b/Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt new file mode 100644 index 0000000000000..470237ed6fe51 --- /dev/null +++ b/Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt @@ -0,0 +1,55 @@ +NVIDIA Tegra Video Decoder Engine + +Required properties: +- compatible : Must contain one of the following values: + - "nvidia,tegra20-vde" + - "nvidia,tegra30-vde" + - "nvidia,tegra114-vde" + - "nvidia,tegra124-vde" + - "nvidia,tegra132-vde" +- reg : Must contain an entry for each entry in reg-names. +- reg-names : Must include the following entries: + - sxe + - bsev + - mbe + - ppe + - mce + - tfe + - ppb + - vdma + - frameid +- iram : Must contain phandle to the mmio-sram device node that represents + IRAM region used by VDE. +- interrupts : Must contain an entry for each entry in interrupt-names. +- interrupt-names : Must include the following entries: + - sync-token + - bsev + - sxe +- clocks : Must include the following entries: + - vde +- resets : Must include the following entries: + - vde + +Example: + +video-codec@6001a000 { + compatible = "nvidia,tegra20-vde"; + reg = <0x6001a000 0x1000 /* Syntax Engine */ + 0x6001b000 0x1000 /* Video Bitstream Engine */ + 0x6001c000 0x100 /* Macroblock Engine */ + 0x6001c200 0x100 /* Post-processing Engine */ + 0x6001c400 0x100 /* Motion Compensation Engine */ + 0x6001c600 0x100 /* Transform Engine */ + 0x6001c800 0x100 /* Pixel prediction block */ + 0x6001ca00 0x100 /* Video DMA */ + 0x6001d800 0x300 /* Video frame controls */>; + reg-names = "sxe", "bsev", "mbe", "ppe", "mce", + "tfe", "ppb", "vdma", "frameid"; + iram = <&vde_pool>; /* IRAM region */ + interrupts = , /* Sync token interrupt */ + , /* BSE-V interrupt */ + ; /* SXE interrupt */ + interrupt-names = "sync-token", "bsev", "sxe"; + clocks = <&tegra_car TEGRA20_CLK_VDE>; + resets = <&tegra_car 61>; +}; -- GitLab From cd6c56feb591f6fe66bebcbeb43ecc0e2acdcffa Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Mon, 11 Dec 2017 19:26:08 -0500 Subject: [PATCH 0182/1190] media: staging: media: Introduce NVIDIA Tegra video decoder driver NVIDIA Tegra20/30/114/124/132 SoC's have video decoder engine that supports standard set of video formats like H.264 / MPEG-4 / WMV / VC1. Signed-off-by: Dmitry Osipenko Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 9 + drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/tegra-vde/Kconfig | 7 + drivers/staging/media/tegra-vde/Makefile | 1 + drivers/staging/media/tegra-vde/TODO | 4 + drivers/staging/media/tegra-vde/tegra-vde.c | 1213 +++++++++++++++++++ drivers/staging/media/tegra-vde/uapi.h | 78 ++ 8 files changed, 1315 insertions(+) create mode 100644 drivers/staging/media/tegra-vde/Kconfig create mode 100644 drivers/staging/media/tegra-vde/Makefile create mode 100644 drivers/staging/media/tegra-vde/TODO create mode 100644 drivers/staging/media/tegra-vde/tegra-vde.c create mode 100644 drivers/staging/media/tegra-vde/uapi.h diff --git a/MAINTAINERS b/MAINTAINERS index 947363d3d6e85..487304ea1e884 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8680,6 +8680,15 @@ T: git git://linuxtv.org/media_tree.git S: Maintained F: drivers/media/dvb-frontends/stv6111* +MEDIA DRIVERS FOR NVIDIA TEGRA - VDE +M: Dmitry Osipenko +L: linux-media@vger.kernel.org +L: linux-tegra@vger.kernel.org +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt +F: drivers/staging/media/tegra-vde/ + MEDIA INPUT INFRASTRUCTURE (V4L/DVB) M: Mauro Carvalho Chehab M: Mauro Carvalho Chehab diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig index f8c25ee082efb..79aff267e2846 100644 --- a/drivers/staging/media/Kconfig +++ b/drivers/staging/media/Kconfig @@ -34,4 +34,6 @@ source "drivers/staging/media/omap4iss/Kconfig" # Keep LIRC at the end, as it has sub-menus source "drivers/staging/media/lirc/Kconfig" +source "drivers/staging/media/tegra-vde/Kconfig" + endif diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile index be732cf932fda..608f7d35c2564 100644 --- a/drivers/staging/media/Makefile +++ b/drivers/staging/media/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_LIRC_STAGING) += lirc/ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ obj-$(CONFIG_INTEL_ATOMISP) += atomisp/ +obj-$(CONFIG_TEGRA_VDE) += tegra-vde/ diff --git a/drivers/staging/media/tegra-vde/Kconfig b/drivers/staging/media/tegra-vde/Kconfig new file mode 100644 index 0000000000000..ec3ddddebdaa5 --- /dev/null +++ b/drivers/staging/media/tegra-vde/Kconfig @@ -0,0 +1,7 @@ +config TEGRA_VDE + tristate "NVIDIA Tegra Video Decoder Engine driver" + depends on ARCH_TEGRA || COMPILE_TEST + select SRAM + help + Say Y here to enable support for the NVIDIA Tegra video decoder + driver. diff --git a/drivers/staging/media/tegra-vde/Makefile b/drivers/staging/media/tegra-vde/Makefile new file mode 100644 index 0000000000000..444c1d62daa16 --- /dev/null +++ b/drivers/staging/media/tegra-vde/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_TEGRA_VDE) += tegra-vde.o diff --git a/drivers/staging/media/tegra-vde/TODO b/drivers/staging/media/tegra-vde/TODO new file mode 100644 index 0000000000000..31aaa3e66d80d --- /dev/null +++ b/drivers/staging/media/tegra-vde/TODO @@ -0,0 +1,4 @@ +TODO: + - Implement V4L2 API once it gains support for stateless decoders. + +Contact: Dmitry Osipenko diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c b/drivers/staging/media/tegra-vde/tegra-vde.c new file mode 100644 index 0000000000000..c47659e960896 --- /dev/null +++ b/drivers/staging/media/tegra-vde/tegra-vde.c @@ -0,0 +1,1213 @@ +/* + * NVIDIA Tegra Video decoder driver + * + * Copyright (C) 2016-2017 Dmitry Osipenko + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "uapi.h" + +#define ICMDQUE_WR 0x00 +#define CMDQUE_CONTROL 0x08 +#define INTR_STATUS 0x18 +#define BSE_INT_ENB 0x40 +#define BSE_CONFIG 0x44 + +#define BSE_ICMDQUE_EMPTY BIT(3) +#define BSE_DMA_BUSY BIT(23) + +#define VDE_WR(__data, __addr) \ +do { \ + dev_dbg(vde->miscdev.parent, \ + "%s: %d: 0x%08X => " #__addr ")\n", \ + __func__, __LINE__, (u32)(__data)); \ + writel_relaxed(__data, __addr); \ +} while (0) + +struct video_frame { + struct dma_buf_attachment *y_dmabuf_attachment; + struct dma_buf_attachment *cb_dmabuf_attachment; + struct dma_buf_attachment *cr_dmabuf_attachment; + struct dma_buf_attachment *aux_dmabuf_attachment; + struct sg_table *y_sgt; + struct sg_table *cb_sgt; + struct sg_table *cr_sgt; + struct sg_table *aux_sgt; + dma_addr_t y_addr; + dma_addr_t cb_addr; + dma_addr_t cr_addr; + dma_addr_t aux_addr; + u32 frame_num; + u32 flags; +}; + +struct tegra_vde { + void __iomem *sxe; + void __iomem *bsev; + void __iomem *mbe; + void __iomem *ppe; + void __iomem *mce; + void __iomem *tfe; + void __iomem *ppb; + void __iomem *vdma; + void __iomem *frameid; + struct mutex lock; + struct miscdevice miscdev; + struct reset_control *rst; + struct gen_pool *iram_pool; + struct completion decode_completion; + struct clk *clk; + dma_addr_t iram_lists_addr; + u32 *iram; +}; + +static void tegra_vde_set_bits(struct tegra_vde *vde, + u32 mask, void __iomem *regs) +{ + u32 value = readl_relaxed(regs); + + VDE_WR(value | mask, regs); +} + +static int tegra_vde_wait_mbe(struct tegra_vde *vde) +{ + u32 tmp; + + return readl_relaxed_poll_timeout(vde->mbe + 0x8C, tmp, + (tmp >= 0x10), 1, 100); +} + +static int tegra_vde_setup_mbe_frame_idx(struct tegra_vde *vde, + unsigned int refs_nb, + bool setup_refs) +{ + u32 frame_idx_enb_mask = 0; + u32 value; + unsigned int frame_idx; + unsigned int idx; + int err; + + VDE_WR(0xD0000000 | (0 << 23), vde->mbe + 0x80); + VDE_WR(0xD0200000 | (0 << 23), vde->mbe + 0x80); + + err = tegra_vde_wait_mbe(vde); + if (err) + return err; + + if (!setup_refs) + return 0; + + for (idx = 0, frame_idx = 1; idx < refs_nb; idx++, frame_idx++) { + VDE_WR(0xD0000000 | (frame_idx << 23), vde->mbe + 0x80); + VDE_WR(0xD0200000 | (frame_idx << 23), vde->mbe + 0x80); + + frame_idx_enb_mask |= frame_idx << (6 * (idx % 4)); + + if (idx % 4 == 3 || idx == refs_nb - 1) { + value = 0xC0000000; + value |= (idx >> 2) << 24; + value |= frame_idx_enb_mask; + + VDE_WR(value, vde->mbe + 0x80); + + err = tegra_vde_wait_mbe(vde); + if (err) + return err; + + frame_idx_enb_mask = 0; + } + } + + return 0; +} + +static void tegra_vde_mbe_set_0xa_reg(struct tegra_vde *vde, int reg, u32 val) +{ + VDE_WR(0xA0000000 | (reg << 24) | (val & 0xFFFF), vde->mbe + 0x80); + VDE_WR(0xA0000000 | ((reg + 1) << 24) | (val >> 16), vde->mbe + 0x80); +} + +static int tegra_vde_wait_bsev(struct tegra_vde *vde, bool wait_dma) +{ + struct device *dev = vde->miscdev.parent; + u32 value; + int err; + + err = readl_relaxed_poll_timeout(vde->bsev + INTR_STATUS, value, + !(value & BIT(2)), 1, 100); + if (err) { + dev_err(dev, "BSEV unknown bit timeout\n"); + return err; + } + + err = readl_relaxed_poll_timeout(vde->bsev + INTR_STATUS, value, + (value & BSE_ICMDQUE_EMPTY), 1, 100); + if (err) { + dev_err(dev, "BSEV ICMDQUE flush timeout\n"); + return err; + } + + if (!wait_dma) + return 0; + + err = readl_relaxed_poll_timeout(vde->bsev + INTR_STATUS, value, + !(value & BSE_DMA_BUSY), 1, 100); + if (err) { + dev_err(dev, "BSEV DMA timeout\n"); + return err; + } + + return 0; +} + +static int tegra_vde_push_to_bsev_icmdqueue(struct tegra_vde *vde, + u32 value, bool wait_dma) +{ + VDE_WR(value, vde->bsev + ICMDQUE_WR); + + return tegra_vde_wait_bsev(vde, wait_dma); +} + +static void tegra_vde_setup_frameid(struct tegra_vde *vde, + struct video_frame *frame, + unsigned int frameid, + u32 mbs_width, u32 mbs_height) +{ + u32 y_addr = frame ? frame->y_addr : 0x6CDEAD00; + u32 cb_addr = frame ? frame->cb_addr : 0x6CDEAD00; + u32 cr_addr = frame ? frame->cr_addr : 0x6CDEAD00; + u32 value1 = frame ? ((mbs_width << 16) | mbs_height) : 0; + u32 value2 = frame ? ((((mbs_width + 1) >> 1) << 6) | 1) : 0; + + VDE_WR(y_addr >> 8, vde->frameid + 0x000 + frameid * 4); + VDE_WR(cb_addr >> 8, vde->frameid + 0x100 + frameid * 4); + VDE_WR(cr_addr >> 8, vde->frameid + 0x180 + frameid * 4); + VDE_WR(value1, vde->frameid + 0x080 + frameid * 4); + VDE_WR(value2, vde->frameid + 0x280 + frameid * 4); +} + +static void tegra_setup_frameidx(struct tegra_vde *vde, + struct video_frame *frames, + unsigned int frames_nb, + u32 mbs_width, u32 mbs_height) +{ + unsigned int idx; + + for (idx = 0; idx < frames_nb; idx++) + tegra_vde_setup_frameid(vde, &frames[idx], idx, + mbs_width, mbs_height); + + for (; idx < 17; idx++) + tegra_vde_setup_frameid(vde, NULL, idx, 0, 0); +} + +static void tegra_vde_setup_iram_entry(struct tegra_vde *vde, + unsigned int table, + unsigned int row, + u32 value1, u32 value2) +{ + u32 *iram_tables = vde->iram; + + dev_dbg(vde->miscdev.parent, "IRAM table %u: row %u: 0x%08X 0x%08X\n", + table, row, value1, value2); + + iram_tables[0x20 * table + row * 2] = value1; + iram_tables[0x20 * table + row * 2 + 1] = value2; +} + +static void tegra_vde_setup_iram_tables(struct tegra_vde *vde, + struct video_frame *dpb_frames, + unsigned int ref_frames_nb, + unsigned int with_earlier_poc_nb) +{ + struct video_frame *frame; + u32 value, aux_addr; + int with_later_poc_nb; + unsigned int i, k; + + dev_dbg(vde->miscdev.parent, "DPB: Frame 0: frame_num = %d\n", + dpb_frames[0].frame_num); + + dev_dbg(vde->miscdev.parent, "REF L0:\n"); + + for (i = 0; i < 16; i++) { + if (i < ref_frames_nb) { + frame = &dpb_frames[i + 1]; + + aux_addr = frame->aux_addr; + + value = (i + 1) << 26; + value |= !(frame->flags & FLAG_B_FRAME) << 25; + value |= 1 << 24; + value |= frame->frame_num; + + dev_dbg(vde->miscdev.parent, + "\tFrame %d: frame_num = %d B_frame = %d\n", + i + 1, frame->frame_num, + (frame->flags & FLAG_B_FRAME)); + } else { + aux_addr = 0x6ADEAD00; + value = 0; + } + + tegra_vde_setup_iram_entry(vde, 0, i, value, aux_addr); + tegra_vde_setup_iram_entry(vde, 1, i, value, aux_addr); + tegra_vde_setup_iram_entry(vde, 2, i, value, aux_addr); + tegra_vde_setup_iram_entry(vde, 3, i, value, aux_addr); + } + + if (!(dpb_frames[0].flags & FLAG_B_FRAME)) + return; + + if (with_earlier_poc_nb >= ref_frames_nb) + return; + + with_later_poc_nb = ref_frames_nb - with_earlier_poc_nb; + + dev_dbg(vde->miscdev.parent, + "REF L1: with_later_poc_nb %d with_earlier_poc_nb %d\n", + with_later_poc_nb, with_earlier_poc_nb); + + for (i = 0, k = with_earlier_poc_nb; i < with_later_poc_nb; i++, k++) { + frame = &dpb_frames[k + 1]; + + aux_addr = frame->aux_addr; + + value = (k + 1) << 26; + value |= !(frame->flags & FLAG_B_FRAME) << 25; + value |= 1 << 24; + value |= frame->frame_num; + + dev_dbg(vde->miscdev.parent, + "\tFrame %d: frame_num = %d\n", + k + 1, frame->frame_num); + + tegra_vde_setup_iram_entry(vde, 2, i, value, aux_addr); + } + + for (k = 0; i < ref_frames_nb; i++, k++) { + frame = &dpb_frames[k + 1]; + + aux_addr = frame->aux_addr; + + value = (k + 1) << 26; + value |= !(frame->flags & FLAG_B_FRAME) << 25; + value |= 1 << 24; + value |= frame->frame_num; + + dev_dbg(vde->miscdev.parent, + "\tFrame %d: frame_num = %d\n", + k + 1, frame->frame_num); + + tegra_vde_setup_iram_entry(vde, 2, i, value, aux_addr); + } +} + +static int tegra_vde_setup_hw_context(struct tegra_vde *vde, + struct tegra_vde_h264_decoder_ctx *ctx, + struct video_frame *dpb_frames, + dma_addr_t bitstream_data_addr, + size_t bitstream_data_size, + unsigned int macroblocks_nb) +{ + struct device *dev = vde->miscdev.parent; + u32 value; + int err; + + tegra_vde_set_bits(vde, 0x000A, vde->sxe + 0xF0); + tegra_vde_set_bits(vde, 0x000B, vde->bsev + CMDQUE_CONTROL); + tegra_vde_set_bits(vde, 0x8002, vde->mbe + 0x50); + tegra_vde_set_bits(vde, 0x000A, vde->mbe + 0xA0); + tegra_vde_set_bits(vde, 0x000A, vde->ppe + 0x14); + tegra_vde_set_bits(vde, 0x000A, vde->ppe + 0x28); + tegra_vde_set_bits(vde, 0x0A00, vde->mce + 0x08); + tegra_vde_set_bits(vde, 0x000A, vde->tfe + 0x00); + tegra_vde_set_bits(vde, 0x0005, vde->vdma + 0x04); + + VDE_WR(0x00000000, vde->vdma + 0x1C); + VDE_WR(0x00000000, vde->vdma + 0x00); + VDE_WR(0x00000007, vde->vdma + 0x04); + VDE_WR(0x00000007, vde->frameid + 0x200); + VDE_WR(0x00000005, vde->tfe + 0x04); + VDE_WR(0x00000000, vde->mbe + 0x84); + VDE_WR(0x00000010, vde->sxe + 0x08); + VDE_WR(0x00000150, vde->sxe + 0x54); + VDE_WR(0x0000054C, vde->sxe + 0x58); + VDE_WR(0x00000E34, vde->sxe + 0x5C); + VDE_WR(0x063C063C, vde->mce + 0x10); + VDE_WR(0x0003FC00, vde->bsev + INTR_STATUS); + VDE_WR(0x0000150D, vde->bsev + BSE_CONFIG); + VDE_WR(0x00000100, vde->bsev + BSE_INT_ENB); + VDE_WR(0x00000000, vde->bsev + 0x98); + VDE_WR(0x00000060, vde->bsev + 0x9C); + + memset(vde->iram + 128, 0, macroblocks_nb / 2); + + tegra_setup_frameidx(vde, dpb_frames, ctx->dpb_frames_nb, + ctx->pic_width_in_mbs, ctx->pic_height_in_mbs); + + tegra_vde_setup_iram_tables(vde, dpb_frames, + ctx->dpb_frames_nb - 1, + ctx->dpb_ref_frames_with_earlier_poc_nb); + wmb(); + + VDE_WR(0x00000000, vde->bsev + 0x8C); + VDE_WR(bitstream_data_addr + bitstream_data_size, + vde->bsev + 0x54); + + value = ctx->pic_width_in_mbs << 11 | ctx->pic_height_in_mbs << 3; + + VDE_WR(value, vde->bsev + 0x88); + + err = tegra_vde_wait_bsev(vde, false); + if (err) + return err; + + err = tegra_vde_push_to_bsev_icmdqueue(vde, 0x800003FC, false); + if (err) + return err; + + value = 0x01500000; + value |= ((vde->iram_lists_addr + 512) >> 2) & 0xFFFF; + + err = tegra_vde_push_to_bsev_icmdqueue(vde, value, true); + if (err) + return err; + + err = tegra_vde_push_to_bsev_icmdqueue(vde, 0x840F054C, false); + if (err) + return err; + + err = tegra_vde_push_to_bsev_icmdqueue(vde, 0x80000080, false); + if (err) + return err; + + value = 0x0E340000 | ((vde->iram_lists_addr >> 2) & 0xFFFF); + + err = tegra_vde_push_to_bsev_icmdqueue(vde, value, true); + if (err) + return err; + + value = 0x00800005; + value |= ctx->pic_width_in_mbs << 11; + value |= ctx->pic_height_in_mbs << 3; + + VDE_WR(value, vde->sxe + 0x10); + + value = !ctx->baseline_profile << 17; + value |= ctx->level_idc << 13; + value |= ctx->log2_max_pic_order_cnt_lsb << 7; + value |= ctx->pic_order_cnt_type << 5; + value |= ctx->log2_max_frame_num; + + VDE_WR(value, vde->sxe + 0x40); + + value = ctx->pic_init_qp << 25; + value |= !!(ctx->deblocking_filter_control_present_flag) << 2; + value |= !!ctx->pic_order_present_flag; + + VDE_WR(value, vde->sxe + 0x44); + + value = ctx->chroma_qp_index_offset; + value |= ctx->num_ref_idx_l0_active_minus1 << 5; + value |= ctx->num_ref_idx_l1_active_minus1 << 10; + value |= !!ctx->constrained_intra_pred_flag << 15; + + VDE_WR(value, vde->sxe + 0x48); + + value = 0x0C000000; + value |= !!(dpb_frames[0].flags & FLAG_B_FRAME) << 24; + + VDE_WR(value, vde->sxe + 0x4C); + + value = 0x03800000; + value |= min_t(size_t, bitstream_data_size, SZ_1M); + + VDE_WR(value, vde->sxe + 0x68); + + VDE_WR(bitstream_data_addr, vde->sxe + 0x6C); + + value = 0x10000005; + value |= ctx->pic_width_in_mbs << 11; + value |= ctx->pic_height_in_mbs << 3; + + VDE_WR(value, vde->mbe + 0x80); + + value = 0x26800000; + value |= ctx->level_idc << 4; + value |= !ctx->baseline_profile << 1; + value |= !!ctx->direct_8x8_inference_flag; + + VDE_WR(value, vde->mbe + 0x80); + + VDE_WR(0xF4000001, vde->mbe + 0x80); + VDE_WR(0x20000000, vde->mbe + 0x80); + VDE_WR(0xF4000101, vde->mbe + 0x80); + + value = 0x20000000; + value |= ctx->chroma_qp_index_offset << 8; + + VDE_WR(value, vde->mbe + 0x80); + + err = tegra_vde_setup_mbe_frame_idx(vde, + ctx->dpb_frames_nb - 1, + ctx->pic_order_cnt_type == 0); + if (err) { + dev_err(dev, "MBE frames setup failed %d\n", err); + return err; + } + + tegra_vde_mbe_set_0xa_reg(vde, 0, 0x000009FC); + tegra_vde_mbe_set_0xa_reg(vde, 2, 0x61DEAD00); + tegra_vde_mbe_set_0xa_reg(vde, 4, 0x62DEAD00); + tegra_vde_mbe_set_0xa_reg(vde, 6, 0x63DEAD00); + tegra_vde_mbe_set_0xa_reg(vde, 8, dpb_frames[0].aux_addr); + + value = 0xFC000000; + value |= !!(dpb_frames[0].flags & FLAG_B_FRAME) << 2; + + if (!ctx->baseline_profile) + value |= !!(dpb_frames[0].flags & FLAG_REFERENCE) << 1; + + VDE_WR(value, vde->mbe + 0x80); + + err = tegra_vde_wait_mbe(vde); + if (err) { + dev_err(dev, "MBE programming failed %d\n", err); + return err; + } + + return 0; +} + +static void tegra_vde_decode_frame(struct tegra_vde *vde, + unsigned int macroblocks_nb) +{ + reinit_completion(&vde->decode_completion); + + VDE_WR(0x00000001, vde->bsev + 0x8C); + VDE_WR(0x20000000 | (macroblocks_nb - 1), vde->sxe + 0x00); +} + +static void tegra_vde_detach_and_put_dmabuf(struct dma_buf_attachment *a, + struct sg_table *sgt, + enum dma_data_direction dma_dir) +{ + struct dma_buf *dmabuf = a->dmabuf; + + dma_buf_unmap_attachment(a, sgt, dma_dir); + dma_buf_detach(dmabuf, a); + dma_buf_put(dmabuf); +} + +static int tegra_vde_attach_dmabuf(struct device *dev, + int fd, + unsigned long offset, + unsigned int min_size, + struct dma_buf_attachment **a, + dma_addr_t *addr, + struct sg_table **s, + size_t *size, + enum dma_data_direction dma_dir) +{ + struct dma_buf_attachment *attachment; + struct dma_buf *dmabuf; + struct sg_table *sgt; + int err; + + dmabuf = dma_buf_get(fd); + if (IS_ERR(dmabuf)) { + dev_err(dev, "Invalid dmabuf FD\n"); + return PTR_ERR(dmabuf); + } + + if ((u64)offset + min_size > dmabuf->size) { + dev_err(dev, "Too small dmabuf size %zu @0x%lX, " + "should be at least %d\n", + dmabuf->size, offset, min_size); + return -EINVAL; + } + + attachment = dma_buf_attach(dmabuf, dev); + if (IS_ERR(attachment)) { + dev_err(dev, "Failed to attach dmabuf\n"); + err = PTR_ERR(attachment); + goto err_put; + } + + sgt = dma_buf_map_attachment(attachment, dma_dir); + if (IS_ERR(sgt)) { + dev_err(dev, "Failed to get dmabufs sg_table\n"); + err = PTR_ERR(sgt); + goto err_detach; + } + + if (sgt->nents != 1) { + dev_err(dev, "Sparse DMA region is unsupported\n"); + err = -EINVAL; + goto err_unmap; + } + + *addr = sg_dma_address(sgt->sgl) + offset; + *a = attachment; + *s = sgt; + + if (size) + *size = dmabuf->size - offset; + + return 0; + +err_unmap: + dma_buf_unmap_attachment(attachment, sgt, dma_dir); +err_detach: + dma_buf_detach(dmabuf, attachment); +err_put: + dma_buf_put(dmabuf); + + return err; +} + +static int tegra_vde_attach_dmabufs_to_frame(struct device *dev, + struct video_frame *frame, + struct tegra_vde_h264_frame *src, + enum dma_data_direction dma_dir, + bool baseline_profile, + size_t csize) +{ + int err; + + err = tegra_vde_attach_dmabuf(dev, src->y_fd, + src->y_offset, csize * 4, + &frame->y_dmabuf_attachment, + &frame->y_addr, + &frame->y_sgt, + NULL, dma_dir); + if (err) + return err; + + err = tegra_vde_attach_dmabuf(dev, src->cb_fd, + src->cb_offset, csize, + &frame->cb_dmabuf_attachment, + &frame->cb_addr, + &frame->cb_sgt, + NULL, dma_dir); + if (err) + goto err_release_y; + + err = tegra_vde_attach_dmabuf(dev, src->cr_fd, + src->cr_offset, csize, + &frame->cr_dmabuf_attachment, + &frame->cr_addr, + &frame->cr_sgt, + NULL, dma_dir); + if (err) + goto err_release_cb; + + if (baseline_profile) { + frame->aux_addr = 0x64DEAD00; + return 0; + } + + err = tegra_vde_attach_dmabuf(dev, src->aux_fd, + src->aux_offset, csize, + &frame->aux_dmabuf_attachment, + &frame->aux_addr, + &frame->aux_sgt, + NULL, dma_dir); + if (err) + goto err_release_cr; + + return 0; + +err_release_cr: + tegra_vde_detach_and_put_dmabuf(frame->cr_dmabuf_attachment, + frame->cr_sgt, dma_dir); +err_release_cb: + tegra_vde_detach_and_put_dmabuf(frame->cb_dmabuf_attachment, + frame->cb_sgt, dma_dir); +err_release_y: + tegra_vde_detach_and_put_dmabuf(frame->y_dmabuf_attachment, + frame->y_sgt, dma_dir); + + return err; +} + +static void tegra_vde_release_frame_dmabufs(struct video_frame *frame, + enum dma_data_direction dma_dir, + bool baseline_profile) +{ + if (!baseline_profile) + tegra_vde_detach_and_put_dmabuf(frame->aux_dmabuf_attachment, + frame->aux_sgt, dma_dir); + + tegra_vde_detach_and_put_dmabuf(frame->cr_dmabuf_attachment, + frame->cr_sgt, dma_dir); + + tegra_vde_detach_and_put_dmabuf(frame->cb_dmabuf_attachment, + frame->cb_sgt, dma_dir); + + tegra_vde_detach_and_put_dmabuf(frame->y_dmabuf_attachment, + frame->y_sgt, dma_dir); +} + +static int tegra_vde_validate_frame(struct device *dev, + struct tegra_vde_h264_frame *frame) +{ + if (frame->frame_num > 0x7FFFFF) { + dev_err(dev, "Bad frame_num %u\n", frame->frame_num); + return -EINVAL; + } + + if (frame->y_offset & 0xFF) { + dev_err(dev, "Bad y_offset 0x%X\n", frame->y_offset); + return -EINVAL; + } + + if (frame->cb_offset & 0xFF) { + dev_err(dev, "Bad cb_offset 0x%X\n", frame->cb_offset); + return -EINVAL; + } + + if (frame->cr_offset & 0xFF) { + dev_err(dev, "Bad cr_offset 0x%X\n", frame->cr_offset); + return -EINVAL; + } + + return 0; +} + +static int tegra_vde_validate_h264_ctx(struct device *dev, + struct tegra_vde_h264_decoder_ctx *ctx) +{ + if (ctx->dpb_frames_nb == 0 || ctx->dpb_frames_nb > 17) { + dev_err(dev, "Bad DPB size %u\n", ctx->dpb_frames_nb); + return -EINVAL; + } + + if (ctx->level_idc > 15) { + dev_err(dev, "Bad level value %u\n", ctx->level_idc); + return -EINVAL; + } + + if (ctx->pic_init_qp > 52) { + dev_err(dev, "Bad pic_init_qp value %u\n", ctx->pic_init_qp); + return -EINVAL; + } + + if (ctx->log2_max_pic_order_cnt_lsb > 16) { + dev_err(dev, "Bad log2_max_pic_order_cnt_lsb value %u\n", + ctx->log2_max_pic_order_cnt_lsb); + return -EINVAL; + } + + if (ctx->log2_max_frame_num > 16) { + dev_err(dev, "Bad log2_max_frame_num value %u\n", + ctx->log2_max_frame_num); + return -EINVAL; + } + + if (ctx->chroma_qp_index_offset > 31) { + dev_err(dev, "Bad chroma_qp_index_offset value %u\n", + ctx->chroma_qp_index_offset); + return -EINVAL; + } + + if (ctx->pic_order_cnt_type > 2) { + dev_err(dev, "Bad pic_order_cnt_type value %u\n", + ctx->pic_order_cnt_type); + return -EINVAL; + } + + if (ctx->num_ref_idx_l0_active_minus1 > 15) { + dev_err(dev, "Bad num_ref_idx_l0_active_minus1 value %u\n", + ctx->num_ref_idx_l0_active_minus1); + return -EINVAL; + } + + if (ctx->num_ref_idx_l1_active_minus1 > 15) { + dev_err(dev, "Bad num_ref_idx_l1_active_minus1 value %u\n", + ctx->num_ref_idx_l1_active_minus1); + return -EINVAL; + } + + if (!ctx->pic_width_in_mbs || ctx->pic_width_in_mbs > 127) { + dev_err(dev, "Bad pic_width_in_mbs value %u\n", + ctx->pic_width_in_mbs); + return -EINVAL; + } + + if (!ctx->pic_height_in_mbs || ctx->pic_height_in_mbs > 127) { + dev_err(dev, "Bad pic_height_in_mbs value %u\n", + ctx->pic_height_in_mbs); + return -EINVAL; + } + + return 0; +} + +static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde, + unsigned long vaddr) +{ + struct device *dev = vde->miscdev.parent; + struct tegra_vde_h264_decoder_ctx ctx; + struct tegra_vde_h264_frame frames[17]; + struct tegra_vde_h264_frame __user *frames_user; + struct video_frame *dpb_frames; + struct dma_buf_attachment *bitstream_data_dmabuf_attachment; + struct sg_table *bitstream_sgt; + enum dma_data_direction dma_dir; + dma_addr_t bitstream_data_addr; + dma_addr_t bsev_ptr; + size_t bitstream_data_size; + unsigned int macroblocks_nb; + unsigned int read_bytes; + unsigned int i; + long timeout; + int ret, err; + + if (copy_from_user(&ctx, (void __user *)vaddr, sizeof(ctx))) + return -EFAULT; + + ret = tegra_vde_validate_h264_ctx(dev, &ctx); + if (ret) + return ret; + + ret = tegra_vde_attach_dmabuf(dev, ctx.bitstream_data_fd, + ctx.bitstream_data_offset, 0, + &bitstream_data_dmabuf_attachment, + &bitstream_data_addr, + &bitstream_sgt, + &bitstream_data_size, + DMA_TO_DEVICE); + if (ret) + return ret; + + dpb_frames = kcalloc(ctx.dpb_frames_nb, sizeof(*dpb_frames), + GFP_KERNEL); + if (!dpb_frames) { + ret = -ENOMEM; + goto release_bitstream_dmabuf; + } + + macroblocks_nb = ctx.pic_width_in_mbs * ctx.pic_height_in_mbs; + frames_user = u64_to_user_ptr(ctx.dpb_frames_ptr); + + if (copy_from_user(frames, frames_user, + ctx.dpb_frames_nb * sizeof(*frames))) { + ret = -EFAULT; + goto free_dpb_frames; + } + + for (i = 0; i < ctx.dpb_frames_nb; i++) { + ret = tegra_vde_validate_frame(dev, &frames[i]); + if (ret) + goto release_dpb_frames; + + dpb_frames[i].flags = frames[i].flags; + dpb_frames[i].frame_num = frames[i].frame_num; + + dma_dir = (i == 0) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + + ret = tegra_vde_attach_dmabufs_to_frame(dev, &dpb_frames[i], + &frames[i], dma_dir, + ctx.baseline_profile, + macroblocks_nb * 64); + if (ret) + goto release_dpb_frames; + } + + ret = mutex_lock_interruptible(&vde->lock); + if (ret) + goto release_dpb_frames; + + ret = pm_runtime_get_sync(dev); + if (ret < 0) + goto unlock; + + /* + * We rely on the VDE registers reset value, otherwise VDE + * causes bus lockup. + */ + ret = reset_control_reset(vde->rst); + if (ret) { + dev_err(dev, "Failed to reset HW: %d\n", ret); + goto put_runtime_pm; + } + + ret = tegra_vde_setup_hw_context(vde, &ctx, dpb_frames, + bitstream_data_addr, + bitstream_data_size, + macroblocks_nb); + if (ret) + goto put_runtime_pm; + + tegra_vde_decode_frame(vde, macroblocks_nb); + + timeout = wait_for_completion_interruptible_timeout( + &vde->decode_completion, msecs_to_jiffies(1000)); + if (timeout == 0) { + bsev_ptr = readl_relaxed(vde->bsev + 0x10); + macroblocks_nb = readl_relaxed(vde->sxe + 0xC8) & 0x1FFF; + read_bytes = bsev_ptr ? bsev_ptr - bitstream_data_addr : 0; + + dev_err(dev, "Decoding failed: " + "read 0x%X bytes, %u macroblocks parsed\n", + read_bytes, macroblocks_nb); + + ret = -EIO; + } else if (timeout < 0) { + ret = timeout; + } + + err = reset_control_assert(vde->rst); + if (err) + dev_err(dev, "Failed to assert HW reset: %d\n", err); + +put_runtime_pm: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + +unlock: + mutex_unlock(&vde->lock); + +release_dpb_frames: + while (i--) { + dma_dir = (i == 0) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + + tegra_vde_release_frame_dmabufs(&dpb_frames[i], dma_dir, + ctx.baseline_profile); + } + +free_dpb_frames: + kfree(dpb_frames); + +release_bitstream_dmabuf: + tegra_vde_detach_and_put_dmabuf(bitstream_data_dmabuf_attachment, + bitstream_sgt, DMA_TO_DEVICE); + + return ret; +} + +static long tegra_vde_unlocked_ioctl(struct file *filp, + unsigned int cmd, unsigned long arg) +{ + struct miscdevice *miscdev = filp->private_data; + struct tegra_vde *vde = container_of(miscdev, struct tegra_vde, + miscdev); + + switch (cmd) { + case TEGRA_VDE_IOCTL_DECODE_H264: + return tegra_vde_ioctl_decode_h264(vde, arg); + } + + dev_err(miscdev->parent, "Invalid IOCTL command %u\n", cmd); + + return -ENOTTY; +} + +static const struct file_operations tegra_vde_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = tegra_vde_unlocked_ioctl, +}; + +static irqreturn_t tegra_vde_isr(int irq, void *data) +{ + struct tegra_vde *vde = data; + + tegra_vde_set_bits(vde, 0, vde->frameid + 0x208); + complete(&vde->decode_completion); + + return IRQ_HANDLED; +} + +static int tegra_vde_runtime_suspend(struct device *dev) +{ + struct tegra_vde *vde = dev_get_drvdata(dev); + int err; + + err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC); + if (err) { + dev_err(dev, "Failed to power down HW: %d\n", err); + return err; + } + + clk_disable_unprepare(vde->clk); + + return 0; +} + +static int tegra_vde_runtime_resume(struct device *dev) +{ + struct tegra_vde *vde = dev_get_drvdata(dev); + int err; + + err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC, + vde->clk, vde->rst); + if (err) { + dev_err(dev, "Failed to power up HW : %d\n", err); + return err; + } + + return 0; +} + +static int tegra_vde_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *regs; + struct tegra_vde *vde; + int irq, err; + + vde = devm_kzalloc(dev, sizeof(*vde), GFP_KERNEL); + if (!vde) + return -ENOMEM; + + platform_set_drvdata(pdev, vde); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sxe"); + if (!regs) + return -ENODEV; + + vde->sxe = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->sxe)) + return PTR_ERR(vde->sxe); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "bsev"); + if (!regs) + return -ENODEV; + + vde->bsev = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->bsev)) + return PTR_ERR(vde->bsev); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbe"); + if (!regs) + return -ENODEV; + + vde->mbe = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->mbe)) + return PTR_ERR(vde->mbe); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ppe"); + if (!regs) + return -ENODEV; + + vde->ppe = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->ppe)) + return PTR_ERR(vde->ppe); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mce"); + if (!regs) + return -ENODEV; + + vde->mce = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->mce)) + return PTR_ERR(vde->mce); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tfe"); + if (!regs) + return -ENODEV; + + vde->tfe = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->tfe)) + return PTR_ERR(vde->tfe); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ppb"); + if (!regs) + return -ENODEV; + + vde->ppb = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->ppb)) + return PTR_ERR(vde->ppb); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vdma"); + if (!regs) + return -ENODEV; + + vde->vdma = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->vdma)) + return PTR_ERR(vde->vdma); + + regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "frameid"); + if (!regs) + return -ENODEV; + + vde->frameid = devm_ioremap_resource(dev, regs); + if (IS_ERR(vde->frameid)) + return PTR_ERR(vde->frameid); + + vde->clk = devm_clk_get(dev, NULL); + if (IS_ERR(vde->clk)) { + err = PTR_ERR(vde->clk); + dev_err(dev, "Could not get VDE clk %d\n", err); + return err; + } + + vde->rst = devm_reset_control_get(dev, NULL); + if (IS_ERR(vde->rst)) { + err = PTR_ERR(vde->rst); + dev_err(dev, "Could not get VDE reset %d\n", err); + return err; + } + + irq = platform_get_irq_byname(pdev, "sync-token"); + if (irq < 0) + return irq; + + err = devm_request_irq(dev, irq, tegra_vde_isr, 0, + dev_name(dev), vde); + if (err) { + dev_err(dev, "Could not request IRQ %d\n", err); + return err; + } + + vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0); + if (!vde->iram_pool) { + dev_err(dev, "Could not get IRAM pool\n"); + return -EPROBE_DEFER; + } + + vde->iram = gen_pool_dma_alloc(vde->iram_pool, + gen_pool_size(vde->iram_pool), + &vde->iram_lists_addr); + if (!vde->iram) { + dev_err(dev, "Could not reserve IRAM\n"); + return -ENOMEM; + } + + mutex_init(&vde->lock); + init_completion(&vde->decode_completion); + + vde->miscdev.minor = MISC_DYNAMIC_MINOR; + vde->miscdev.name = "tegra_vde"; + vde->miscdev.fops = &tegra_vde_fops; + vde->miscdev.parent = dev; + + err = misc_register(&vde->miscdev); + if (err) { + dev_err(dev, "Failed to register misc device: %d\n", err); + goto err_gen_free; + } + + pm_runtime_enable(dev); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_autosuspend_delay(dev, 300); + + if (!pm_runtime_enabled(dev)) { + err = tegra_vde_runtime_resume(dev); + if (err) + goto err_misc_unreg; + } + + return 0; + +err_misc_unreg: + misc_deregister(&vde->miscdev); + +err_gen_free: + gen_pool_free(vde->iram_pool, (unsigned long)vde->iram, + gen_pool_size(vde->iram_pool)); + + return err; +} + +static int tegra_vde_remove(struct platform_device *pdev) +{ + struct tegra_vde *vde = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + int err; + + if (!pm_runtime_enabled(dev)) { + err = tegra_vde_runtime_suspend(dev); + if (err) + return err; + } + + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); + + misc_deregister(&vde->miscdev); + + gen_pool_free(vde->iram_pool, (unsigned long)vde->iram, + gen_pool_size(vde->iram_pool)); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int tegra_vde_pm_suspend(struct device *dev) +{ + struct tegra_vde *vde = dev_get_drvdata(dev); + int err; + + mutex_lock(&vde->lock); + + err = pm_runtime_force_suspend(dev); + if (err < 0) + return err; + + return 0; +} + +static int tegra_vde_pm_resume(struct device *dev) +{ + struct tegra_vde *vde = dev_get_drvdata(dev); + int err; + + err = pm_runtime_force_resume(dev); + if (err < 0) + return err; + + mutex_unlock(&vde->lock); + + return 0; +} +#endif + +static const struct dev_pm_ops tegra_vde_pm_ops = { + SET_RUNTIME_PM_OPS(tegra_vde_runtime_suspend, + tegra_vde_runtime_resume, + NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra_vde_pm_suspend, + tegra_vde_pm_resume) +}; + +static const struct of_device_id tegra_vde_of_match[] = { + { .compatible = "nvidia,tegra20-vde", }, + { }, +}; +MODULE_DEVICE_TABLE(of, tegra_vde_of_match); + +static struct platform_driver tegra_vde_driver = { + .probe = tegra_vde_probe, + .remove = tegra_vde_remove, + .driver = { + .name = "tegra-vde", + .of_match_table = tegra_vde_of_match, + .pm = &tegra_vde_pm_ops, + }, +}; +module_platform_driver(tegra_vde_driver); + +MODULE_DESCRIPTION("NVIDIA Tegra Video Decoder driver"); +MODULE_AUTHOR("Dmitry Osipenko "); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/media/tegra-vde/uapi.h b/drivers/staging/media/tegra-vde/uapi.h new file mode 100644 index 0000000000000..a50c7bcae057c --- /dev/null +++ b/drivers/staging/media/tegra-vde/uapi.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016-2017 Dmitry Osipenko + * + * 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. + */ + +#ifndef _UAPI_TEGRA_VDE_H_ +#define _UAPI_TEGRA_VDE_H_ + +#include +#include + +#define FLAG_B_FRAME (1 << 0) +#define FLAG_REFERENCE (1 << 1) + +struct tegra_vde_h264_frame { + __s32 y_fd; + __s32 cb_fd; + __s32 cr_fd; + __s32 aux_fd; + __u32 y_offset; + __u32 cb_offset; + __u32 cr_offset; + __u32 aux_offset; + __u32 frame_num; + __u32 flags; + + __u32 reserved; +} __attribute__((packed)); + +struct tegra_vde_h264_decoder_ctx { + __s32 bitstream_data_fd; + __u32 bitstream_data_offset; + + __u64 dpb_frames_ptr; + __u8 dpb_frames_nb; + __u8 dpb_ref_frames_with_earlier_poc_nb; + + // SPS + __u8 baseline_profile; + __u8 level_idc; + __u8 log2_max_pic_order_cnt_lsb; + __u8 log2_max_frame_num; + __u8 pic_order_cnt_type; + __u8 direct_8x8_inference_flag; + __u8 pic_width_in_mbs; + __u8 pic_height_in_mbs; + + // PPS + __u8 pic_init_qp; + __u8 deblocking_filter_control_present_flag; + __u8 constrained_intra_pred_flag; + __u8 chroma_qp_index_offset; + __u8 pic_order_present_flag; + + // Slice header + __u8 num_ref_idx_l0_active_minus1; + __u8 num_ref_idx_l1_active_minus1; + + __u32 reserved; +} __attribute__((packed)); + +#define VDE_IOCTL_BASE ('v' + 0x20) + +#define VDE_IO(nr) _IO(VDE_IOCTL_BASE, nr) +#define VDE_IOR(nr, type) _IOR(VDE_IOCTL_BASE, nr, type) +#define VDE_IOW(nr, type) _IOW(VDE_IOCTL_BASE, nr, type) +#define VDE_IOWR(nr, type) _IOWR(VDE_IOCTL_BASE, nr, type) + +#define TEGRA_VDE_DECODE_H264 0x00 + +#define TEGRA_VDE_IOCTL_DECODE_H264 \ + VDE_IOW(TEGRA_VDE_DECODE_H264, struct tegra_vde_h264_decoder_ctx) + +#endif // _UAPI_TEGRA_VDE_H_ -- GitLab From 5742240577b6726104844a099598f284c75772e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 16 Feb 2017 19:55:33 -0500 Subject: [PATCH 0183/1190] media: dvbsky: MyGica T230C support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mygica T230 DVB-T/T2/C USB stick support. It uses the same FX2/Si2168 bridge/demodulator combo as the other devices supported by the driver, but uses the Si2141 tuner. Several DVB-T (MPEG2) and DVB-T2 (H.265) channels were tested, as well as the included remote control. Signed-off-by: Stefan Brüns Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb-usb-ids.h | 1 + drivers/media/usb/dvb-usb-v2/dvbsky.c | 88 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h index d1954e6debe34..28e2be5c8a987 100644 --- a/drivers/media/dvb-core/dvb-usb-ids.h +++ b/drivers/media/dvb-core/dvb-usb-ids.h @@ -386,6 +386,7 @@ #define USB_PID_SONY_PLAYTV 0x0003 #define USB_PID_MYGICA_D689 0xd811 #define USB_PID_MYGICA_T230 0xc688 +#define USB_PID_MYGICA_T230C 0xc689 #define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011 #define USB_PID_ELGATO_EYETV_DTT 0x0021 #define USB_PID_ELGATO_EYETV_DTT_2 0x003f diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c index f90540f947f8c..43eb828845559 100644 --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c @@ -661,6 +661,65 @@ static int dvbsky_t330_attach(struct dvb_usb_adapter *adap) return ret; } +static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter *adap) +{ + struct dvbsky_state *state = adap_to_priv(adap); + struct dvb_usb_device *d = adap_to_d(adap); + struct i2c_adapter *i2c_adapter; + struct i2c_client *client_demod, *client_tuner; + struct i2c_board_info info; + struct si2168_config si2168_config; + struct si2157_config si2157_config; + + /* attach demod */ + memset(&si2168_config, 0, sizeof(si2168_config)); + si2168_config.i2c_adapter = &i2c_adapter; + si2168_config.fe = &adap->fe[0]; + si2168_config.ts_mode = SI2168_TS_PARALLEL; + si2168_config.ts_clock_inv = 1; + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "si2168", sizeof(info.type)); + info.addr = 0x64; + info.platform_data = &si2168_config; + + request_module("si2168"); + client_demod = i2c_new_device(&d->i2c_adap, &info); + if (!client_demod || !client_demod->dev.driver) + goto fail_demod_device; + if (!try_module_get(client_demod->dev.driver->owner)) + goto fail_demod_module; + + /* attach tuner */ + memset(&si2157_config, 0, sizeof(si2157_config)); + si2157_config.fe = adap->fe[0]; + si2157_config.if_port = 0; + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "si2141", sizeof(info.type)); + info.addr = 0x60; + info.platform_data = &si2157_config; + + request_module("si2157"); + client_tuner = i2c_new_device(i2c_adapter, &info); + if (!client_tuner || !client_tuner->dev.driver) + goto fail_tuner_device; + if (!try_module_get(client_tuner->dev.driver->owner)) + goto fail_tuner_module; + + state->i2c_client_demod = client_demod; + state->i2c_client_tuner = client_tuner; + return 0; + +fail_tuner_module: + i2c_unregister_device(client_tuner); +fail_tuner_device: + module_put(client_demod->dev.driver->owner); +fail_demod_module: + i2c_unregister_device(client_demod); +fail_demod_device: + return -ENODEV; +} + + static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name) { dvbsky_gpio_ctrl(d, 0x04, 1); @@ -826,6 +885,32 @@ static struct dvb_usb_device_properties dvbsky_t330_props = { } }; +static struct dvb_usb_device_properties mygica_t230c_props = { + .driver_name = KBUILD_MODNAME, + .owner = THIS_MODULE, + .adapter_nr = adapter_nr, + .size_of_priv = sizeof(struct dvbsky_state), + + .generic_bulk_ctrl_endpoint = 0x01, + .generic_bulk_ctrl_endpoint_response = 0x81, + .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY, + + .i2c_algo = &dvbsky_i2c_algo, + .frontend_attach = dvbsky_mygica_t230c_attach, + .init = dvbsky_init, + .get_rc_config = dvbsky_get_rc_config, + .streaming_ctrl = dvbsky_streaming_ctrl, + .identify_state = dvbsky_identify_state, + .exit = dvbsky_exit, + + .num_adapters = 1, + .adapter = { + { + .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096), + } + } +}; + static const struct usb_device_id dvbsky_id_table[] = { { DVB_USB_DEVICE(0x0572, 0x6831, &dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) }, @@ -858,6 +943,9 @@ static const struct usb_device_id dvbsky_id_table[] = { { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4, &dvbsky_s960_props, "Terratec Cinergy S2 Rev.4", RC_MAP_DVBSKY) }, + { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C, + &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C", + RC_MAP_TOTAL_MEDIA_IN_HAND_02) }, { } }; MODULE_DEVICE_TABLE(usb, dvbsky_id_table); -- GitLab From 3ee6229f1a16ad80ac83f02614f46b70b7ecf666 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 19 Sep 2017 21:09:18 -0400 Subject: [PATCH 0184/1190] media: siano: fix a potential integer overflow Add suffix ULL to constant 65535 in order to avoid a potential integer overflow. This constant is used in a context that expects an expression of type u64. Addresses-Coverity-ID: 1056806 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c index affde1426b7a2..166428cbd3c88 100644 --- a/drivers/media/common/siano/smsdvb-main.c +++ b/drivers/media/common/siano/smsdvb-main.c @@ -271,7 +271,7 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client, c->post_bit_count.stat[0].uvalue += p->ber_bit_count; /* Legacy PER/BER */ - tmp = p->ets_packets * 65535; + tmp = p->ets_packets * 65535ULL; if (p->ts_packets + p->ets_packets) do_div(tmp, p->ts_packets + p->ets_packets); client->legacy_per = tmp; -- GitLab From a24e6348e5a0e8562ad64d760c25907ed088611c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 20 Sep 2017 18:19:59 -0400 Subject: [PATCH 0185/1190] media: dvb_ca_en50221: sanity check slot number from userspace Currently a user can pass in an unsanitized slot number which will lead to and out of range index into ca->slot_info. Fix this by checking that the slot number is no more than the allowed maximum number of slots. Seems that this bug has been in the driver forever. Detected by CoverityScan, CID#139381 ("Untrusted pointer read") Signed-off-by: Colin Ian King Reviewed-by: Dan Carpenter Reviewed-by: Jasmin Jessich Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_ca_en50221.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c index d48b61eb01f4c..a3b2754e71247 100644 --- a/drivers/media/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb-core/dvb_ca_en50221.c @@ -1473,6 +1473,9 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, return -EFAULT; buf += 2; count -= 2; + + if (slot >= ca->slot_count) + return -EINVAL; sl = &ca->slot_info[slot]; /* check if the slot is actually running */ -- GitLab From 45392ff6881dbe56d41ef0b17c2e576065f8ffa1 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Thu, 21 Sep 2017 19:23:56 -0400 Subject: [PATCH 0186/1190] media: bt8xx: Fix err 'bt878_probe()' This is odd to call 'pci_disable_device()' in an error path before a coresponding successful 'pci_enable_device()'. Return directly instead. Fixes: 77e0be12100a ("V4L/DVB (4176): Bug-fix: Fix memory overflow") Signed-off-by: Christophe JAILLET Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bt878.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c index a5f52137d306a..d4bc78b4fcb5c 100644 --- a/drivers/media/pci/bt8xx/bt878.c +++ b/drivers/media/pci/bt8xx/bt878.c @@ -422,8 +422,7 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) bt878_num); if (bt878_num >= BT878_MAX) { printk(KERN_ERR "bt878: Too many devices inserted\n"); - result = -ENOMEM; - goto fail0; + return -ENOMEM; } if (pci_enable_device(dev)) return -EIO; -- GitLab From ef94711a04027066c4ae77d3477a5a4e0ba0784f Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 12 Oct 2017 12:04:44 -0400 Subject: [PATCH 0187/1190] media: xilinx-video: fix bad of_node_put() on endpoint error When iterating through all endpoints using of_graph_get_next_endpoint(), the refcount of the returned endpoint node is incremented and the refcount of the node which is passed as previous endpoint is decremented. So the caller doesn't need to call of_node_put() for each iterated node except for error exit paths. Otherwise we get "OF: ERROR: Bad of_node_put() on ..." messages. Cc: Hyun Kwon Signed-off-by: Akinobu Mita Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/xilinx/xilinx-vipp.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index d881cf09876db..f4c3e48ed2c06 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -76,20 +76,16 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, struct xvip_graph_entity *ent; struct v4l2_fwnode_link link; struct device_node *ep = NULL; - struct device_node *next; int ret = 0; dev_dbg(xdev->dev, "creating links for entity %s\n", local->name); while (1) { /* Get the next endpoint and parse its link. */ - next = of_graph_get_next_endpoint(entity->node, ep); - if (next == NULL) + ep = of_graph_get_next_endpoint(entity->node, ep); + if (ep == NULL) break; - of_node_put(ep); - ep = next; - dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); @@ -200,7 +196,6 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) struct xvip_graph_entity *ent; struct v4l2_fwnode_link link; struct device_node *ep = NULL; - struct device_node *next; struct xvip_dma *dma; int ret = 0; @@ -208,13 +203,10 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) while (1) { /* Get the next endpoint and parse its link. */ - next = of_graph_get_next_endpoint(node, ep); - if (next == NULL) + ep = of_graph_get_next_endpoint(node, ep); + if (ep == NULL) break; - of_node_put(ep); - ep = next; - dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); -- GitLab From afc7f24c01034b7820365d9fa64822504b4dc35d Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 18 Oct 2017 09:39:12 -0400 Subject: [PATCH 0188/1190] media: rc: i2c: set parent of rc device and improve name With the parent set for the rc device, the messages clearly state that it is attached via i2c. The additional printk is unnecessary. These are the old messages: rc rc1: i2c IR (Hauppauge WinTV PVR-150 as /devices/virtual/rc/rc1 ir-kbd-i2c: i2c IR (Hauppauge WinTV PVR-150 detected at i2c-10/10-0071/ir0 [ivtv i2c driver #0] Now we simply get: rc rc1: Hauppauge WinTV PVR-150 as /devices/pci0000:00/0000:00:1e.0/0000:02:00.0/i2c-10/10-0071/rc/rc1 Note that we no longer copy the name. I've checked all call sites to verfiy this is not a problem. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 11 +++-------- drivers/media/pci/saa7134/saa7134-input.c | 3 ++- include/media/i2c/ir-kbd-i2c.h | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 8b5f7d0435e43..27e36f45286cf 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -439,12 +439,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) goto err_out_free; } - /* Sets name */ - snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name); ir->ir_codes = ir_codes; - snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0", - dev_name(&adap->dev), + snprintf(ir->phys, sizeof(ir->phys), "%s/%s", dev_name(&adap->dev), dev_name(&client->dev)); /* @@ -453,7 +450,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) */ rc->input_id.bustype = BUS_I2C; rc->input_phys = ir->phys; - rc->device_name = ir->name; + rc->device_name = name; + rc->dev.parent = &client->dev; /* * Initialize the other fields of rc_dev @@ -467,9 +465,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) if (err) goto err_out_free; - printk(MODULE_NAME ": %s detected at %s [%s]\n", - ir->name, ir->phys, adap->name); - /* start polling via eventd */ INIT_DELAYED_WORK(&ir->work, ir_work); schedule_delayed_work(&ir->work, 0); diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c index 2d5abeddc0795..33ee8322895e0 100644 --- a/drivers/media/pci/saa7134/saa7134-input.c +++ b/drivers/media/pci/saa7134/saa7134-input.c @@ -43,7 +43,8 @@ MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=g } while (0) #define ir_dbg(ir, fmt, arg...) do { \ if (ir_debug) \ - printk(KERN_DEBUG pr_fmt("ir %s: " fmt), ir->name, ## arg); \ + printk(KERN_DEBUG pr_fmt("ir %s: " fmt), ir->rc->device_name, \ + ## arg); \ } while (0) /* Helper function for raw decoding at GPIO16 or GPIO18 */ diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h index 76491c62c2545..1a9df1ae533fe 100644 --- a/include/media/i2c/ir-kbd-i2c.h +++ b/include/media/i2c/ir-kbd-i2c.h @@ -19,7 +19,6 @@ struct IR_i2c { u32 polling_interval; /* in ms */ struct delayed_work work; - char name[32]; char phys[32]; int (*get_key)(struct IR_i2c *ir, enum rc_proto *protocol, -- GitLab From 50a762b413ad7ed137e75b79b1aa50cf4b1e2b73 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 18 Oct 2017 10:00:50 -0400 Subject: [PATCH 0189/1190] media: rc: i2c: use dev_dbg rather hand-rolled debug Use the dev_dbg dynamic infrastructure instead of rolling our own custom debug logic. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 61 ++++++++++++++-------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 27e36f45286cf..1b8cd1b75bfbf 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -46,18 +46,6 @@ #include #include -/* ----------------------------------------------------------------------- */ -/* insmod parameters */ - -static int debug; -module_param(debug, int, 0644); /* debug level (0,1,2) */ - - -#define MODULE_NAME "ir-kbd-i2c" -#define dprintk(level, fmt, arg...) if (debug >= level) \ - printk(KERN_DEBUG MODULE_NAME ": " fmt , ## arg) - -/* ----------------------------------------------------------------------- */ static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, u32 *scancode, u8 *ptoggle, int size) @@ -96,7 +84,8 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, if (!range) code += 64; - dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", + dev_dbg(&ir->rc->dev, + "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", start, range, toggle, dev, code); *protocol = RC_PROTO_RC5; @@ -113,13 +102,15 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, *ptoggle = (dev & 0x80) != 0; *protocol = RC_PROTO_RC6_MCE; dev &= 0x7f; - dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n", - *ptoggle, vendor, dev, code); + dev_dbg(&ir->rc->dev, + "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n", + *ptoggle, vendor, dev, code); } else { *ptoggle = 0; *protocol = RC_PROTO_RC6_6A_32; - dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n", - vendor, dev, code); + dev_dbg(&ir->rc->dev, + "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n", + vendor, dev, code); } *scancode = RC_SCANCODE_RC6_6A(vendor, dev, code); @@ -162,7 +153,7 @@ static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, /* poll IR chip */ if (1 != i2c_master_recv(ir->c, &b, 1)) { - dprintk(1,"read error\n"); + dev_dbg(&ir->rc->dev, "read error\n"); return -EIO; } @@ -179,13 +170,12 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, /* poll IR chip */ if (4 != i2c_master_recv(ir->c, buf, 4)) { - dprintk(1,"read error\n"); + dev_dbg(&ir->rc->dev, "read error\n"); return -EIO; } - if(buf[0] !=0 || buf[1] !=0 || buf[2] !=0 || buf[3] != 0) - dprintk(2, "%s: 0x%2x 0x%2x 0x%2x 0x%2x\n", __func__, - buf[0], buf[1], buf[2], buf[3]); + if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0 || buf[3] != 0) + dev_dbg(&ir->rc->dev, "%s: %*ph\n", __func__, 4, buf); /* no key pressed or signal from other ir remote */ if(buf[0] != 0x1 || buf[1] != 0xfe) @@ -204,7 +194,7 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, /* poll IR chip */ if (1 != i2c_master_recv(ir->c, &b, 1)) { - dprintk(1,"read error\n"); + dev_dbg(&ir->rc->dev, "read error\n"); return -EIO; } @@ -212,7 +202,7 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, down, while 0xff indicates that no button is hold down. 0xfe sequences are sometimes interrupted by 0xFF */ - dprintk(2,"key %02x\n", b); + dev_dbg(&ir->rc->dev, "key %02x\n", b); if (b == 0xff) return 0; @@ -237,7 +227,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol, .buf = &key, .len = 1} }; subaddr = 0x0d; if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { - dprintk(1, "read error\n"); + dev_dbg(&ir->rc->dev, "read error\n"); return -EIO; } @@ -247,18 +237,17 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol, subaddr = 0x0b; msg[1].buf = &keygroup; if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { - dprintk(1, "read error\n"); + dev_dbg(&ir->rc->dev, "read error\n"); return -EIO; } if (keygroup == 0xff) return 0; - dprintk(1, "read key 0x%02x/0x%02x\n", key, keygroup); + dev_dbg(&ir->rc->dev, "read key 0x%02x/0x%02x\n", key, keygroup); if (keygroup < 2 || keygroup > 4) { - /* Only a warning */ - dprintk(1, "warning: invalid key group 0x%02x for key 0x%02x\n", - keygroup, key); + dev_warn(&ir->rc->dev, "warning: invalid key group 0x%02x for key 0x%02x\n", + keygroup, key); } key |= (keygroup & 1) << 6; @@ -279,15 +268,15 @@ static int ir_key_poll(struct IR_i2c *ir) u8 toggle; int rc; - dprintk(3, "%s\n", __func__); + dev_dbg(&ir->rc->dev, "%s\n", __func__); rc = ir->get_key(ir, &protocol, &scancode, &toggle); if (rc < 0) { - dprintk(2,"error\n"); + dev_warn(&ir->rc->dev, "error %d\n", rc); return rc; } if (rc) { - dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n", + dev_dbg(&ir->rc->dev, "%s: proto = 0x%04x, scancode = 0x%08x\n", __func__, protocol, scancode); rc_keydown(ir->rc, protocol, scancode, toggle); } @@ -433,8 +422,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Make sure we are all setup before going on */ if (!name || !ir->get_key || !rc_proto || !ir_codes) { - dprintk(1, ": Unsupported device at address 0x%02x\n", - addr); + dev_warn(&client->dev, "Unsupported device at address 0x%02x\n", + addr); err = -ENODEV; goto err_out_free; } @@ -459,7 +448,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) rc->map_name = ir->ir_codes; rc->allowed_protocols = rc_proto; if (!rc->driver_name) - rc->driver_name = MODULE_NAME; + rc->driver_name = KBUILD_MODNAME; err = rc_register_device(rc); if (err) -- GitLab From a6927d81c0073c89a468ff558212f230941a941f Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 17 Oct 2017 16:31:20 -0400 Subject: [PATCH 0190/1190] media: rc: i2c: only poll if the rc device is opened The lirc_zilog driver only polls the device if the lirc chardev is opened; do the same with the rc-core driver. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 1b8cd1b75bfbf..22f32717638a8 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -298,6 +298,22 @@ static void ir_work(struct work_struct *work) schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval)); } +static int ir_open(struct rc_dev *dev) +{ + struct IR_i2c *ir = dev->priv; + + schedule_delayed_work(&ir->work, 0); + + return 0; +} + +static void ir_close(struct rc_dev *dev) +{ + struct IR_i2c *ir = dev->priv; + + cancel_delayed_work_sync(&ir->work); +} + /* ----------------------------------------------------------------------- */ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) @@ -441,6 +457,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) rc->input_phys = ir->phys; rc->device_name = name; rc->dev.parent = &client->dev; + rc->priv = ir; + rc->open = ir_open; + rc->close = ir_close; /* * Initialize the other fields of rc_dev @@ -450,14 +469,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!rc->driver_name) rc->driver_name = KBUILD_MODNAME; + INIT_DELAYED_WORK(&ir->work, ir_work); + err = rc_register_device(rc); if (err) goto err_out_free; - /* start polling via eventd */ - INIT_DELAYED_WORK(&ir->work, ir_work); - schedule_delayed_work(&ir->work, 0); - return 0; err_out_free: -- GitLab From ab5222ed1691b522b196624794a904c879033afb Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 12 Oct 2017 18:02:57 -0400 Subject: [PATCH 0191/1190] media: merge ir_tx_z8f0811_haup and ir_rx_z8f0811_haup i2c devices These two devices ids are really just one device with multiple addresses. Probing becomes much simpler if we simply fold this into one i2c device with two address. Note that this breaks the lirc_zilog driver, however we will teach ir-kbd-i2c to do what lirc_zilog does in a later commit. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 4 ++-- drivers/media/pci/cx18/cx18-cards.h | 8 +------ drivers/media/pci/cx18/cx18-i2c.c | 13 +++++------ drivers/media/pci/ivtv/ivtv-cards.h | 22 ++++++------------- drivers/media/pci/ivtv/ivtv-i2c.c | 20 ++++------------- drivers/media/usb/hdpvr/hdpvr-core.c | 11 ++-------- drivers/media/usb/hdpvr/hdpvr-i2c.c | 23 +++++--------------- drivers/media/usb/hdpvr/hdpvr.h | 3 +-- drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 13 +++-------- 9 files changed, 30 insertions(+), 87 deletions(-) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 22f32717638a8..ec669ec4cfc5f 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -501,8 +501,8 @@ static const struct i2c_device_id ir_kbd_id[] = { /* Generic entry for any IR receiver */ { "ir_video", 0 }, /* IR device specific entries should be added here */ - { "ir_rx_z8f0811_haup", 0 }, - { "ir_rx_z8f0811_hdpvr", 0 }, + { "ir_z8f0811_haup", 0 }, + { "ir_z8f0811_hdpvr", 0 }, { } }; diff --git a/drivers/media/pci/cx18/cx18-cards.h b/drivers/media/pci/cx18/cx18-cards.h index 667e2d7b1d037..5478f62b5cf3d 100644 --- a/drivers/media/pci/cx18/cx18-cards.h +++ b/drivers/media/pci/cx18/cx18-cards.h @@ -25,13 +25,7 @@ #define CX18_HW_418_AV (1 << 4) #define CX18_HW_GPIO_MUX (1 << 5) #define CX18_HW_GPIO_RESET_CTRL (1 << 6) -#define CX18_HW_Z8F0811_IR_TX_HAUP (1 << 7) -#define CX18_HW_Z8F0811_IR_RX_HAUP (1 << 8) -#define CX18_HW_Z8F0811_IR_HAUP (CX18_HW_Z8F0811_IR_RX_HAUP | \ - CX18_HW_Z8F0811_IR_TX_HAUP) - -#define CX18_HW_IR_ANY (CX18_HW_Z8F0811_IR_RX_HAUP | \ - CX18_HW_Z8F0811_IR_TX_HAUP) +#define CX18_HW_Z8F0811_IR_HAUP (1 << 7) /* video inputs */ #define CX18_CARD_INPUT_VID_TUNER 1 diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c index 7f588eeac60fa..f0eb181f2b949 100644 --- a/drivers/media/pci/cx18/cx18-i2c.c +++ b/drivers/media/pci/cx18/cx18-i2c.c @@ -47,8 +47,7 @@ static const u8 hw_addrs[] = { 0, /* CX18_HW_418_AV */ 0, /* CX18_HW_GPIO_MUX */ 0, /* CX18_HW_GPIO_RESET_CTRL */ - CX18_Z8F0811_IR_TX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_TX_HAUP */ - CX18_Z8F0811_IR_RX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_RX_HAUP */ + CX18_Z8F0811_IR_RX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_HAUP */ }; /* This array should match the CX18_HW_ defines */ @@ -61,8 +60,7 @@ static const u8 hw_bus[] = { 0, /* CX18_HW_418_AV */ 0, /* CX18_HW_GPIO_MUX */ 0, /* CX18_HW_GPIO_RESET_CTRL */ - 0, /* CX18_HW_Z8F0811_IR_TX_HAUP */ - 0, /* CX18_HW_Z8F0811_IR_RX_HAUP */ + 0, /* CX18_HW_Z8F0811_IR_HAUP */ }; /* This array should match the CX18_HW_ defines */ @@ -74,8 +72,7 @@ static const char * const hw_devicenames[] = { "cx23418_AV", "gpio_mux", "gpio_reset_ctrl", - "ir_tx_z8f0811_haup", - "ir_rx_z8f0811_haup", + "ir_z8f0811_haup", }; static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw, @@ -90,7 +87,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw, /* Our default information for ir-kbd-i2c.c to use */ switch (hw) { - case CX18_HW_Z8F0811_IR_RX_HAUP: + case CX18_HW_Z8F0811_IR_HAUP: init_data->ir_codes = RC_MAP_HAUPPAUGE; init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE | @@ -129,7 +126,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx) return sd != NULL ? 0 : -1; } - if (hw & CX18_HW_IR_ANY) + if (hw == CX18_HW_Z8F0811_IR_HAUP) return cx18_i2c_new_ir(cx, adap, hw, type, hw_addrs[idx]); /* Is it not an I2C device or one we do not wish to register? */ diff --git a/drivers/media/pci/ivtv/ivtv-cards.h b/drivers/media/pci/ivtv/ivtv-cards.h index e6f5c02981f1e..06e7b4ed64448 100644 --- a/drivers/media/pci/ivtv/ivtv-cards.h +++ b/drivers/media/pci/ivtv/ivtv-cards.h @@ -109,24 +109,16 @@ #define IVTV_HW_I2C_IR_RX_AVER (1 << 16) #define IVTV_HW_I2C_IR_RX_HAUP_EXT (1 << 17) /* External before internal */ #define IVTV_HW_I2C_IR_RX_HAUP_INT (1 << 18) -#define IVTV_HW_Z8F0811_IR_TX_HAUP (1 << 19) -#define IVTV_HW_Z8F0811_IR_RX_HAUP (1 << 20) -#define IVTV_HW_I2C_IR_RX_ADAPTEC (1 << 21) - -#define IVTV_HW_Z8F0811_IR_HAUP (IVTV_HW_Z8F0811_IR_RX_HAUP | \ - IVTV_HW_Z8F0811_IR_TX_HAUP) +#define IVTV_HW_Z8F0811_IR_HAUP (1 << 19) +#define IVTV_HW_I2C_IR_RX_ADAPTEC (1 << 20) #define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114) -#define IVTV_HW_IR_RX_ANY (IVTV_HW_I2C_IR_RX_AVER | \ - IVTV_HW_I2C_IR_RX_HAUP_EXT | \ - IVTV_HW_I2C_IR_RX_HAUP_INT | \ - IVTV_HW_Z8F0811_IR_RX_HAUP | \ - IVTV_HW_I2C_IR_RX_ADAPTEC) - -#define IVTV_HW_IR_TX_ANY (IVTV_HW_Z8F0811_IR_TX_HAUP) - -#define IVTV_HW_IR_ANY (IVTV_HW_IR_RX_ANY | IVTV_HW_IR_TX_ANY) +#define IVTV_HW_IR_ANY (IVTV_HW_I2C_IR_RX_AVER | \ + IVTV_HW_I2C_IR_RX_HAUP_EXT | \ + IVTV_HW_I2C_IR_RX_HAUP_INT | \ + IVTV_HW_Z8F0811_IR_HAUP | \ + IVTV_HW_I2C_IR_RX_ADAPTEC) /* video inputs */ #define IVTV_CARD_INPUT_VID_TUNER 1 diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c index 893962ac85deb..66696e6ee587c 100644 --- a/drivers/media/pci/ivtv/ivtv-i2c.c +++ b/drivers/media/pci/ivtv/ivtv-i2c.c @@ -117,8 +117,7 @@ static const u8 hw_addrs[] = { IVTV_AVERMEDIA_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_AVER */ IVTV_HAUP_EXT_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_HAUP_EXT */ IVTV_HAUP_INT_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_HAUP_INT */ - IVTV_Z8F0811_IR_TX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_TX_HAUP */ - IVTV_Z8F0811_IR_RX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_RX_HAUP */ + IVTV_Z8F0811_IR_RX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_HAUP */ IVTV_ADAPTEC_IR_ADDR, /* IVTV_HW_I2C_IR_RX_ADAPTEC */ }; @@ -143,8 +142,7 @@ static const char * const hw_devicenames[] = { "ir_video", /* IVTV_HW_I2C_IR_RX_AVER */ "ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_EXT */ "ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_INT */ - "ir_tx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_TX_HAUP */ - "ir_rx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_RX_HAUP */ + "ir_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_HAUP */ "ir_video", /* IVTV_HW_I2C_IR_RX_ADAPTEC */ }; @@ -181,18 +179,8 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data; unsigned short addr_list[2] = { addr, I2C_CLIENT_END }; - /* Only allow one IR transmitter to be registered per board */ - if (hw & IVTV_HW_IR_TX_ANY) { - if (itv->hw_flags & IVTV_HW_IR_TX_ANY) - return -1; - memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, type, I2C_NAME_SIZE); - return i2c_new_probed_device(adap, &info, addr_list, NULL) - == NULL ? -1 : 0; - } - /* Only allow one IR receiver to be registered per board */ - if (itv->hw_flags & IVTV_HW_IR_RX_ANY) + if (itv->hw_flags & IVTV_HW_IR_ANY) return -1; /* Our default information for ir-kbd-i2c.c to use */ @@ -211,7 +199,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) init_data->type = RC_PROTO_BIT_RC5; init_data->name = itv->card_name; break; - case IVTV_HW_Z8F0811_IR_RX_HAUP: + case IVTV_HW_Z8F0811_IR_HAUP: /* Default to grey remote */ init_data->ir_codes = RC_MAP_HAUPPAUGE; init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index 1e8cbaf368961..29ac7fc5b039f 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -364,16 +364,9 @@ static int hdpvr_probe(struct usb_interface *interface, goto error_free_buffers; } - client = hdpvr_register_ir_rx_i2c(dev); + client = hdpvr_register_ir_i2c(dev); if (!client) { - v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n"); - retval = -ENODEV; - goto reg_fail; - } - - client = hdpvr_register_ir_tx_i2c(dev); - if (!client) { - v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n"); + v4l2_err(&dev->v4l2_dev, "i2c IR device register failed\n"); retval = -ENODEV; goto reg_fail; } diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c index 1db49ed5eaf1a..4720d79b02823 100644 --- a/drivers/media/usb/hdpvr/hdpvr-i2c.c +++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c @@ -32,24 +32,11 @@ #define Z8F0811_IR_RX_I2C_ADDR 0x71 -struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev) +struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev) { struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; - struct i2c_board_info hdpvr_ir_tx_i2c_board_info = { - I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR), - }; - - init_data->name = "HD-PVR"; - hdpvr_ir_tx_i2c_board_info.platform_data = init_data; - - return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_tx_i2c_board_info); -} - -struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev) -{ - struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; - struct i2c_board_info hdpvr_ir_rx_i2c_board_info = { - I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR), + struct i2c_board_info info = { + I2C_BOARD_INFO("ir_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR), }; /* Our default information for ir-kbd-i2c.c to use */ @@ -59,9 +46,9 @@ struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev) RC_PROTO_BIT_RC6_6A_32; init_data->name = "HD-PVR"; init_data->polling_interval = 405; /* ms, duplicated from Windows */ - hdpvr_ir_rx_i2c_board_info.platform_data = init_data; + info.platform_data = init_data; - return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_rx_i2c_board_info); + return i2c_new_device(&dev->i2c_adapter, &info); } static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus, diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h index a12e0af1d4e15..96e36a8e5f437 100644 --- a/drivers/media/usb/hdpvr/hdpvr.h +++ b/drivers/media/usb/hdpvr/hdpvr.h @@ -320,8 +320,7 @@ int hdpvr_cancel_queue(struct hdpvr_device *dev); /* i2c adapter registration */ int hdpvr_register_i2c_adapter(struct hdpvr_device *dev); -struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev); -struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev); +struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev); /*========================================================================*/ /* buffer management */ diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c index ff7b4d1d385d5..f3003ca05f4ba 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c @@ -585,17 +585,10 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_RC6_6A_32; init_data->name = hdw->hdw_desc->description; - /* IR Receiver */ - info.addr = 0x71; - info.platform_data = init_data; - strlcpy(info.type, "ir_rx_z8f0811_haup", I2C_NAME_SIZE); - pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.", - info.type, info.addr); - i2c_new_device(&hdw->i2c_adap, &info); - /* IR Trasmitter */ - info.addr = 0x70; + /* IR Transceiver */ + info.addr = 0x71; info.platform_data = init_data; - strlcpy(info.type, "ir_tx_z8f0811_haup", I2C_NAME_SIZE); + strlcpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE); pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.", info.type, info.addr); i2c_new_device(&hdw->i2c_adap, &info); -- GitLab From acaa34bf06e963f0b9481a3c16bfd6867e2369a0 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 21 Oct 2017 08:16:47 -0400 Subject: [PATCH 0192/1190] media: rc: implement zilog transmitter This code implements the transmitter which is currently implemented in the staging lirc_zilog driver. The new code does not need a signal database, iow. the haup-ir-blaster.bin firmware file is no longer needed, and the driver does not know anything about the keycodes in that file. Instead, the new driver can send raw IR, but the hardware is limited to few different lengths of pulse and spaces, so it is best to use generated IR rather than recorded IR. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 436 ++++++++++++++++++++++++++++++++- include/media/i2c/ir-kbd-i2c.h | 5 + 2 files changed, 433 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index ec669ec4cfc5f..020ef0d7058e7 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -18,6 +18,20 @@ * Brian Rogers * modified for AVerMedia Cardbus by * Oldrich Jedlicka + * Zilog Transmitter portions/ideas were derived from GPLv2+ sources: + * - drivers/char/pctv_zilogir.[ch] from Hauppauge Broadway product + * Copyright 2011 Hauppauge Computer works + * - drivers/staging/media/lirc/lirc_zilog.c + * Copyright (c) 2000 Gerd Knorr + * Michal Kochanowicz + * Christoph Bartelmus + * Ulrich Mueller + * Stefan Jahn + * Jerome Brock + * Thomas Reitmayr (treitmayr@yahoo.com) + * Mark Weaver + * Jarod Wilson + * Copyright (C) 2011 Andy Walls * * 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 @@ -46,6 +60,8 @@ #include #include +#define FLAG_TX 1 +#define FLAG_HDPVR 2 static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, u32 *scancode, u8 *ptoggle, int size) @@ -288,11 +304,18 @@ static void ir_work(struct work_struct *work) int rc; struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work); - rc = ir_key_poll(ir); - if (rc == -ENODEV) { - rc_unregister_device(ir->rc); - ir->rc = NULL; - return; + /* + * If the transmit code is holding the lock, skip polling for + * IR, we'll get it to it next time round + */ + if (mutex_trylock(&ir->lock)) { + rc = ir_key_poll(ir); + mutex_unlock(&ir->lock); + if (rc == -ENODEV) { + rc_unregister_device(ir->rc); + ir->rc = NULL; + return; + } } schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval)); @@ -314,7 +337,383 @@ static void ir_close(struct rc_dev *dev) cancel_delayed_work_sync(&ir->work); } -/* ----------------------------------------------------------------------- */ +/* Zilog Transmit Interface */ +#define XTAL_FREQ 18432000 + +#define ZILOG_SEND 0x80 +#define ZILOG_UIR_END 0x40 +#define ZILOG_INIT_END 0x20 +#define ZILOG_LIR_END 0x10 + +#define ZILOG_STATUS_OK 0x80 +#define ZILOG_STATUS_TX 0x40 +#define ZILOG_STATUS_SET 0x20 + +/* + * As you can see here, very few different lengths of pulse and space + * can be encoded. This means that the hardware does not work well with + * recorded IR. It's best to work with generated IR, like from ir-ctl or + * the in-kernel encoders. + */ +struct code_block { + u8 length; + u16 pulse[7]; /* not aligned */ + u8 carrier_pulse; + u8 carrier_space; + u16 space[8]; /* not aligned */ + u8 codes[61]; + u8 csum[2]; +} __packed; + +static int send_data_block(struct IR_i2c *ir, int cmd, + struct code_block *code_block) +{ + int i, j, ret; + u8 buf[5], *p; + + p = &code_block->length; + for (i = 0; p < code_block->csum; i++) + code_block->csum[i & 1] ^= *p++; + + p = &code_block->length; + + for (i = 0; i < sizeof(*code_block);) { + int tosend = sizeof(*code_block) - i; + + if (tosend > 4) + tosend = 4; + buf[0] = i + 1; + for (j = 0; j < tosend; ++j) + buf[1 + j] = p[i + j]; + dev_dbg(&ir->rc->dev, "%*ph", tosend + 1, buf); + ret = i2c_master_send(ir->tx_c, buf, tosend + 1); + if (ret != tosend + 1) { + dev_dbg(&ir->rc->dev, + "i2c_master_send failed with %d\n", ret); + return ret < 0 ? ret : -EIO; + } + i += tosend; + } + + buf[0] = 0; + buf[1] = cmd; + ret = i2c_master_send(ir->tx_c, buf, 2); + if (ret != 2) { + dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); + return ret < 0 ? ret : -EIO; + } + + usleep_range(2000, 5000); + + ret = i2c_master_send(ir->tx_c, buf, 1); + if (ret != 1) { + dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); + return ret < 0 ? ret : -EIO; + } + + return 0; +} + +static int zilog_init(struct IR_i2c *ir) +{ + struct code_block code_block = { .length = sizeof(code_block) }; + u8 buf[4]; + int ret; + + put_unaligned_be16(0x1000, &code_block.pulse[3]); + + ret = send_data_block(ir, ZILOG_INIT_END, &code_block); + if (ret) + return ret; + + ret = i2c_master_recv(ir->tx_c, buf, 4); + if (ret != 4) { + dev_err(&ir->c->dev, "failed to retrieve firmware version: %d\n", + ret); + return ret < 0 ? ret : -EIO; + } + + dev_info(&ir->c->dev, "Zilog/Hauppauge IR blaster firmware version %d.%d.%d\n", + buf[1], buf[2], buf[3]); + + return 0; +} + +/* + * If the last slot for pulse is the same as the current slot for pulse, + * then use slot no 7. + */ +static void copy_codes(u8 *dst, u8 *src, unsigned int count) +{ + u8 c, last = 0xff; + + while (count--) { + c = *src++; + if ((c & 0xf0) == last) { + *dst++ = 0x70 | (c & 0xf); + } else { + *dst++ = c; + last = c & 0xf0; + } + } +} + +/* + * When looking for repeats, we don't care about the trailing space. This + * is set to the shortest possible anyway. + */ +static int cmp_no_trail(u8 *a, u8 *b, unsigned int count) +{ + while (--count) { + if (*a++ != *b++) + return 1; + } + + return (*a & 0xf0) - (*b & 0xf0); +} + +static int find_slot(u16 *array, unsigned int size, u16 val) +{ + int i; + + for (i = 0; i < size; i++) { + if (get_unaligned_be16(&array[i]) == val) { + return i; + } else if (!array[i]) { + put_unaligned_be16(val, &array[i]); + return i; + } + } + + return -1; +} + +static int zilog_ir_format(struct rc_dev *rcdev, unsigned int *txbuf, + unsigned int count, struct code_block *code_block) +{ + struct IR_i2c *ir = rcdev->priv; + int rep, i, l, p = 0, s, c = 0; + bool repeating; + u8 codes[174]; + + code_block->carrier_pulse = DIV_ROUND_CLOSEST( + ir->duty_cycle * XTAL_FREQ / 1000, ir->carrier); + code_block->carrier_space = DIV_ROUND_CLOSEST( + (100 - ir->duty_cycle) * XTAL_FREQ / 1000, ir->carrier); + + for (i = 0; i < count; i++) { + if (c >= ARRAY_SIZE(codes) - 1) { + dev_warn(&rcdev->dev, "IR too long, cannot transmit\n"); + return -EINVAL; + } + + /* + * Lengths more than 142220us cannot be encoded; also + * this checks for multiply overflow + */ + if (txbuf[i] > 142220) + return -EINVAL; + + l = DIV_ROUND_CLOSEST((XTAL_FREQ / 1000) * txbuf[i], 40000); + + if (i & 1) { + s = find_slot(code_block->space, + ARRAY_SIZE(code_block->space), l); + if (s == -1) { + dev_warn(&rcdev->dev, "Too many different lengths spaces, cannot transmit"); + return -EINVAL; + } + + /* We have a pulse and space */ + codes[c++] = (p << 4) | s; + } else { + p = find_slot(code_block->pulse, + ARRAY_SIZE(code_block->pulse), l); + if (p == -1) { + dev_warn(&rcdev->dev, "Too many different lengths pulses, cannot transmit"); + return -EINVAL; + } + } + } + + /* We have to encode the trailing pulse. Find the shortest space */ + s = 0; + for (i = 1; i < ARRAY_SIZE(code_block->space); i++) { + u16 d = get_unaligned_be16(&code_block->space[i]); + + if (get_unaligned_be16(&code_block->space[s]) > d) + s = i; + } + + codes[c++] = (p << 4) | s; + + dev_dbg(&rcdev->dev, "generated %d codes\n", c); + + /* + * Are the last N codes (so pulse + space) repeating 3 times? + * if so we can shorten the codes list and use code 0xc0 to repeat + * them. + */ + repeating = false; + + for (rep = c / 3; rep >= 1; rep--) { + if (!memcmp(&codes[c - rep * 3], &codes[c - rep * 2], rep) && + !cmp_no_trail(&codes[c - rep], &codes[c - rep * 2], rep)) { + repeating = true; + break; + } + } + + if (repeating) { + /* first copy any leading non-repeating */ + int leading = c - rep * 3; + + if (leading + rep >= ARRAY_SIZE(code_block->codes) - 3) { + dev_warn(&rcdev->dev, "IR too long, cannot transmit\n"); + return -EINVAL; + } + + dev_dbg(&rcdev->dev, "found trailing %d repeat\n", rep); + copy_codes(code_block->codes, codes, leading); + code_block->codes[leading] = 0x82; + copy_codes(code_block->codes + leading + 1, codes + leading, + rep); + c = leading + 1 + rep; + code_block->codes[c++] = 0xc0; + } else { + if (c >= ARRAY_SIZE(code_block->codes) - 3) { + dev_warn(&rcdev->dev, "IR too long, cannot transmit\n"); + return -EINVAL; + } + + dev_dbg(&rcdev->dev, "found no trailing repeat\n"); + code_block->codes[0] = 0x82; + copy_codes(code_block->codes + 1, codes, c); + c++; + code_block->codes[c++] = 0xc4; + } + + while (c < ARRAY_SIZE(code_block->codes)) + code_block->codes[c++] = 0x83; + + return 0; +} + +static int zilog_tx(struct rc_dev *rcdev, unsigned int *txbuf, + unsigned int count) +{ + struct IR_i2c *ir = rcdev->priv; + struct code_block code_block = { .length = sizeof(code_block) }; + u8 buf[2]; + int ret, i; + + ret = zilog_ir_format(rcdev, txbuf, count, &code_block); + if (ret) + return ret; + + ret = mutex_lock_interruptible(&ir->lock); + if (ret) + return ret; + + ret = send_data_block(ir, ZILOG_UIR_END, &code_block); + if (ret) + goto out_unlock; + + ret = i2c_master_recv(ir->tx_c, buf, 1); + if (ret != 1) { + dev_err(&ir->rc->dev, "i2c_master_recv failed with %d\n", ret); + goto out_unlock; + } + + dev_dbg(&ir->rc->dev, "code set status: %02x\n", buf[0]); + + if (buf[0] != (ZILOG_STATUS_OK | ZILOG_STATUS_SET)) { + dev_err(&ir->rc->dev, "unexpected IR TX response %02x\n", + buf[0]); + ret = -EIO; + goto out_unlock; + } + + buf[0] = 0x00; + buf[1] = ZILOG_SEND; + + ret = i2c_master_send(ir->tx_c, buf, 2); + if (ret != 2) { + dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); + if (ret >= 0) + ret = -EIO; + goto out_unlock; + } + + dev_dbg(&ir->rc->dev, "send command sent\n"); + + /* + * This bit NAKs until the device is ready, so we retry it + * sleeping a bit each time. This seems to be what the windows + * driver does, approximately. + * Try for up to 1s. + */ + for (i = 0; i < 20; ++i) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(msecs_to_jiffies(50)); + ret = i2c_master_send(ir->tx_c, buf, 1); + if (ret == 1) + break; + dev_dbg(&ir->rc->dev, + "NAK expected: i2c_master_send failed with %d (try %d)\n", + ret, i + 1); + } + + if (ret != 1) { + dev_err(&ir->rc->dev, + "IR TX chip never got ready: last i2c_master_send failed with %d\n", + ret); + if (ret >= 0) + ret = -EIO; + goto out_unlock; + } + + i = i2c_master_recv(ir->tx_c, buf, 1); + if (i != 1) { + dev_err(&ir->rc->dev, "i2c_master_recv failed with %d\n", ret); + ret = -EIO; + goto out_unlock; + } else if (buf[0] != ZILOG_STATUS_OK) { + dev_err(&ir->rc->dev, "unexpected IR TX response #2: %02x\n", + buf[0]); + ret = -EIO; + goto out_unlock; + } + dev_dbg(&ir->rc->dev, "transmit complete\n"); + + /* Oh good, it worked */ + ret = count; +out_unlock: + mutex_unlock(&ir->lock); + + return ret; +} + +static int zilog_tx_carrier(struct rc_dev *dev, u32 carrier) +{ + struct IR_i2c *ir = dev->priv; + + if (carrier > 500000 || carrier < 20000) + return -EINVAL; + + ir->carrier = carrier; + + return 0; +} + +static int zilog_tx_duty_cycle(struct rc_dev *dev, u32 duty_cycle) +{ + struct IR_i2c *ir = dev->priv; + + ir->duty_cycle = duty_cycle; + + return 0; +} static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -469,8 +868,23 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!rc->driver_name) rc->driver_name = KBUILD_MODNAME; + mutex_init(&ir->lock); + INIT_DELAYED_WORK(&ir->work, ir_work); + if (id->driver_data & FLAG_TX) { + ir->tx_c = i2c_new_dummy(client->adapter, 0x70); + if (!ir->tx_c) { + dev_err(&client->dev, "failed to setup tx i2c address"); + } else if (!zilog_init(ir)) { + ir->carrier = 38000; + ir->duty_cycle = 40; + rc->tx_ir = zilog_tx; + rc->s_tx_carrier = zilog_tx_carrier; + rc->s_tx_duty_cycle = zilog_tx_duty_cycle; + } + } + err = rc_register_device(rc); if (err) goto err_out_free; @@ -478,6 +892,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) return 0; err_out_free: + if (ir->tx_c) + i2c_unregister_device(ir->tx_c); + /* Only frees rc if it were allocated internally */ rc_free_device(rc); return err; @@ -490,6 +907,9 @@ static int ir_remove(struct i2c_client *client) /* kill outstanding polls */ cancel_delayed_work_sync(&ir->work); + if (ir->tx_c) + i2c_unregister_device(ir->tx_c); + /* unregister device */ rc_unregister_device(ir->rc); @@ -501,8 +921,8 @@ static const struct i2c_device_id ir_kbd_id[] = { /* Generic entry for any IR receiver */ { "ir_video", 0 }, /* IR device specific entries should be added here */ - { "ir_z8f0811_haup", 0 }, - { "ir_z8f0811_hdpvr", 0 }, + { "ir_z8f0811_haup", FLAG_TX }, + { "ir_z8f0811_hdpvr", FLAG_TX | FLAG_HDPVR }, { } }; diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h index 1a9df1ae533fe..9f47d6a48cff3 100644 --- a/include/media/i2c/ir-kbd-i2c.h +++ b/include/media/i2c/ir-kbd-i2c.h @@ -23,6 +23,11 @@ struct IR_i2c { int (*get_key)(struct IR_i2c *ir, enum rc_proto *protocol, u32 *scancode, u8 *toggle); + /* tx */ + struct i2c_client *tx_c; + struct mutex lock; /* do not poll Rx during Tx */ + unsigned int carrier; + unsigned int duty_cycle; }; enum ir_kbd_get_key_fn { -- GitLab From 1cb26030f3494a8bb3c953d45cffba838ec4d454 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 24 Oct 2017 17:04:16 -0400 Subject: [PATCH 0193/1190] media: i2c: enable i2c IR for hardware which isn't HD-PVR This is a fix for commit 329d88da4df9 ("[media] media: i2c: Don't export ir-kbd-i2c module alias") that stopped the module from being loaded automagically. The problems described only affect the HD-PVR, so it should not affect other hardware; also if the module happens to be loaded, the i2c IR part of the HD-PVR will be enabled anyway. Fixes: 329d88da4df9 ("[media] media: i2c: Don't export ir-kbd-i2c module alias") Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ir-kbd-i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 020ef0d7058e7..193020d64e519 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -63,6 +63,9 @@ #define FLAG_TX 1 #define FLAG_HDPVR 2 +static bool enable_hdpvr; +module_param(enable_hdpvr, bool, 0644); + static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, u32 *scancode, u8 *ptoggle, int size) { @@ -726,6 +729,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) unsigned short addr = client->addr; int err; + if ((id->driver_data & FLAG_HDPVR) && !enable_hdpvr) { + dev_err(&client->dev, "IR for HDPVR is known to cause problems during recording, use enable_hdpvr modparam to enable\n"); + return -ENODEV; + } + ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); if (!ir) return -ENOMEM; @@ -925,6 +933,7 @@ static const struct i2c_device_id ir_kbd_id[] = { { "ir_z8f0811_hdpvr", FLAG_TX | FLAG_HDPVR }, { } }; +MODULE_DEVICE_TABLE(i2c, ir_kbd_id); static struct i2c_driver ir_kbd_driver = { .driver = { -- GitLab From f95367a7b7585fd9123f417d09ed5b2febe773a1 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 24 Oct 2017 14:59:31 -0400 Subject: [PATCH 0194/1190] media: staging: remove lirc_zilog driver The ir-kbd-i2c driver behaves like the lirc_zilog driver, except it can send raw IR and receives scancodes rather than lirccodes. The lirc_zilog driver only polls if the lirc chardev is opened; similarly the ir-kbd-i2c driver only polls if the corresponding input device is opened, or the lirc device. Polling is disabled during IR transmission through the mutex. The polling period is 402ms in the ir-kdb-i2c driver, and 260ms in the lirc_zilog driver. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/Kconfig | 3 - drivers/staging/media/Makefile | 1 - drivers/staging/media/lirc/Kconfig | 21 - drivers/staging/media/lirc/Makefile | 6 - drivers/staging/media/lirc/TODO | 36 - drivers/staging/media/lirc/lirc_zilog.c | 1653 ----------------------- 6 files changed, 1720 deletions(-) delete mode 100644 drivers/staging/media/lirc/Kconfig delete mode 100644 drivers/staging/media/lirc/Makefile delete mode 100644 drivers/staging/media/lirc/TODO delete mode 100644 drivers/staging/media/lirc/lirc_zilog.c diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig index 79aff267e2846..227437f22acfc 100644 --- a/drivers/staging/media/Kconfig +++ b/drivers/staging/media/Kconfig @@ -31,9 +31,6 @@ source "drivers/staging/media/imx/Kconfig" source "drivers/staging/media/omap4iss/Kconfig" -# Keep LIRC at the end, as it has sub-menus -source "drivers/staging/media/lirc/Kconfig" - source "drivers/staging/media/tegra-vde/Kconfig" endif diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile index 608f7d35c2564..59a47f69884f8 100644 --- a/drivers/staging/media/Makefile +++ b/drivers/staging/media/Makefile @@ -2,7 +2,6 @@ obj-$(CONFIG_I2C_BCM2048) += bcm2048/ obj-$(CONFIG_DVB_CXD2099) += cxd2099/ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx/ -obj-$(CONFIG_LIRC_STAGING) += lirc/ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ obj-$(CONFIG_INTEL_ATOMISP) += atomisp/ diff --git a/drivers/staging/media/lirc/Kconfig b/drivers/staging/media/lirc/Kconfig deleted file mode 100644 index 3e350a9922de8..0000000000000 --- a/drivers/staging/media/lirc/Kconfig +++ /dev/null @@ -1,21 +0,0 @@ -# -# LIRC driver(s) configuration -# -menuconfig LIRC_STAGING - bool "Linux Infrared Remote Control IR receiver/transmitter drivers" - depends on LIRC - help - Say Y here, and all supported Linux Infrared Remote Control IR and - RF receiver and transmitter drivers will be displayed. When paired - with a remote control and the lirc daemon, the receiver drivers - allow control of your Linux system via remote control. - -if LIRC_STAGING - -config LIRC_ZILOG - tristate "Zilog/Hauppauge IR Transmitter" - depends on LIRC && I2C - help - Driver for the Zilog/Hauppauge IR Transmitter, found on - PVR-150/500, HVR-1200/1250/1700/1800, HD-PVR and other cards -endif diff --git a/drivers/staging/media/lirc/Makefile b/drivers/staging/media/lirc/Makefile deleted file mode 100644 index 665562436e30d..0000000000000 --- a/drivers/staging/media/lirc/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# Makefile for the lirc drivers. -# - -# Each configuration option enables a list of files. - -obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o diff --git a/drivers/staging/media/lirc/TODO b/drivers/staging/media/lirc/TODO deleted file mode 100644 index a97800a8e1271..0000000000000 --- a/drivers/staging/media/lirc/TODO +++ /dev/null @@ -1,36 +0,0 @@ -1. Both ir-kbd-i2c and lirc_zilog provide support for RX events for -the chips supported by lirc_zilog. Before moving lirc_zilog out of staging: - -a. ir-kbd-i2c needs a module parameter added to allow the user to tell - ir-kbd-i2c to ignore Z8 IR units. - -b. lirc_zilog should provide Rx key presses to the rc core like ir-kbd-i2c - does. - - -2. lirc_zilog module ref-counting need examination. It has not been -verified that cdev and lirc_dev will take the proper module references on -lirc_zilog to prevent removal of lirc_zilog when the /dev/lircN device node -is open. - -(The good news is ref-counting of lirc_zilog internal structures appears to be -complete. Testing has shown the cx18 module can be unloaded out from under -irw + lircd + lirc_dev, with the /dev/lirc0 device node open, with no adverse -effects. The cx18 module could then be reloaded and irw properly began -receiving button presses again and ir_send worked without error.) - - -3. Bridge drivers, if able, should provide a chip reset() callback -to lirc_zilog via struct IR_i2c_init_data. cx18 and ivtv already have routines -to perform Z8 chip resets via GPIO manipulations. This would allow lirc_zilog -to bring the chip back to normal when it hangs, in the same places the -original lirc_pvr150 driver code does. This is not strictly needed, so it -is not required to move lirc_zilog out of staging. - -Note: Both lirc_zilog and ir-kbd-i2c support the Zilog Z8 for IR, as programmed -and installed on Hauppauge products. When working on either module, developers -must consider at least the following bridge drivers which mention an IR Rx unit -at address 0x71 (indicative of a Z8): - - ivtv cx18 hdpvr pvrusb2 bt8xx cx88 saa7134 - diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c deleted file mode 100644 index 6bd0717bf76e5..0000000000000 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ /dev/null @@ -1,1653 +0,0 @@ -/* - * i2c IR lirc driver for devices with zilog IR processors - * - * Copyright (c) 2000 Gerd Knorr - * modified for PixelView (BT878P+W/FM) by - * Michal Kochanowicz - * Christoph Bartelmus - * modified for KNC ONE TV Station/Anubis Typhoon TView Tuner by - * Ulrich Mueller - * modified for Asus TV-Box and Creative/VisionTek BreakOut-Box by - * Stefan Jahn - * modified for inclusion into kernel sources by - * Jerome Brock - * modified for Leadtek Winfast PVR2000 by - * Thomas Reitmayr (treitmayr@yahoo.com) - * modified for Hauppauge PVR-150 IR TX device by - * Mark Weaver - * changed name from lirc_pvr150 to lirc_zilog, works on more than pvr-150 - * Jarod Wilson - * - * parts are cut&pasted from the lirc_i2c.c driver - * - * Numerous changes updating lirc_zilog.c in kernel 2.6.38 and later are - * Copyright (C) 2011 Andy Walls - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -/* Max transfer size done by I2C transfer functions */ -#define MAX_XFER_SIZE 64 - -struct IR; - -struct IR_rx { - struct kref ref; - struct IR *ir; - - /* RX device */ - struct mutex client_lock; - struct i2c_client *c; - - /* RX polling thread data */ - struct task_struct *task; - - /* RX read data */ - unsigned char b[3]; - bool hdpvr_data_fmt; -}; - -struct IR_tx { - struct kref ref; - struct IR *ir; - - /* TX device */ - struct mutex client_lock; - struct i2c_client *c; - - /* TX additional actions needed */ - int need_boot; - bool post_tx_ready_poll; -}; - -struct IR { - struct kref ref; - struct list_head list; - - /* FIXME spinlock access to l->features */ - struct lirc_dev *l; - struct lirc_buffer rbuf; - - struct mutex ir_lock; - atomic_t open_count; - - struct device *dev; - struct i2c_adapter *adapter; - - spinlock_t rx_ref_lock; /* struct IR_rx kref get()/put() */ - struct IR_rx *rx; - - spinlock_t tx_ref_lock; /* struct IR_tx kref get()/put() */ - struct IR_tx *tx; -}; - -/* IR transceiver instance object list */ -/* - * This lock is used for the following: - * a. ir_devices_list access, insertions, deletions - * b. struct IR kref get()s and put()s - * c. serialization of ir_probe() for the two i2c_clients for a Z8 - */ -static DEFINE_MUTEX(ir_devices_lock); -static LIST_HEAD(ir_devices_list); - -/* Block size for IR transmitter */ -#define TX_BLOCK_SIZE 99 - -/* Hauppauge IR transmitter data */ -struct tx_data_struct { - /* Boot block */ - unsigned char *boot_data; - - /* Start of binary data block */ - unsigned char *datap; - - /* End of binary data block */ - unsigned char *endp; - - /* Number of installed codesets */ - unsigned int num_code_sets; - - /* Pointers to codesets */ - unsigned char **code_sets; - - /* Global fixed data template */ - int fixed[TX_BLOCK_SIZE]; -}; - -static struct tx_data_struct *tx_data; -static struct mutex tx_data_lock; - - -/* module parameters */ -static bool debug; /* debug output */ -static bool tx_only; /* only handle the IR Tx function */ - - -/* struct IR reference counting */ -static struct IR *get_ir_device(struct IR *ir, bool ir_devices_lock_held) -{ - if (ir_devices_lock_held) { - kref_get(&ir->ref); - } else { - mutex_lock(&ir_devices_lock); - kref_get(&ir->ref); - mutex_unlock(&ir_devices_lock); - } - return ir; -} - -static void release_ir_device(struct kref *ref) -{ - struct IR *ir = container_of(ref, struct IR, ref); - - /* - * Things should be in this state by now: - * ir->rx set to NULL and deallocated - happens before ir->rx->ir put() - * ir->rx->task kthread stopped - happens before ir->rx->ir put() - * ir->tx set to NULL and deallocated - happens before ir->tx->ir put() - * ir->open_count == 0 - happens on final close() - * ir_lock, tx_ref_lock, rx_ref_lock, all released - */ - if (ir->l) - lirc_unregister_device(ir->l); - - if (kfifo_initialized(&ir->rbuf.fifo)) - lirc_buffer_free(&ir->rbuf); - list_del(&ir->list); - kfree(ir); -} - -static int put_ir_device(struct IR *ir, bool ir_devices_lock_held) -{ - int released; - - if (ir_devices_lock_held) - return kref_put(&ir->ref, release_ir_device); - - mutex_lock(&ir_devices_lock); - released = kref_put(&ir->ref, release_ir_device); - mutex_unlock(&ir_devices_lock); - - return released; -} - -/* struct IR_rx reference counting */ -static struct IR_rx *get_ir_rx(struct IR *ir) -{ - struct IR_rx *rx; - - spin_lock(&ir->rx_ref_lock); - rx = ir->rx; - if (rx) - kref_get(&rx->ref); - spin_unlock(&ir->rx_ref_lock); - return rx; -} - -static void destroy_rx_kthread(struct IR_rx *rx, bool ir_devices_lock_held) -{ - /* end up polling thread */ - if (!IS_ERR_OR_NULL(rx->task)) { - kthread_stop(rx->task); - rx->task = NULL; - /* Put the ir ptr that ir_probe() gave to the rx poll thread */ - put_ir_device(rx->ir, ir_devices_lock_held); - } -} - -static void release_ir_rx(struct kref *ref) -{ - struct IR_rx *rx = container_of(ref, struct IR_rx, ref); - struct IR *ir = rx->ir; - - /* - * This release function can't do all the work, as we want - * to keep the rx_ref_lock a spinlock, and killing the poll thread - * and releasing the ir reference can cause a sleep. That work is - * performed by put_ir_rx() - */ - ir->l->features &= ~LIRC_CAN_REC_LIRCCODE; - /* Don't put_ir_device(rx->ir) here; lock can't be freed yet */ - ir->rx = NULL; - /* Don't do the kfree(rx) here; we still need to kill the poll thread */ -} - -static int put_ir_rx(struct IR_rx *rx, bool ir_devices_lock_held) -{ - int released; - struct IR *ir = rx->ir; - - spin_lock(&ir->rx_ref_lock); - released = kref_put(&rx->ref, release_ir_rx); - spin_unlock(&ir->rx_ref_lock); - /* Destroy the rx kthread while not holding the spinlock */ - if (released) { - destroy_rx_kthread(rx, ir_devices_lock_held); - kfree(rx); - /* Make sure we're not still in a poll_table somewhere */ - wake_up_interruptible(&ir->rbuf.wait_poll); - } - /* Do a reference put() for the rx->ir reference, if we released rx */ - if (released) - put_ir_device(ir, ir_devices_lock_held); - return released; -} - -/* struct IR_tx reference counting */ -static struct IR_tx *get_ir_tx(struct IR *ir) -{ - struct IR_tx *tx; - - spin_lock(&ir->tx_ref_lock); - tx = ir->tx; - if (tx) - kref_get(&tx->ref); - spin_unlock(&ir->tx_ref_lock); - return tx; -} - -static void release_ir_tx(struct kref *ref) -{ - struct IR_tx *tx = container_of(ref, struct IR_tx, ref); - struct IR *ir = tx->ir; - - ir->l->features &= ~LIRC_CAN_SEND_LIRCCODE; - /* Don't put_ir_device(tx->ir) here, so our lock doesn't get freed */ - ir->tx = NULL; - kfree(tx); -} - -static int put_ir_tx(struct IR_tx *tx, bool ir_devices_lock_held) -{ - int released; - struct IR *ir = tx->ir; - - spin_lock(&ir->tx_ref_lock); - released = kref_put(&tx->ref, release_ir_tx); - spin_unlock(&ir->tx_ref_lock); - /* Do a reference put() for the tx->ir reference, if we released tx */ - if (released) - put_ir_device(ir, ir_devices_lock_held); - return released; -} - -static int add_to_buf(struct IR *ir) -{ - __u16 code; - unsigned char codes[2]; - unsigned char keybuf[6]; - int got_data = 0; - int ret; - int failures = 0; - unsigned char sendbuf[1] = { 0 }; - struct lirc_buffer *rbuf = ir->l->buf; - struct IR_rx *rx; - struct IR_tx *tx; - - if (lirc_buffer_full(rbuf)) { - dev_dbg(ir->dev, "buffer overflow\n"); - return -EOVERFLOW; - } - - rx = get_ir_rx(ir); - if (!rx) - return -ENXIO; - - /* Ensure our rx->c i2c_client remains valid for the duration */ - mutex_lock(&rx->client_lock); - if (!rx->c) { - mutex_unlock(&rx->client_lock); - put_ir_rx(rx, false); - return -ENXIO; - } - - tx = get_ir_tx(ir); - - /* - * service the device as long as it is returning - * data and we have space - */ - do { - if (kthread_should_stop()) { - ret = -ENODATA; - break; - } - - /* - * Lock i2c bus for the duration. RX/TX chips interfere so - * this is worth it - */ - mutex_lock(&ir->ir_lock); - - if (kthread_should_stop()) { - mutex_unlock(&ir->ir_lock); - ret = -ENODATA; - break; - } - - /* - * Send random "poll command" (?) Windows driver does this - * and it is a good point to detect chip failure. - */ - ret = i2c_master_send(rx->c, sendbuf, 1); - if (ret != 1) { - dev_err(ir->dev, "i2c_master_send failed with %d\n", - ret); - if (failures >= 3) { - mutex_unlock(&ir->ir_lock); - dev_err(ir->dev, - "unable to read from the IR chip after 3 resets, giving up\n"); - break; - } - - /* Looks like the chip crashed, reset it */ - dev_err(ir->dev, - "polling the IR receiver chip failed, trying reset\n"); - - set_current_state(TASK_UNINTERRUPTIBLE); - if (kthread_should_stop()) { - mutex_unlock(&ir->ir_lock); - ret = -ENODATA; - break; - } - schedule_timeout((100 * HZ + 999) / 1000); - if (tx) - tx->need_boot = 1; - - ++failures; - mutex_unlock(&ir->ir_lock); - ret = 0; - continue; - } - - if (kthread_should_stop()) { - mutex_unlock(&ir->ir_lock); - ret = -ENODATA; - break; - } - ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf)); - mutex_unlock(&ir->ir_lock); - if (ret != sizeof(keybuf)) { - dev_err(ir->dev, - "i2c_master_recv failed with %d -- keeping last read buffer\n", - ret); - } else { - rx->b[0] = keybuf[3]; - rx->b[1] = keybuf[4]; - rx->b[2] = keybuf[5]; - dev_dbg(ir->dev, - "key (0x%02x/0x%02x)\n", - rx->b[0], rx->b[1]); - } - - /* key pressed ? */ - if (rx->hdpvr_data_fmt) { - if (got_data && (keybuf[0] == 0x80)) { - ret = 0; - break; - } else if (got_data && (keybuf[0] == 0x00)) { - ret = -ENODATA; - break; - } - } else if ((rx->b[0] & 0x80) == 0) { - ret = got_data ? 0 : -ENODATA; - break; - } - - /* look what we have */ - code = (((__u16)rx->b[0] & 0x7f) << 6) | (rx->b[1] >> 2); - - codes[0] = (code >> 8) & 0xff; - codes[1] = code & 0xff; - - /* return it */ - lirc_buffer_write(rbuf, codes); - ++got_data; - ret = 0; - } while (!lirc_buffer_full(rbuf)); - - mutex_unlock(&rx->client_lock); - if (tx) - put_ir_tx(tx, false); - put_ir_rx(rx, false); - return ret; -} - -/* - * Main function of the polling thread -- from lirc_dev. - * We don't fit the LIRC model at all anymore. This is horrible, but - * basically we have a single RX/TX device with a nasty failure mode - * that needs to be accounted for across the pair. lirc lets us provide - * fops, but prevents us from using the internal polling, etc. if we do - * so. Hence the replication. Might be neater to extend the LIRC model - * to account for this but I'd think it's a very special case of seriously - * messed up hardware. - */ -static int lirc_thread(void *arg) -{ - struct IR *ir = arg; - struct lirc_buffer *rbuf = ir->l->buf; - - dev_dbg(ir->dev, "poll thread started\n"); - - while (!kthread_should_stop()) { - set_current_state(TASK_INTERRUPTIBLE); - - /* if device not opened, we can sleep half a second */ - if (atomic_read(&ir->open_count) == 0) { - schedule_timeout(HZ / 2); - continue; - } - - /* - * This is ~113*2 + 24 + jitter (2*repeat gap + code length). - * We use this interval as the chip resets every time you poll - * it (bad!). This is therefore just sufficient to catch all - * of the button presses. It makes the remote much more - * responsive. You can see the difference by running irw and - * holding down a button. With 100ms, the old polling - * interval, you'll notice breaks in the repeat sequence - * corresponding to lost keypresses. - */ - schedule_timeout((260 * HZ) / 1000); - if (kthread_should_stop()) - break; - if (!add_to_buf(ir)) - wake_up_interruptible(&rbuf->wait_poll); - } - - dev_dbg(ir->dev, "poll thread ended\n"); - return 0; -} - -/* safe read of a uint32 (always network byte order) */ -static int read_uint32(unsigned char **data, - unsigned char *endp, unsigned int *val) -{ - if (*data + 4 > endp) - return 0; - *val = ((*data)[0] << 24) | ((*data)[1] << 16) | - ((*data)[2] << 8) | (*data)[3]; - *data += 4; - return 1; -} - -/* safe read of a uint8 */ -static int read_uint8(unsigned char **data, - unsigned char *endp, unsigned char *val) -{ - if (*data + 1 > endp) - return 0; - *val = *((*data)++); - return 1; -} - -/* safe skipping of N bytes */ -static int skip(unsigned char **data, - unsigned char *endp, unsigned int distance) -{ - if (*data + distance > endp) - return 0; - *data += distance; - return 1; -} - -/* decompress key data into the given buffer */ -static int get_key_data(unsigned char *buf, - unsigned int codeset, unsigned int key) -{ - unsigned char *data, *endp, *diffs, *key_block; - unsigned char keys, ndiffs, id; - unsigned int base, lim, pos, i; - - /* Binary search for the codeset */ - for (base = 0, lim = tx_data->num_code_sets; lim; lim >>= 1) { - pos = base + (lim >> 1); - data = tx_data->code_sets[pos]; - - if (!read_uint32(&data, tx_data->endp, &i)) - goto corrupt; - - if (i == codeset) { - break; - } else if (codeset > i) { - base = pos + 1; - --lim; - } - } - /* Not found? */ - if (!lim) - return -EPROTO; - - /* Set end of data block */ - endp = pos < tx_data->num_code_sets - 1 ? - tx_data->code_sets[pos + 1] : tx_data->endp; - - /* Read the block header */ - if (!read_uint8(&data, endp, &keys) || - !read_uint8(&data, endp, &ndiffs) || - ndiffs > TX_BLOCK_SIZE || keys == 0) - goto corrupt; - - /* Save diffs & skip */ - diffs = data; - if (!skip(&data, endp, ndiffs)) - goto corrupt; - - /* Read the id of the first key */ - if (!read_uint8(&data, endp, &id)) - goto corrupt; - - /* Unpack the first key's data */ - for (i = 0; i < TX_BLOCK_SIZE; ++i) { - if (tx_data->fixed[i] == -1) { - if (!read_uint8(&data, endp, &buf[i])) - goto corrupt; - } else { - buf[i] = (unsigned char)tx_data->fixed[i]; - } - } - - /* Early out key found/not found */ - if (key == id) - return 0; - if (keys == 1) - return -EPROTO; - - /* Sanity check */ - key_block = data; - if (!skip(&data, endp, (keys - 1) * (ndiffs + 1))) - goto corrupt; - - /* Binary search for the key */ - for (base = 0, lim = keys - 1; lim; lim >>= 1) { - /* Seek to block */ - unsigned char *key_data; - - pos = base + (lim >> 1); - key_data = key_block + (ndiffs + 1) * pos; - - if (*key_data == key) { - /* skip key id */ - ++key_data; - - /* found, so unpack the diffs */ - for (i = 0; i < ndiffs; ++i) { - unsigned char val; - - if (!read_uint8(&key_data, endp, &val) || - diffs[i] >= TX_BLOCK_SIZE) - goto corrupt; - buf[diffs[i]] = val; - } - - return 0; - } else if (key > *key_data) { - base = pos + 1; - --lim; - } - } - /* Key not found */ - return -EPROTO; - -corrupt: - pr_err("firmware is corrupt\n"); - return -EFAULT; -} - -/* send a block of data to the IR TX device */ -static int send_data_block(struct IR_tx *tx, unsigned char *data_block) -{ - int i, j, ret; - unsigned char buf[5]; - - for (i = 0; i < TX_BLOCK_SIZE;) { - int tosend = TX_BLOCK_SIZE - i; - - if (tosend > 4) - tosend = 4; - buf[0] = (unsigned char)(i + 1); - for (j = 0; j < tosend; ++j) - buf[1 + j] = data_block[i + j]; - dev_dbg(tx->ir->dev, "%*ph", 5, buf); - ret = i2c_master_send(tx->c, buf, tosend + 1); - if (ret != tosend + 1) { - dev_err(tx->ir->dev, - "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - i += tosend; - } - return 0; -} - -/* send boot data to the IR TX device */ -static int send_boot_data(struct IR_tx *tx) -{ - int ret, i; - unsigned char buf[4]; - - /* send the boot block */ - ret = send_data_block(tx, tx_data->boot_data); - if (ret != 0) - return ret; - - /* Hit the go button to activate the new boot data */ - buf[0] = 0x00; - buf[1] = 0x20; - ret = i2c_master_send(tx->c, buf, 2); - if (ret != 2) { - dev_err(tx->ir->dev, "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - - /* - * Wait for zilog to settle after hitting go post boot block upload. - * Without this delay, the HD-PVR and HVR-1950 both return an -EIO - * upon attempting to get firmware revision, and tx probe thus fails. - */ - for (i = 0; i < 10; i++) { - ret = i2c_master_send(tx->c, buf, 1); - if (ret == 1) - break; - udelay(100); - } - - if (ret != 1) { - dev_err(tx->ir->dev, "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - - /* Here comes the firmware version... (hopefully) */ - ret = i2c_master_recv(tx->c, buf, 4); - if (ret != 4) { - dev_err(tx->ir->dev, "i2c_master_recv failed with %d\n", ret); - return 0; - } - if ((buf[0] != 0x80) && (buf[0] != 0xa0)) { - dev_err(tx->ir->dev, "unexpected IR TX init response: %02x\n", - buf[0]); - return 0; - } - dev_notice(tx->ir->dev, - "Zilog/Hauppauge IR blaster firmware version %d.%d.%d loaded\n", - buf[1], buf[2], buf[3]); - - return 0; -} - -/* unload "firmware", lock held */ -static void fw_unload_locked(void) -{ - if (tx_data) { - vfree(tx_data->code_sets); - - vfree(tx_data->datap); - - vfree(tx_data); - tx_data = NULL; - pr_debug("successfully unloaded IR blaster firmware\n"); - } -} - -/* unload "firmware" for the IR TX device */ -static void fw_unload(void) -{ - mutex_lock(&tx_data_lock); - fw_unload_locked(); - mutex_unlock(&tx_data_lock); -} - -/* load "firmware" for the IR TX device */ -static int fw_load(struct IR_tx *tx) -{ - int ret; - unsigned int i; - unsigned char *data, version, num_global_fixed; - const struct firmware *fw_entry; - - /* Already loaded? */ - mutex_lock(&tx_data_lock); - if (tx_data) { - ret = 0; - goto out; - } - - /* Request codeset data file */ - ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", tx->ir->dev); - if (ret != 0) { - dev_err(tx->ir->dev, - "firmware haup-ir-blaster.bin not available (%d)\n", - ret); - ret = ret < 0 ? ret : -EFAULT; - goto out; - } - dev_dbg(tx->ir->dev, "firmware of size %zu loaded\n", fw_entry->size); - - /* Parse the file */ - tx_data = vmalloc(sizeof(*tx_data)); - if (!tx_data) { - release_firmware(fw_entry); - ret = -ENOMEM; - goto out; - } - tx_data->code_sets = NULL; - - /* Copy the data so hotplug doesn't get confused and timeout */ - tx_data->datap = vmalloc(fw_entry->size); - if (!tx_data->datap) { - release_firmware(fw_entry); - vfree(tx_data); - ret = -ENOMEM; - goto out; - } - memcpy(tx_data->datap, fw_entry->data, fw_entry->size); - tx_data->endp = tx_data->datap + fw_entry->size; - release_firmware(fw_entry); fw_entry = NULL; - - /* Check version */ - data = tx_data->datap; - if (!read_uint8(&data, tx_data->endp, &version)) - goto corrupt; - if (version != 1) { - dev_err(tx->ir->dev, - "unsupported code set file version (%u, expected 1) -- please upgrade to a newer driver\n", - version); - fw_unload_locked(); - ret = -EFAULT; - goto out; - } - - /* Save boot block for later */ - tx_data->boot_data = data; - if (!skip(&data, tx_data->endp, TX_BLOCK_SIZE)) - goto corrupt; - - if (!read_uint32(&data, tx_data->endp, - &tx_data->num_code_sets)) - goto corrupt; - - dev_dbg(tx->ir->dev, "%u IR blaster codesets loaded\n", - tx_data->num_code_sets); - - tx_data->code_sets = vmalloc( - tx_data->num_code_sets * sizeof(char *)); - if (!tx_data->code_sets) { - fw_unload_locked(); - ret = -ENOMEM; - goto out; - } - - for (i = 0; i < TX_BLOCK_SIZE; ++i) - tx_data->fixed[i] = -1; - - /* Read global fixed data template */ - if (!read_uint8(&data, tx_data->endp, &num_global_fixed) || - num_global_fixed > TX_BLOCK_SIZE) - goto corrupt; - for (i = 0; i < num_global_fixed; ++i) { - unsigned char pos, val; - - if (!read_uint8(&data, tx_data->endp, &pos) || - !read_uint8(&data, tx_data->endp, &val) || - pos >= TX_BLOCK_SIZE) - goto corrupt; - tx_data->fixed[pos] = (int)val; - } - - /* Filch out the position of each code set */ - for (i = 0; i < tx_data->num_code_sets; ++i) { - unsigned int id; - unsigned char keys; - unsigned char ndiffs; - - /* Save the codeset position */ - tx_data->code_sets[i] = data; - - /* Read header */ - if (!read_uint32(&data, tx_data->endp, &id) || - !read_uint8(&data, tx_data->endp, &keys) || - !read_uint8(&data, tx_data->endp, &ndiffs) || - ndiffs > TX_BLOCK_SIZE || keys == 0) - goto corrupt; - - /* skip diff positions */ - if (!skip(&data, tx_data->endp, ndiffs)) - goto corrupt; - - /* - * After the diffs we have the first key id + data - - * global fixed - */ - if (!skip(&data, tx_data->endp, - 1 + TX_BLOCK_SIZE - num_global_fixed)) - goto corrupt; - - /* Then we have keys-1 blocks of key id+diffs */ - if (!skip(&data, tx_data->endp, - (ndiffs + 1) * (keys - 1))) - goto corrupt; - } - ret = 0; - goto out; - -corrupt: - dev_err(tx->ir->dev, "firmware is corrupt\n"); - fw_unload_locked(); - ret = -EFAULT; - -out: - mutex_unlock(&tx_data_lock); - return ret; -} - -/* copied from lirc_dev */ -static ssize_t read(struct file *filep, char __user *outbuf, size_t n, - loff_t *ppos) -{ - struct IR *ir = lirc_get_pdata(filep); - struct IR_rx *rx; - struct lirc_buffer *rbuf = ir->l->buf; - int ret = 0, written = 0, retries = 0; - unsigned int m; - DECLARE_WAITQUEUE(wait, current); - - dev_dbg(ir->dev, "read called\n"); - if (n % rbuf->chunk_size) { - dev_dbg(ir->dev, "read result = -EINVAL\n"); - return -EINVAL; - } - - rx = get_ir_rx(ir); - if (!rx) - return -ENXIO; - - /* - * we add ourselves to the task queue before buffer check - * to avoid losing scan code (in case when queue is awaken somewhere - * between while condition checking and scheduling) - */ - add_wait_queue(&rbuf->wait_poll, &wait); - set_current_state(TASK_INTERRUPTIBLE); - - /* - * while we didn't provide 'length' bytes, device is opened in blocking - * mode and 'copy_to_user' is happy, wait for data. - */ - while (written < n && ret == 0) { - if (lirc_buffer_empty(rbuf)) { - /* - * According to the read(2) man page, 'written' can be - * returned as less than 'n', instead of blocking - * again, returning -EWOULDBLOCK, or returning - * -ERESTARTSYS - */ - if (written) - break; - if (filep->f_flags & O_NONBLOCK) { - ret = -EWOULDBLOCK; - break; - } - if (signal_pending(current)) { - ret = -ERESTARTSYS; - break; - } - schedule(); - set_current_state(TASK_INTERRUPTIBLE); - } else { - unsigned char buf[MAX_XFER_SIZE]; - - if (rbuf->chunk_size > sizeof(buf)) { - dev_err(ir->dev, - "chunk_size is too big (%d)!\n", - rbuf->chunk_size); - ret = -EINVAL; - break; - } - m = lirc_buffer_read(rbuf, buf); - if (m == rbuf->chunk_size) { - ret = copy_to_user(outbuf + written, buf, - rbuf->chunk_size); - written += rbuf->chunk_size; - } else { - retries++; - } - if (retries >= 5) { - dev_err(ir->dev, "Buffer read failed!\n"); - ret = -EIO; - } - } - } - - remove_wait_queue(&rbuf->wait_poll, &wait); - put_ir_rx(rx, false); - set_current_state(TASK_RUNNING); - - dev_dbg(ir->dev, "read result = %d (%s)\n", ret, - ret ? "Error" : "OK"); - - return ret ? ret : written; -} - -/* send a keypress to the IR TX device */ -static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) -{ - unsigned char data_block[TX_BLOCK_SIZE]; - unsigned char buf[2]; - int i, ret; - - /* Get data for the codeset/key */ - ret = get_key_data(data_block, code, key); - - if (ret == -EPROTO) { - dev_err(tx->ir->dev, - "failed to get data for code %u, key %u -- check lircd.conf entries\n", - code, key); - return ret; - } else if (ret != 0) { - return ret; - } - - /* Send the data block */ - ret = send_data_block(tx, data_block); - if (ret != 0) - return ret; - - /* Send data block length? */ - buf[0] = 0x00; - buf[1] = 0x40; - ret = i2c_master_send(tx->c, buf, 2); - if (ret != 2) { - dev_err(tx->ir->dev, "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - - /* Give the z8 a moment to process data block */ - for (i = 0; i < 10; i++) { - ret = i2c_master_send(tx->c, buf, 1); - if (ret == 1) - break; - udelay(100); - } - - if (ret != 1) { - dev_err(tx->ir->dev, "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - - /* Send finished download? */ - ret = i2c_master_recv(tx->c, buf, 1); - if (ret != 1) { - dev_err(tx->ir->dev, "i2c_master_recv failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - if (buf[0] != 0xA0) { - dev_err(tx->ir->dev, "unexpected IR TX response #1: %02x\n", - buf[0]); - return -EFAULT; - } - - /* Send prepare command? */ - buf[0] = 0x00; - buf[1] = 0x80; - ret = i2c_master_send(tx->c, buf, 2); - if (ret != 2) { - dev_err(tx->ir->dev, "i2c_master_send failed with %d\n", ret); - return ret < 0 ? ret : -EFAULT; - } - - /* - * The sleep bits aren't necessary on the HD PVR, and in fact, the - * last i2c_master_recv always fails with a -5, so for now, we're - * going to skip this whole mess and say we're done on the HD PVR - */ - if (!tx->post_tx_ready_poll) { - dev_dbg(tx->ir->dev, "sent code %u, key %u\n", code, key); - return 0; - } - - /* - * This bit NAKs until the device is ready, so we retry it - * sleeping a bit each time. This seems to be what the windows - * driver does, approximately. - * Try for up to 1s. - */ - for (i = 0; i < 20; ++i) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((50 * HZ + 999) / 1000); - ret = i2c_master_send(tx->c, buf, 1); - if (ret == 1) - break; - dev_dbg(tx->ir->dev, - "NAK expected: i2c_master_send failed with %d (try %d)\n", - ret, i + 1); - } - if (ret != 1) { - dev_err(tx->ir->dev, - "IR TX chip never got ready: last i2c_master_send failed with %d\n", - ret); - return ret < 0 ? ret : -EFAULT; - } - - /* Seems to be an 'ok' response */ - i = i2c_master_recv(tx->c, buf, 1); - if (i != 1) { - dev_err(tx->ir->dev, "i2c_master_recv failed with %d\n", ret); - return -EFAULT; - } - if (buf[0] != 0x80) { - dev_err(tx->ir->dev, "unexpected IR TX response #2: %02x\n", - buf[0]); - return -EFAULT; - } - - /* Oh good, it worked */ - dev_dbg(tx->ir->dev, "sent code %u, key %u\n", code, key); - return 0; -} - -/* - * Write a code to the device. We take in a 32-bit number (an int) and then - * decode this to a codeset/key index. The key data is then decompressed and - * sent to the device. We have a spin lock as per i2c documentation to prevent - * multiple concurrent sends which would probably cause the device to explode. - */ -static ssize_t write(struct file *filep, const char __user *buf, size_t n, - loff_t *ppos) -{ - struct IR *ir = lirc_get_pdata(filep); - struct IR_tx *tx; - size_t i; - int failures = 0; - - /* Validate user parameters */ - if (n % sizeof(int)) - return -EINVAL; - - /* Get a struct IR_tx reference */ - tx = get_ir_tx(ir); - if (!tx) - return -ENXIO; - - /* Ensure our tx->c i2c_client remains valid for the duration */ - mutex_lock(&tx->client_lock); - if (!tx->c) { - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - return -ENXIO; - } - - /* Lock i2c bus for the duration */ - mutex_lock(&ir->ir_lock); - - /* Send each keypress */ - for (i = 0; i < n;) { - int ret = 0; - int command; - - if (copy_from_user(&command, buf + i, sizeof(command))) { - mutex_unlock(&ir->ir_lock); - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - return -EFAULT; - } - - /* Send boot data first if required */ - if (tx->need_boot == 1) { - /* Make sure we have the 'firmware' loaded, first */ - ret = fw_load(tx); - if (ret != 0) { - mutex_unlock(&ir->ir_lock); - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - if (ret != -ENOMEM) - ret = -EIO; - return ret; - } - /* Prep the chip for transmitting codes */ - ret = send_boot_data(tx); - if (ret == 0) - tx->need_boot = 0; - } - - /* Send the code */ - if (ret == 0) { - ret = send_code(tx, (unsigned int)command >> 16, - (unsigned int)command & 0xFFFF); - if (ret == -EPROTO) { - mutex_unlock(&ir->ir_lock); - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - return ret; - } - } - - /* - * Hmm, a failure. If we've had a few then give up, otherwise - * try a reset - */ - if (ret != 0) { - /* Looks like the chip crashed, reset it */ - dev_err(tx->ir->dev, - "sending to the IR transmitter chip failed, trying reset\n"); - - if (failures >= 3) { - dev_err(tx->ir->dev, - "unable to send to the IR chip after 3 resets, giving up\n"); - mutex_unlock(&ir->ir_lock); - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - return ret; - } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((100 * HZ + 999) / 1000); - tx->need_boot = 1; - ++failures; - } else { - i += sizeof(int); - } - } - - /* Release i2c bus */ - mutex_unlock(&ir->ir_lock); - - mutex_unlock(&tx->client_lock); - - /* Give back our struct IR_tx reference */ - put_ir_tx(tx, false); - - /* All looks good */ - return n; -} - -/* copied from lirc_dev */ -static unsigned int poll(struct file *filep, poll_table *wait) -{ - struct IR *ir = lirc_get_pdata(filep); - struct IR_rx *rx; - struct lirc_buffer *rbuf = ir->l->buf; - unsigned int ret; - - dev_dbg(ir->dev, "%s called\n", __func__); - - rx = get_ir_rx(ir); - if (!rx) { - /* - * Revisit this, if our poll function ever reports writeable - * status for Tx - */ - dev_dbg(ir->dev, "%s result = POLLERR\n", __func__); - return POLLERR; - } - - /* - * Add our lirc_buffer's wait_queue to the poll_table. A wake up on - * that buffer's wait queue indicates we may have a new poll status. - */ - poll_wait(filep, &rbuf->wait_poll, wait); - - /* Indicate what ops could happen immediately without blocking */ - ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN | POLLRDNORM); - - dev_dbg(ir->dev, "%s result = %s\n", __func__, - ret ? "POLLIN|POLLRDNORM" : "none"); - return ret; -} - -static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) -{ - struct IR *ir = lirc_get_pdata(filep); - unsigned long __user *uptr = (unsigned long __user *)arg; - int result; - unsigned long mode, features; - - features = ir->l->features; - - switch (cmd) { - case LIRC_GET_LENGTH: - result = put_user(13UL, uptr); - break; - case LIRC_GET_FEATURES: - result = put_user(features, uptr); - break; - case LIRC_GET_REC_MODE: - if (!(features & LIRC_CAN_REC_MASK)) - return -ENOTTY; - - result = put_user(LIRC_REC2MODE - (features & LIRC_CAN_REC_MASK), - uptr); - break; - case LIRC_SET_REC_MODE: - if (!(features & LIRC_CAN_REC_MASK)) - return -ENOTTY; - - result = get_user(mode, uptr); - if (!result && !(LIRC_MODE2REC(mode) & features)) - result = -ENOTTY; - break; - case LIRC_GET_SEND_MODE: - if (!(features & LIRC_CAN_SEND_MASK)) - return -ENOTTY; - - result = put_user(LIRC_MODE_LIRCCODE, uptr); - break; - case LIRC_SET_SEND_MODE: - if (!(features & LIRC_CAN_SEND_MASK)) - return -ENOTTY; - - result = get_user(mode, uptr); - if (!result && mode != LIRC_MODE_LIRCCODE) - return -EINVAL; - break; - default: - return -EINVAL; - } - return result; -} - -/* - * Open the IR device. - */ -static int open(struct inode *node, struct file *filep) -{ - struct IR *ir; - - lirc_init_pdata(node, filep); - ir = lirc_get_pdata(filep); - - atomic_inc(&ir->open_count); - - nonseekable_open(node, filep); - return 0; -} - -/* Close the IR device */ -static int close(struct inode *node, struct file *filep) -{ - struct IR *ir = lirc_get_pdata(filep); - - atomic_dec(&ir->open_count); - - put_ir_device(ir, false); - return 0; -} - -static int ir_remove(struct i2c_client *client); -static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id); - -#define ID_FLAG_TX 0x01 -#define ID_FLAG_HDPVR 0x02 - -static const struct i2c_device_id ir_transceiver_id[] = { - { "ir_tx_z8f0811_haup", ID_FLAG_TX }, - { "ir_rx_z8f0811_haup", 0 }, - { "ir_tx_z8f0811_hdpvr", ID_FLAG_HDPVR | ID_FLAG_TX }, - { "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR }, - { } -}; -MODULE_DEVICE_TABLE(i2c, ir_transceiver_id); - -static struct i2c_driver driver = { - .driver = { - .name = "Zilog/Hauppauge i2c IR", - }, - .probe = ir_probe, - .remove = ir_remove, - .id_table = ir_transceiver_id, -}; - -static const struct file_operations lirc_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .read = read, - .write = write, - .poll = poll, - .unlocked_ioctl = ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = ioctl, -#endif - .open = open, - .release = close -}; - -static int ir_remove(struct i2c_client *client) -{ - if (strncmp("ir_tx_z8", client->name, 8) == 0) { - struct IR_tx *tx = i2c_get_clientdata(client); - - if (tx) { - mutex_lock(&tx->client_lock); - tx->c = NULL; - mutex_unlock(&tx->client_lock); - put_ir_tx(tx, false); - } - } else if (strncmp("ir_rx_z8", client->name, 8) == 0) { - struct IR_rx *rx = i2c_get_clientdata(client); - - if (rx) { - mutex_lock(&rx->client_lock); - rx->c = NULL; - mutex_unlock(&rx->client_lock); - put_ir_rx(rx, false); - } - } - return 0; -} - -/* ir_devices_lock must be held */ -static struct IR *get_ir_device_by_adapter(struct i2c_adapter *adapter) -{ - struct IR *ir; - - if (list_empty(&ir_devices_list)) - return NULL; - - list_for_each_entry(ir, &ir_devices_list, list) - if (ir->adapter == adapter) { - get_ir_device(ir, true); - return ir; - } - - return NULL; -} - -static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct IR *ir; - struct IR_tx *tx; - struct IR_rx *rx; - struct i2c_adapter *adap = client->adapter; - int ret; - bool tx_probe = false; - - dev_dbg(&client->dev, "%s: %s on i2c-%d (%s), client addr=0x%02x\n", - __func__, id->name, adap->nr, adap->name, client->addr); - - /* - * The IR receiver is at i2c address 0x71. - * The IR transmitter is at i2c address 0x70. - */ - - if (id->driver_data & ID_FLAG_TX) - tx_probe = true; - else if (tx_only) /* module option */ - return -ENXIO; - - pr_info("probing IR %s on %s (i2c-%d)\n", - tx_probe ? "Tx" : "Rx", adap->name, adap->nr); - - mutex_lock(&ir_devices_lock); - - /* Use a single struct IR instance for both the Rx and Tx functions */ - ir = get_ir_device_by_adapter(adap); - if (!ir) { - ir = kzalloc(sizeof(*ir), GFP_KERNEL); - if (!ir) { - ret = -ENOMEM; - goto out_no_ir; - } - kref_init(&ir->ref); - - /* store for use in ir_probe() again, and open() later on */ - INIT_LIST_HEAD(&ir->list); - list_add_tail(&ir->list, &ir_devices_list); - - ir->adapter = adap; - ir->dev = &adap->dev; - mutex_init(&ir->ir_lock); - atomic_set(&ir->open_count, 0); - spin_lock_init(&ir->tx_ref_lock); - spin_lock_init(&ir->rx_ref_lock); - - /* set lirc_dev stuff */ - ir->l = lirc_allocate_device(); - if (!ir->l) { - ret = -ENOMEM; - goto out_put_ir; - } - - snprintf(ir->l->name, sizeof(ir->l->name), "lirc_zilog"); - ir->l->code_length = 13; - ir->l->fops = &lirc_fops; - ir->l->owner = THIS_MODULE; - ir->l->dev.parent = &adap->dev; - - /* - * FIXME this is a pointer reference to us, but no refcount. - * - * This OK for now, since lirc_dev currently won't touch this - * buffer as we provide our own lirc_fops. - * - * Currently our own lirc_fops rely on this ir->l->buf pointer - */ - ir->l->buf = &ir->rbuf; - /* This will be returned by lirc_get_pdata() */ - ir->l->data = ir; - ret = lirc_buffer_init(ir->l->buf, 2, BUFLEN / 2); - if (ret) { - lirc_free_device(ir->l); - ir->l = NULL; - goto out_put_ir; - } - } - - if (tx_probe) { - /* Get the IR_rx instance for later, if already allocated */ - rx = get_ir_rx(ir); - - /* Set up a struct IR_tx instance */ - tx = kzalloc(sizeof(*tx), GFP_KERNEL); - if (!tx) { - ret = -ENOMEM; - goto out_put_xx; - } - kref_init(&tx->ref); - ir->tx = tx; - - ir->l->features |= LIRC_CAN_SEND_LIRCCODE; - mutex_init(&tx->client_lock); - tx->c = client; - tx->need_boot = 1; - tx->post_tx_ready_poll = - (id->driver_data & ID_FLAG_HDPVR) ? false : true; - - /* An ir ref goes to the struct IR_tx instance */ - tx->ir = get_ir_device(ir, true); - - /* A tx ref goes to the i2c_client */ - i2c_set_clientdata(client, get_ir_tx(ir)); - - /* - * Load the 'firmware'. We do this before registering with - * lirc_dev, so the first firmware load attempt does not happen - * after a open() or write() call on the device. - * - * Failure here is not deemed catastrophic, so the receiver will - * still be usable. Firmware load will be retried in write(), - * if it is needed. - */ - fw_load(tx); - - /* Proceed only if the Rx client is also ready or not needed */ - if (!rx && !tx_only) { - dev_info(tx->ir->dev, - "probe of IR Tx on %s (i2c-%d) done. Waiting on IR Rx.\n", - adap->name, adap->nr); - goto out_ok; - } - } else { - /* Get the IR_tx instance for later, if already allocated */ - tx = get_ir_tx(ir); - - /* Set up a struct IR_rx instance */ - rx = kzalloc(sizeof(*rx), GFP_KERNEL); - if (!rx) { - ret = -ENOMEM; - goto out_put_xx; - } - kref_init(&rx->ref); - ir->rx = rx; - - ir->l->features |= LIRC_CAN_REC_LIRCCODE; - mutex_init(&rx->client_lock); - rx->c = client; - rx->hdpvr_data_fmt = - (id->driver_data & ID_FLAG_HDPVR) ? true : false; - - /* An ir ref goes to the struct IR_rx instance */ - rx->ir = get_ir_device(ir, true); - - /* An rx ref goes to the i2c_client */ - i2c_set_clientdata(client, get_ir_rx(ir)); - - /* - * Start the polling thread. - * It will only perform an empty loop around schedule_timeout() - * until we register with lirc_dev and the first user open() - */ - /* An ir ref goes to the new rx polling kthread */ - rx->task = kthread_run(lirc_thread, get_ir_device(ir, true), - "zilog-rx-i2c-%d", adap->nr); - if (IS_ERR(rx->task)) { - ret = PTR_ERR(rx->task); - dev_err(tx->ir->dev, - "%s: could not start IR Rx polling thread\n", - __func__); - /* Failed kthread, so put back the ir ref */ - put_ir_device(ir, true); - /* Failure exit, so put back rx ref from i2c_client */ - i2c_set_clientdata(client, NULL); - put_ir_rx(rx, true); - ir->l->features &= ~LIRC_CAN_REC_LIRCCODE; - goto out_put_tx; - } - - /* Proceed only if the Tx client is also ready */ - if (!tx) { - pr_info("probe of IR Rx on %s (i2c-%d) done. Waiting on IR Tx.\n", - adap->name, adap->nr); - goto out_ok; - } - } - - /* register with lirc */ - ret = lirc_register_device(ir->l); - if (ret < 0) { - dev_err(tx->ir->dev, - "%s: lirc_register_device() failed: %i\n", - __func__, ret); - lirc_free_device(ir->l); - ir->l = NULL; - goto out_put_xx; - } - - dev_info(ir->dev, - "IR unit on %s (i2c-%d) registered as lirc%d and ready\n", - adap->name, adap->nr, ir->l->minor); - -out_ok: - if (rx) - put_ir_rx(rx, true); - if (tx) - put_ir_tx(tx, true); - put_ir_device(ir, true); - dev_info(ir->dev, - "probe of IR %s on %s (i2c-%d) done\n", - tx_probe ? "Tx" : "Rx", adap->name, adap->nr); - mutex_unlock(&ir_devices_lock); - return 0; - -out_put_xx: - if (rx) - put_ir_rx(rx, true); -out_put_tx: - if (tx) - put_ir_tx(tx, true); -out_put_ir: - put_ir_device(ir, true); -out_no_ir: - dev_err(&client->dev, - "%s: probing IR %s on %s (i2c-%d) failed with %d\n", - __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr, ret); - mutex_unlock(&ir_devices_lock); - return ret; -} - -static int __init zilog_init(void) -{ - int ret; - - pr_notice("Zilog/Hauppauge IR driver initializing\n"); - - mutex_init(&tx_data_lock); - - request_module("firmware_class"); - - ret = i2c_add_driver(&driver); - if (ret) - pr_err("initialization failed\n"); - else - pr_notice("initialization complete\n"); - - return ret; -} - -static void __exit zilog_exit(void) -{ - i2c_del_driver(&driver); - /* if loaded */ - fw_unload(); - pr_notice("Zilog/Hauppauge IR driver unloaded\n"); -} - -module_init(zilog_init); -module_exit(zilog_exit); - -MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)"); -MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver, Andy Walls"); -MODULE_LICENSE("GPL"); -/* for compat with old name, which isn't all that accurate anymore */ -MODULE_ALIAS("lirc_pvr150"); - -module_param(debug, bool, 0644); -MODULE_PARM_DESC(debug, "Enable debugging messages"); - -module_param(tx_only, bool, 0644); -MODULE_PARM_DESC(tx_only, "Only handle the IR transmit function"); -- GitLab From 794348e883780bcc9758724cb1ddfb7374a61985 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 28 Sep 2017 10:40:45 -0400 Subject: [PATCH 0195/1190] media: MAINTAINERS: remove lirc staging area Now that lirc is no longer in the staging area, remove the entry. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 487304ea1e884..9501403353f43 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12873,12 +12873,6 @@ S: Odd Fixes F: Documentation/devicetree/bindings/staging/iio/ F: drivers/staging/iio/ -STAGING - LIRC (LINUX INFRARED REMOTE CONTROL) DRIVERS -M: Jarod Wilson -W: http://www.lirc.org/ -S: Odd Fixes -F: drivers/staging/media/lirc/ - STAGING - LUSTRE PARALLEL FILESYSTEM M: Oleg Drokin M: Andreas Dilger -- GitLab From 4e3cd001fde13dfd4a91888f908b2a07fd0a4047 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 8 Jun 2017 05:10:41 -0400 Subject: [PATCH 0196/1190] media: lirc: remove LIRCCODE and LIRC_GET_LENGTH LIRCCODE is a lirc mode where a driver produces driver-dependent codes for receive and transmit. No driver uses this any more. The LIRC_GET_LENGTH ioctl was used for this mode only. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/lirc.h.rst.exceptions | 5 +++ .../media/uapi/rc/lirc-dev-intro.rst | 15 ------- Documentation/media/uapi/rc/lirc-func.rst | 1 - .../media/uapi/rc/lirc-get-features.rst | 7 +-- .../media/uapi/rc/lirc-get-length.rst | 44 ------------------- .../media/uapi/rc/lirc-get-rec-mode.rst | 4 +- .../media/uapi/rc/lirc-get-send-mode.rst | 3 +- drivers/media/rc/ir-lirc-codec.c | 1 - drivers/media/rc/lirc_dev.c | 12 ----- include/media/lirc_dev.h | 4 -- 10 files changed, 9 insertions(+), 87 deletions(-) delete mode 100644 Documentation/media/uapi/rc/lirc-get-length.rst diff --git a/Documentation/media/lirc.h.rst.exceptions b/Documentation/media/lirc.h.rst.exceptions index c130617a9986e..63ba1d341905b 100644 --- a/Documentation/media/lirc.h.rst.exceptions +++ b/Documentation/media/lirc.h.rst.exceptions @@ -28,6 +28,10 @@ ignore define LIRC_CAN_SEND_MASK ignore define LIRC_CAN_REC_MASK ignore define LIRC_CAN_SET_REC_DUTY_CYCLE +# Obsolete ioctls + +ignore ioctl LIRC_GET_LENGTH + # Undocumented macros ignore define PULSE_BIT @@ -40,3 +44,4 @@ ignore define LIRC_VALUE_MASK ignore define LIRC_MODE2_MASK ignore define LIRC_MODE_RAW +ignore define LIRC_MODE_LIRCCODE diff --git a/Documentation/media/uapi/rc/lirc-dev-intro.rst b/Documentation/media/uapi/rc/lirc-dev-intro.rst index d1936eeb9ce06..3cacf9aeac409 100644 --- a/Documentation/media/uapi/rc/lirc-dev-intro.rst +++ b/Documentation/media/uapi/rc/lirc-dev-intro.rst @@ -72,21 +72,6 @@ on the following table. this packet will be sent, with the number of microseconds with no IR. -.. _lirc-mode-lirccode: - -``LIRC_MODE_LIRCCODE`` - - This mode can be used for IR receive and send. - - The IR signal is decoded internally by the receiver, or encoded by the - transmitter. The LIRC interface represents the scancode as byte string, - which might not be a u32, it can be any length. The value is entirely - driver dependent. This mode is used by some older lirc drivers. - - The length of each code depends on the driver, which can be retrieved - with :ref:`lirc_get_length`. This length is used both - for transmitting and receiving IR. - .. _lirc-mode-pulse: ``LIRC_MODE_PULSE`` diff --git a/Documentation/media/uapi/rc/lirc-func.rst b/Documentation/media/uapi/rc/lirc-func.rst index 9b5a772ec96c2..ddb4620de2940 100644 --- a/Documentation/media/uapi/rc/lirc-func.rst +++ b/Documentation/media/uapi/rc/lirc-func.rst @@ -18,7 +18,6 @@ LIRC Function Reference lirc-set-send-duty-cycle lirc-get-timeout lirc-set-rec-timeout - lirc-get-length lirc-set-rec-carrier lirc-set-rec-carrier-range lirc-set-send-carrier diff --git a/Documentation/media/uapi/rc/lirc-get-features.rst b/Documentation/media/uapi/rc/lirc-get-features.rst index 64f89a4f9d9ce..50c2c26d8e89e 100644 --- a/Documentation/media/uapi/rc/lirc-get-features.rst +++ b/Documentation/media/uapi/rc/lirc-get-features.rst @@ -62,8 +62,7 @@ LIRC features ``LIRC_CAN_REC_LIRCCODE`` - The driver is capable of receiving using - :ref:`LIRC_MODE_LIRCCODE `. + Unused. Kept just to avoid breaking uAPI. .. _LIRC-CAN-SET-SEND-CARRIER: @@ -170,9 +169,7 @@ LIRC features ``LIRC_CAN_SEND_LIRCCODE`` - The driver supports sending (also called as IR blasting or IR TX) using - :ref:`LIRC_MODE_LIRCCODE `. - + Unused. Kept just to avoid breaking uAPI. Return Value ============ diff --git a/Documentation/media/uapi/rc/lirc-get-length.rst b/Documentation/media/uapi/rc/lirc-get-length.rst deleted file mode 100644 index 3990af5de0e91..0000000000000 --- a/Documentation/media/uapi/rc/lirc-get-length.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. -*- coding: utf-8; mode: rst -*- - -.. _lirc_get_length: - -********************* -ioctl LIRC_GET_LENGTH -********************* - -Name -==== - -LIRC_GET_LENGTH - Retrieves the code length in bits. - -Synopsis -======== - -.. c:function:: int ioctl( int fd, LIRC_GET_LENGTH, __u32 *length ) - :name: LIRC_GET_LENGTH - -Arguments -========= - -``fd`` - File descriptor returned by open(). - -``length`` - length, in bits - - -Description -=========== - -Retrieves the code length in bits (only for -:ref:`LIRC_MODE_LIRCCODE `). -Reads on the device must be done in blocks matching the bit count. -The bit could should be rounded up so that it matches full bytes. - - -Return Value -============ - -On success 0 is returned, on error -1 and the ``errno`` variable is set -appropriately. The generic error codes are described at the -:ref:`Generic Error Codes ` chapter. diff --git a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst index a4eb6c0a26e9c..b89de9add921d 100644 --- a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst +++ b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst @@ -34,9 +34,7 @@ Description =========== Get/set supported receive modes. Only :ref:`LIRC_MODE_MODE2 ` -and :ref:`LIRC_MODE_LIRCCODE ` are supported for IR -receive. Use :ref:`lirc_get_features` to find out which modes the driver -supports. +is supported for IR receive. Return Value ============ diff --git a/Documentation/media/uapi/rc/lirc-get-send-mode.rst b/Documentation/media/uapi/rc/lirc-get-send-mode.rst index a169b234290e9..e686b21689a08 100644 --- a/Documentation/media/uapi/rc/lirc-get-send-mode.rst +++ b/Documentation/media/uapi/rc/lirc-get-send-mode.rst @@ -36,8 +36,7 @@ Description Get/set current transmit mode. -Only :ref:`LIRC_MODE_PULSE ` and -:ref:`LIRC_MODE_LIRCCODE ` is supported by for IR send, +Only :ref:`LIRC_MODE_PULSE ` is supported by for IR send, depending on the driver. Use :ref:`lirc_get_features` to find out which modes the driver supports. diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 4fd4521693d95..9954ad4b8e590 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -388,7 +388,6 @@ static int ir_lirc_register(struct rc_dev *dev) ldev->features = features; ldev->data = &dev->raw->lirc; ldev->buf = NULL; - ldev->code_length = sizeof(struct ir_raw_event) * 8; ldev->chunk_size = sizeof(int); ldev->buffer_size = LIRCBUF_SIZE; ldev->fops = &lirc_fops; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index e16d1138ca486..ef7e915dc9a24 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -137,12 +137,6 @@ int lirc_register_device(struct lirc_dev *d) return -EINVAL; } - if (d->code_length < 1 || d->code_length > (BUFLEN * 8)) { - dev_err(&d->dev, "code length must be less than %d bits\n", - BUFLEN * 8); - return -EBADRQC; - } - if (!d->buf && !(d->fops && d->fops->read && d->fops->poll && d->fops->unlocked_ioctl)) { dev_err(&d->dev, "undefined read, poll, ioctl\n"); @@ -152,9 +146,6 @@ int lirc_register_device(struct lirc_dev *d) /* some safety check 8-) */ d->name[sizeof(d->name) - 1] = '\0'; - if (d->features == 0) - d->features = LIRC_CAN_REC_LIRCCODE; - if (LIRC_CAN_REC(d->features)) { err = lirc_allocate_buffer(d); if (err) @@ -343,9 +334,6 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * for now, lirc_serial doesn't support mode changing either */ break; - case LIRC_GET_LENGTH: - result = put_user(d->code_length, (__u32 __user *)arg); - break; default: result = -ENOTTY; } diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 857da67bd9319..0a03dd9e5a680 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -9,8 +9,6 @@ #ifndef _LINUX_LIRC_DEV_H #define _LINUX_LIRC_DEV_H -#define BUFLEN 16 - #include #include #include @@ -117,7 +115,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @code_length: length of a remote control key code expressed in bits * @features: lirc compatible hardware features, like LIRC_MODE_RAW, * LIRC_CAN\_\*, as defined at include/media/lirc.h. * @buffer_size: Number of FIFO buffers with @chunk_size size. @@ -142,7 +139,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, struct lirc_dev { char name[40]; unsigned int minor; - __u32 code_length; __u32 features; unsigned int buffer_size; /* in chunks holding one code each */ -- GitLab From 9b6192589be788dec73a0e99fe49b8f8ddaf825e Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:29 -0500 Subject: [PATCH 0197/1190] media: lirc: implement scancode sending This introduces a new lirc mode: scancode. Any device which can send raw IR can now also send scancodes. int main() { int mode, fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode = { .scancode = 0x1e3d, .rc_proto = RC_PROTO_RC5, }; write(fd, &scancode, sizeof(scancode)); close(fd); } The other fields of lirc_scancode must be set to 0. Note that toggle (rc5, rc6) and repeats (nec) are not implemented. Nor is there a method for holding down a key for a period. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 99 +++++++++++++++++++++++--------- drivers/media/rc/rc-core-priv.h | 2 +- include/media/rc-map.h | 54 +---------------- include/uapi/linux/lirc.h | 82 ++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 81 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 9954ad4b8e590..0a3ec693d290a 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -107,7 +107,8 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, { struct lirc_codec *lirc; struct rc_dev *dev; - unsigned int *txbuf; /* buffer with values to transmit */ + unsigned int *txbuf = NULL; + struct ir_raw_event *raw = NULL; ssize_t ret = -EINVAL; size_t count; ktime_t start; @@ -121,16 +122,50 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (!lirc) return -EFAULT; - if (n < sizeof(unsigned) || n % sizeof(unsigned)) - return -EINVAL; + if (lirc->send_mode == LIRC_MODE_SCANCODE) { + struct lirc_scancode scan; - count = n / sizeof(unsigned); - if (count > LIRCBUF_SIZE || count % 2 == 0) - return -EINVAL; + if (n != sizeof(scan)) + return -EINVAL; - txbuf = memdup_user(buf, n); - if (IS_ERR(txbuf)) - return PTR_ERR(txbuf); + if (copy_from_user(&scan, buf, sizeof(scan))) + return -EFAULT; + + if (scan.flags || scan.keycode || scan.timestamp) + return -EINVAL; + + raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL); + if (!raw) + return -ENOMEM; + + ret = ir_raw_encode_scancode(scan.rc_proto, scan.scancode, + raw, LIRCBUF_SIZE); + if (ret < 0) + goto out; + + count = ret; + + txbuf = kmalloc_array(count, sizeof(unsigned int), GFP_KERNEL); + if (!txbuf) { + ret = -ENOMEM; + goto out; + } + + for (i = 0; i < count; i++) + /* Convert from NS to US */ + txbuf[i] = DIV_ROUND_UP(raw[i].duration, 1000); + } else { + if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) + return -EINVAL; + + count = n / sizeof(unsigned int); + if (count > LIRCBUF_SIZE || count % 2 == 0) + return -EINVAL; + + txbuf = memdup_user(buf, n); + if (IS_ERR(txbuf)) + return PTR_ERR(txbuf); + } dev = lirc->dev; if (!dev) { @@ -156,24 +191,30 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (ret < 0) goto out; - for (duration = i = 0; i < ret; i++) - duration += txbuf[i]; - - ret *= sizeof(unsigned int); - - /* - * The lircd gap calculation expects the write function to - * wait for the actual IR signal to be transmitted before - * returning. - */ - towait = ktime_us_delta(ktime_add_us(start, duration), ktime_get()); - if (towait > 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(usecs_to_jiffies(towait)); + if (lirc->send_mode == LIRC_MODE_SCANCODE) { + ret = n; + } else { + for (duration = i = 0; i < ret; i++) + duration += txbuf[i]; + + ret *= sizeof(unsigned int); + + /* + * The lircd gap calculation expects the write function to + * wait for the actual IR signal to be transmitted before + * returning. + */ + towait = ktime_us_delta(ktime_add_us(start, duration), + ktime_get()); + if (towait > 0) { + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(usecs_to_jiffies(towait)); + } } out: kfree(txbuf); + kfree(raw); return ret; } @@ -202,20 +243,22 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, switch (cmd) { - /* legacy support */ + /* mode support */ case LIRC_GET_SEND_MODE: if (!dev->tx_ir) return -ENOTTY; - val = LIRC_MODE_PULSE; + val = lirc->send_mode; break; case LIRC_SET_SEND_MODE: if (!dev->tx_ir) return -ENOTTY; - if (val != LIRC_MODE_PULSE) + if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) return -EINVAL; + + lirc->send_mode = val; return 0; /* TX settings */ @@ -361,7 +404,7 @@ static int ir_lirc_register(struct rc_dev *dev) } if (dev->tx_ir) { - features |= LIRC_CAN_SEND_PULSE; + features |= LIRC_CAN_SEND_PULSE | LIRC_CAN_SEND_SCANCODE; if (dev->s_tx_mask) features |= LIRC_CAN_SET_TRANSMITTER_MASK; if (dev->s_tx_carrier) @@ -399,6 +442,8 @@ static int ir_lirc_register(struct rc_dev *dev) if (rc < 0) goto out; + dev->raw->lirc.send_mode = LIRC_MODE_PULSE; + dev->raw->lirc.ldev = ldev; dev->raw->lirc.dev = dev; return 0; diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 564d6e13585e5..d10fc998e1db4 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -103,7 +103,7 @@ struct ir_raw_event_ctrl { u64 gap_duration; bool gap; bool send_timeout_reports; - + u8 send_mode; } lirc; struct xmp_dec { int state; diff --git a/include/media/rc-map.h b/include/media/rc-map.h index 72197cb437815..7046734b38953 100644 --- a/include/media/rc-map.h +++ b/include/media/rc-map.h @@ -10,59 +10,7 @@ */ #include - -/** - * enum rc_proto - the Remote Controller protocol - * - * @RC_PROTO_UNKNOWN: Protocol not known - * @RC_PROTO_OTHER: Protocol known but proprietary - * @RC_PROTO_RC5: Philips RC5 protocol - * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol - * @RC_PROTO_RC5_SZ: StreamZap variant of RC5 - * @RC_PROTO_JVC: JVC protocol - * @RC_PROTO_SONY12: Sony 12 bit protocol - * @RC_PROTO_SONY15: Sony 15 bit protocol - * @RC_PROTO_SONY20: Sony 20 bit protocol - * @RC_PROTO_NEC: NEC protocol - * @RC_PROTO_NECX: Extended NEC protocol - * @RC_PROTO_NEC32: NEC 32 bit protocol - * @RC_PROTO_SANYO: Sanyo protocol - * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard - * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse - * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol - * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol - * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol - * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol - * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol - * @RC_PROTO_SHARP: Sharp protocol - * @RC_PROTO_XMP: XMP protocol - * @RC_PROTO_CEC: CEC protocol - */ -enum rc_proto { - RC_PROTO_UNKNOWN = 0, - RC_PROTO_OTHER = 1, - RC_PROTO_RC5 = 2, - RC_PROTO_RC5X_20 = 3, - RC_PROTO_RC5_SZ = 4, - RC_PROTO_JVC = 5, - RC_PROTO_SONY12 = 6, - RC_PROTO_SONY15 = 7, - RC_PROTO_SONY20 = 8, - RC_PROTO_NEC = 9, - RC_PROTO_NECX = 10, - RC_PROTO_NEC32 = 11, - RC_PROTO_SANYO = 12, - RC_PROTO_MCIR2_KBD = 13, - RC_PROTO_MCIR2_MSE = 14, - RC_PROTO_RC6_0 = 15, - RC_PROTO_RC6_6A_20 = 16, - RC_PROTO_RC6_6A_24 = 17, - RC_PROTO_RC6_6A_32 = 18, - RC_PROTO_RC6_MCE = 19, - RC_PROTO_SHARP = 20, - RC_PROTO_XMP = 21, - RC_PROTO_CEC = 22, -}; +#include #define RC_PROTO_BIT_NONE 0ULL #define RC_PROTO_BIT_UNKNOWN BIT_ULL(RC_PROTO_UNKNOWN) diff --git a/include/uapi/linux/lirc.h b/include/uapi/linux/lirc.h index c3aef4316fbf6..4fe580d36e415 100644 --- a/include/uapi/linux/lirc.h +++ b/include/uapi/linux/lirc.h @@ -47,12 +47,14 @@ #define LIRC_MODE_RAW 0x00000001 #define LIRC_MODE_PULSE 0x00000002 #define LIRC_MODE_MODE2 0x00000004 +#define LIRC_MODE_SCANCODE 0x00000008 #define LIRC_MODE_LIRCCODE 0x00000010 #define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW) #define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE) #define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2) +#define LIRC_CAN_SEND_SCANCODE LIRC_MODE2SEND(LIRC_MODE_SCANCODE) #define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE) #define LIRC_CAN_SEND_MASK 0x0000003f @@ -64,6 +66,7 @@ #define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW) #define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE) #define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2) +#define LIRC_CAN_REC_SCANCODE LIRC_MODE2REC(LIRC_MODE_SCANCODE) #define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE) #define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK) @@ -131,4 +134,83 @@ #define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32) +/* + * struct lirc_scancode - decoded scancode with protocol for use with + * LIRC_MODE_SCANCODE + * + * @timestamp: Timestamp in nanoseconds using CLOCK_MONOTONIC when IR + * was decoded. + * @flags: should be 0 for transmit. When receiving scancodes, + * LIRC_SCANCODE_FLAG_TOGGLE or LIRC_SCANCODE_FLAG_REPEAT can be set + * depending on the protocol + * @rc_proto: see enum rc_proto + * @keycode: the translated keycode. Set to 0 for transmit. + * @scancode: the scancode received or to be sent + */ +struct lirc_scancode { + __u64 timestamp; + __u16 flags; + __u16 rc_proto; + __u32 keycode; + __u64 scancode; +}; + +/* Set if the toggle bit of rc-5 or rc-6 is enabled */ +#define LIRC_SCANCODE_FLAG_TOGGLE 1 +/* Set if this is a nec or sanyo repeat */ +#define LIRC_SCANCODE_FLAG_REPEAT 2 + +/** + * enum rc_proto - the Remote Controller protocol + * + * @RC_PROTO_UNKNOWN: Protocol not known + * @RC_PROTO_OTHER: Protocol known but proprietary + * @RC_PROTO_RC5: Philips RC5 protocol + * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol + * @RC_PROTO_RC5_SZ: StreamZap variant of RC5 + * @RC_PROTO_JVC: JVC protocol + * @RC_PROTO_SONY12: Sony 12 bit protocol + * @RC_PROTO_SONY15: Sony 15 bit protocol + * @RC_PROTO_SONY20: Sony 20 bit protocol + * @RC_PROTO_NEC: NEC protocol + * @RC_PROTO_NECX: Extended NEC protocol + * @RC_PROTO_NEC32: NEC 32 bit protocol + * @RC_PROTO_SANYO: Sanyo protocol + * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard + * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse + * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol + * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol + * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol + * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol + * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol + * @RC_PROTO_SHARP: Sharp protocol + * @RC_PROTO_XMP: XMP protocol + * @RC_PROTO_CEC: CEC protocol + */ +enum rc_proto { + RC_PROTO_UNKNOWN = 0, + RC_PROTO_OTHER = 1, + RC_PROTO_RC5 = 2, + RC_PROTO_RC5X_20 = 3, + RC_PROTO_RC5_SZ = 4, + RC_PROTO_JVC = 5, + RC_PROTO_SONY12 = 6, + RC_PROTO_SONY15 = 7, + RC_PROTO_SONY20 = 8, + RC_PROTO_NEC = 9, + RC_PROTO_NECX = 10, + RC_PROTO_NEC32 = 11, + RC_PROTO_SANYO = 12, + RC_PROTO_MCIR2_KBD = 13, + RC_PROTO_MCIR2_MSE = 14, + RC_PROTO_RC6_0 = 15, + RC_PROTO_RC6_6A_20 = 16, + RC_PROTO_RC6_6A_24 = 17, + RC_PROTO_RC6_6A_32 = 18, + RC_PROTO_RC6_MCE = 19, + RC_PROTO_SHARP = 20, + RC_PROTO_XMP = 21, + RC_PROTO_CEC = 22, +}; + #endif -- GitLab From cdfaa01c1cfeb828e6d3c0c5e4f54375fc3ccb95 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:30 -0500 Subject: [PATCH 0198/1190] media: lirc: use the correct carrier for scancode transmit If the lirc device supports it, set the carrier for the protocol. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-jvc-decoder.c | 1 + drivers/media/rc/ir-lirc-codec.c | 29 ++++++++++++++++---------- drivers/media/rc/ir-mce_kbd-decoder.c | 1 + drivers/media/rc/ir-nec-decoder.c | 1 + drivers/media/rc/ir-rc5-decoder.c | 1 + drivers/media/rc/ir-rc6-decoder.c | 1 + drivers/media/rc/ir-sanyo-decoder.c | 1 + drivers/media/rc/ir-sharp-decoder.c | 1 + drivers/media/rc/ir-sony-decoder.c | 1 + drivers/media/rc/rc-core-priv.h | 1 + drivers/media/rc/rc-ir-raw.c | 30 +++++++++++++++++++++++++++ include/media/rc-core.h | 1 + 12 files changed, 58 insertions(+), 11 deletions(-) diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c index 22c8aee3df4fe..c03c776cfa545 100644 --- a/drivers/media/rc/ir-jvc-decoder.c +++ b/drivers/media/rc/ir-jvc-decoder.c @@ -212,6 +212,7 @@ static struct ir_raw_handler jvc_handler = { .protocols = RC_PROTO_BIT_JVC, .decode = ir_jvc_decode, .encode = ir_jvc_encode, + .carrier = 38000, }; static int __init ir_jvc_decode_init(void) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 0a3ec693d290a..bdacbadac4165 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -122,6 +122,17 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (!lirc) return -EFAULT; + dev = lirc->dev; + if (!dev) { + ret = -EFAULT; + goto out; + } + + if (!dev->tx_ir) { + ret = -EINVAL; + goto out; + } + if (lirc->send_mode == LIRC_MODE_SCANCODE) { struct lirc_scancode scan; @@ -154,6 +165,13 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, for (i = 0; i < count; i++) /* Convert from NS to US */ txbuf[i] = DIV_ROUND_UP(raw[i].duration, 1000); + + if (dev->s_tx_carrier) { + int carrier = ir_raw_encode_carrier(scan.rc_proto); + + if (carrier > 0) + dev->s_tx_carrier(dev, carrier); + } } else { if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) return -EINVAL; @@ -167,17 +185,6 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, return PTR_ERR(txbuf); } - dev = lirc->dev; - if (!dev) { - ret = -EFAULT; - goto out; - } - - if (!dev->tx_ir) { - ret = -EINVAL; - goto out; - } - for (i = 0; i < count; i++) { if (txbuf[i] > IR_MAX_DURATION / 1000 - duration || !txbuf[i]) { ret = -EINVAL; diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index 69d6264d54e6e..dbc6e00bace2d 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -473,6 +473,7 @@ static struct ir_raw_handler mce_kbd_handler = { .encode = ir_mce_kbd_encode, .raw_register = ir_mce_kbd_register, .raw_unregister = ir_mce_kbd_unregister, + .carrier = 36000, }; static int __init ir_mce_kbd_decode_init(void) diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c index 22eed9505244f..31d7bafe7bdab 100644 --- a/drivers/media/rc/ir-nec-decoder.c +++ b/drivers/media/rc/ir-nec-decoder.c @@ -254,6 +254,7 @@ static struct ir_raw_handler nec_handler = { RC_PROTO_BIT_NEC32, .decode = ir_nec_decode, .encode = ir_nec_encode, + .carrier = 38000, }; static int __init ir_nec_decode_init(void) diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c index cbff3e26d481c..f589d99245eb7 100644 --- a/drivers/media/rc/ir-rc5-decoder.c +++ b/drivers/media/rc/ir-rc5-decoder.c @@ -273,6 +273,7 @@ static struct ir_raw_handler rc5_handler = { RC_PROTO_BIT_RC5_SZ, .decode = ir_rc5_decode, .encode = ir_rc5_encode, + .carrier = 36000, }; static int __init ir_rc5_decode_init(void) diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c index 5d0d2fe3b7a7f..665025303c281 100644 --- a/drivers/media/rc/ir-rc6-decoder.c +++ b/drivers/media/rc/ir-rc6-decoder.c @@ -408,6 +408,7 @@ static struct ir_raw_handler rc6_handler = { RC_PROTO_BIT_RC6_MCE, .decode = ir_rc6_decode, .encode = ir_rc6_encode, + .carrier = 36000, }; static int __init ir_rc6_decode_init(void) diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c index 2138f0e9472d7..ded39cdfc6efc 100644 --- a/drivers/media/rc/ir-sanyo-decoder.c +++ b/drivers/media/rc/ir-sanyo-decoder.c @@ -209,6 +209,7 @@ static struct ir_raw_handler sanyo_handler = { .protocols = RC_PROTO_BIT_SANYO, .decode = ir_sanyo_decode, .encode = ir_sanyo_encode, + .carrier = 38000, }; static int __init ir_sanyo_decode_init(void) diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c index 7140dd6160eee..df296991906c4 100644 --- a/drivers/media/rc/ir-sharp-decoder.c +++ b/drivers/media/rc/ir-sharp-decoder.c @@ -226,6 +226,7 @@ static struct ir_raw_handler sharp_handler = { .protocols = RC_PROTO_BIT_SHARP, .decode = ir_sharp_decode, .encode = ir_sharp_encode, + .carrier = 38000, }; static int __init ir_sharp_decode_init(void) diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c index a47ced763031d..e4bcff21c0252 100644 --- a/drivers/media/rc/ir-sony-decoder.c +++ b/drivers/media/rc/ir-sony-decoder.c @@ -221,6 +221,7 @@ static struct ir_raw_handler sony_handler = { RC_PROTO_BIT_SONY20, .decode = ir_sony_decode, .encode = ir_sony_encode, + .carrier = 40000, }; static int __init ir_sony_decode_init(void) diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index d10fc998e1db4..2fab4069c023a 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -19,6 +19,7 @@ struct ir_raw_handler { int (*decode)(struct rc_dev *dev, struct ir_raw_event event); int (*encode)(enum rc_proto protocol, u32 scancode, struct ir_raw_event *events, unsigned int max); + u32 carrier; /* These two should only be used by the lirc decoder */ int (*raw_register)(struct rc_dev *dev); diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 0616eee564a89..208db8a5adff5 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -484,6 +484,36 @@ static void edge_handle(struct timer_list *t) ir_raw_event_handle(dev); } +/** + * ir_raw_encode_carrier() - Get carrier used for protocol + * + * @protocol: protocol + * + * Attempts to find the carrier for the specified protocol + * + * Returns: The carrier in Hz + * -EINVAL if the protocol is invalid, or if no + * compatible encoder was found. + */ +int ir_raw_encode_carrier(enum rc_proto protocol) +{ + struct ir_raw_handler *handler; + int ret = -EINVAL; + u64 mask = BIT_ULL(protocol); + + mutex_lock(&ir_raw_handler_lock); + list_for_each_entry(handler, &ir_raw_handler_list, list) { + if (handler->protocols & mask && handler->encode) { + ret = handler->carrier; + break; + } + } + mutex_unlock(&ir_raw_handler_lock); + + return ret; +} +EXPORT_SYMBOL(ir_raw_encode_carrier); + /* * Used to (un)register raw event clients */ diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 314a1edb6189b..ca48632ec8e2a 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -309,6 +309,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode, struct ir_raw_event *events, unsigned int max); +int ir_raw_encode_carrier(enum rc_proto protocol); static inline void ir_raw_event_reset(struct rc_dev *dev) { -- GitLab From 0d39ab0b628b38acf83506d36e9ec969055698df Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:31 -0500 Subject: [PATCH 0199/1190] media: rc: auto load encoder if necessary When sending scancodes, load the encoder if we need it. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/rc-core-priv.h | 1 + drivers/media/rc/rc-ir-raw.c | 2 ++ drivers/media/rc/rc-main.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 2fab4069c023a..6014f116cba2b 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -261,6 +261,7 @@ void ir_raw_event_free(struct rc_dev *dev); void ir_raw_event_unregister(struct rc_dev *dev); int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler); void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler); +void ir_raw_load_modules(u64 *protocols); void ir_raw_init(void); /* diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 208db8a5adff5..78638d1b73ccc 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -448,6 +448,8 @@ int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode, int ret = -EINVAL; u64 mask = 1ULL << protocol; + ir_raw_load_modules(&mask); + mutex_lock(&ir_raw_handler_lock); list_for_each_entry(handler, &ir_raw_handler_list, list) { if (handler->protocols & mask && handler->encode) { diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 372f4d61cb485..29a90adb0f7c6 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1082,7 +1082,7 @@ static int parse_protocol_change(u64 *protocols, const char *buf) return count; } -static void ir_raw_load_modules(u64 *protocols) +void ir_raw_load_modules(u64 *protocols) { u64 available; int i, ret; -- GitLab From a60d64b15c20d178ba3a9bc3a542492b4ddeea70 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 10:41:13 -0400 Subject: [PATCH 0200/1190] media: lirc: lirc interface should not be a raw decoder The lirc user interface exists as a raw decoder, which does not make much sense for transmit-only devices. In addition, we want to have lirc char devices for devices which do not use raw IR, i.e. scancode only devices. Note that rc-code, lirc_dev, ir-lirc-codec are now calling functions of each other, so they've been merged into one module rc-core to avoid circular dependencies. Since ir-lirc-codec no longer exists as separate codec module, there is no need for RC_DRIVER_IR_RAW_TX type drivers to call ir_raw_event_register(). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/Kconfig | 29 ++---- drivers/media/rc/Makefile | 5 +- drivers/media/rc/ir-lirc-codec.c | 135 +++++++------------------- drivers/media/rc/ir-mce_kbd-decoder.c | 6 -- drivers/media/rc/lirc_dev.c | 47 +++------ drivers/media/rc/rc-core-priv.h | 45 ++++++--- drivers/media/rc/rc-ir-raw.c | 24 +---- drivers/media/rc/rc-main.c | 52 +++++----- include/media/lirc_dev.h | 10 -- include/media/rc-core.h | 33 ++++--- 10 files changed, 143 insertions(+), 243 deletions(-) diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig index afb3456d4e201..0f863822889ed 100644 --- a/drivers/media/rc/Kconfig +++ b/drivers/media/rc/Kconfig @@ -16,34 +16,21 @@ menuconfig RC_CORE if RC_CORE source "drivers/media/rc/keymaps/Kconfig" -menuconfig RC_DECODERS - bool "Remote controller decoders" - depends on RC_CORE - default y - -if RC_DECODERS config LIRC - tristate "LIRC interface driver" + bool "LIRC user interface" depends on RC_CORE - ---help--- - Enable this option to build the Linux Infrared Remote - Control (LIRC) core device interface driver. The LIRC - interface passes raw IR to and from userspace, where the - LIRC daemon handles protocol decoding for IR reception and - encoding for IR transmitting (aka "blasting"). + Enable this option to enable the Linux Infrared Remote + Control user interface (e.g. /dev/lirc*). This interface + passes raw IR to and from userspace, which is needed for + IR transmitting (aka "blasting") and for the lirc daemon. -config IR_LIRC_CODEC - tristate "Enable IR to LIRC bridge" +menuconfig RC_DECODERS + bool "Remote controller decoders" depends on RC_CORE - depends on LIRC default y - ---help--- - Enable this option to pass raw IR to and from userspace via - the LIRC interface. - - +if RC_DECODERS config IR_NEC_DECODER tristate "Enable IR raw decoder for the NEC protocol" depends on RC_CORE diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile index 10026477a677e..081b34f971647 100644 --- a/drivers/media/rc/Makefile +++ b/drivers/media/rc/Makefile @@ -1,10 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 -rc-core-objs := rc-main.o rc-ir-raw.o obj-y += keymaps/ obj-$(CONFIG_RC_CORE) += rc-core.o -obj-$(CONFIG_LIRC) += lirc_dev.o +rc-core-y := rc-main.o rc-ir-raw.o +rc-core-$(CONFIG_LIRC) += lirc_dev.o ir-lirc-codec.o obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o @@ -13,7 +13,6 @@ obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o obj-$(CONFIG_IR_SHARP_DECODER) += ir-sharp-decoder.o obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o -obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o obj-$(CONFIG_IR_XMP_DECODER) += ir-xmp-decoder.o # stand-alone IR receivers/transmitters diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index bdacbadac4165..aec0109b1a697 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -23,21 +22,15 @@ #define LIRCBUF_SIZE 256 /** - * ir_lirc_decode() - Send raw IR data to lirc_dev to be relayed to the - * lircd userspace daemon for decoding. + * ir_lirc_raw_event() - Send raw IR data to lirc to be relayed to userspace + * * @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space - * - * This function returns -EINVAL if the lirc interfaces aren't wired up. */ -static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) +void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) { - struct lirc_codec *lirc = &dev->raw->lirc; int sample; - if (!dev->raw->lirc.ldev || !dev->raw->lirc.ldev->buf) - return -EINVAL; - /* Packet start */ if (ev.reset) { /* Userspace expects a long space event before the start of @@ -56,15 +49,15 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) /* Packet end */ } else if (ev.timeout) { - if (lirc->gap) - return 0; + if (dev->gap) + return; - lirc->gap_start = ktime_get(); - lirc->gap = true; - lirc->gap_duration = ev.duration; + dev->gap_start = ktime_get(); + dev->gap = true; + dev->gap_duration = ev.duration; - if (!lirc->send_timeout_reports) - return 0; + if (!dev->send_timeout_reports) + return; sample = LIRC_TIMEOUT(ev.duration / 1000); IR_dprintk(2, "timeout report (duration: %d)\n", sample); @@ -72,21 +65,21 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) /* Normal sample */ } else { - if (lirc->gap) { + if (dev->gap) { int gap_sample; - lirc->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), - lirc->gap_start)); + dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), + dev->gap_start)); /* Convert to ms and cap by LIRC_VALUE_MASK */ - do_div(lirc->gap_duration, 1000); - lirc->gap_duration = min(lirc->gap_duration, - (u64)LIRC_VALUE_MASK); + do_div(dev->gap_duration, 1000); + dev->gap_duration = min_t(u64, dev->gap_duration, + LIRC_VALUE_MASK); - gap_sample = LIRC_SPACE(lirc->gap_duration); - lirc_buffer_write(dev->raw->lirc.ldev->buf, + gap_sample = LIRC_SPACE(dev->gap_duration); + lirc_buffer_write(dev->lirc_dev->buf, (unsigned char *)&gap_sample); - lirc->gap = false; + dev->gap = false; } sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) : @@ -95,18 +88,16 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) TO_US(ev.duration), TO_STR(ev.pulse)); } - lirc_buffer_write(dev->raw->lirc.ldev->buf, + lirc_buffer_write(dev->lirc_dev->buf, (unsigned char *) &sample); - wake_up(&dev->raw->lirc.ldev->buf->wait_poll); - return 0; + wake_up(&dev->lirc_dev->buf->wait_poll); } static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, size_t n, loff_t *ppos) { - struct lirc_codec *lirc; - struct rc_dev *dev; + struct rc_dev *dev = file->private_data; unsigned int *txbuf = NULL; struct ir_raw_event *raw = NULL; ssize_t ret = -EINVAL; @@ -118,22 +109,12 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, start = ktime_get(); - lirc = lirc_get_pdata(file); - if (!lirc) - return -EFAULT; - - dev = lirc->dev; - if (!dev) { - ret = -EFAULT; - goto out; - } - if (!dev->tx_ir) { ret = -EINVAL; goto out; } - if (lirc->send_mode == LIRC_MODE_SCANCODE) { + if (dev->send_mode == LIRC_MODE_SCANCODE) { struct lirc_scancode scan; if (n != sizeof(scan)) @@ -198,7 +179,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (ret < 0) goto out; - if (lirc->send_mode == LIRC_MODE_SCANCODE) { + if (dev->send_mode == LIRC_MODE_SCANCODE) { ret = n; } else { for (duration = i = 0; i < ret; i++) @@ -228,20 +209,11 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - struct lirc_codec *lirc; - struct rc_dev *dev; + struct rc_dev *dev = filep->private_data; u32 __user *argp = (u32 __user *)(arg); int ret = 0; __u32 val = 0, tmp; - lirc = lirc_get_pdata(filep); - if (!lirc) - return -EFAULT; - - dev = lirc->dev; - if (!dev) - return -EFAULT; - if (_IOC_DIR(cmd) & _IOC_WRITE) { ret = get_user(val, argp); if (ret) @@ -255,7 +227,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!dev->tx_ir) return -ENOTTY; - val = lirc->send_mode; + val = dev->send_mode; break; case LIRC_SET_SEND_MODE: @@ -265,7 +237,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) return -EINVAL; - lirc->send_mode = val; + dev->send_mode = val; return 0; /* TX settings */ @@ -299,7 +271,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, return -EINVAL; return dev->s_rx_carrier_range(dev, - dev->raw->lirc.carrier_low, + dev->carrier_low, val); case LIRC_SET_REC_CARRIER_RANGE: @@ -309,7 +281,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (val <= 0) return -EINVAL; - dev->raw->lirc.carrier_low = val; + dev->carrier_low = val; return 0; case LIRC_GET_REC_RESOLUTION: @@ -367,7 +339,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!dev->timeout) return -ENOTTY; - lirc->send_timeout_reports = !!val; + dev->send_timeout_reports = !!val; break; default: @@ -394,7 +366,7 @@ static const struct file_operations lirc_fops = { .llseek = no_llseek, }; -static int ir_lirc_register(struct rc_dev *dev) +int ir_lirc_register(struct rc_dev *dev) { struct lirc_dev *ldev; int rc = -ENOMEM; @@ -436,7 +408,6 @@ static int ir_lirc_register(struct rc_dev *dev) snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", dev->driver_name); ldev->features = features; - ldev->data = &dev->raw->lirc; ldev->buf = NULL; ldev->chunk_size = sizeof(int); ldev->buffer_size = LIRCBUF_SIZE; @@ -449,10 +420,8 @@ static int ir_lirc_register(struct rc_dev *dev) if (rc < 0) goto out; - dev->raw->lirc.send_mode = LIRC_MODE_PULSE; - - dev->raw->lirc.ldev = ldev; - dev->raw->lirc.dev = dev; + dev->send_mode = LIRC_MODE_PULSE; + dev->lirc_dev = ldev; return 0; out: @@ -460,40 +429,8 @@ static int ir_lirc_register(struct rc_dev *dev) return rc; } -static int ir_lirc_unregister(struct rc_dev *dev) -{ - struct lirc_codec *lirc = &dev->raw->lirc; - - lirc_unregister_device(lirc->ldev); - lirc->ldev = NULL; - - return 0; -} - -static struct ir_raw_handler lirc_handler = { - .protocols = 0, - .decode = ir_lirc_decode, - .raw_register = ir_lirc_register, - .raw_unregister = ir_lirc_unregister, -}; - -static int __init ir_lirc_codec_init(void) +void ir_lirc_unregister(struct rc_dev *dev) { - ir_raw_handler_register(&lirc_handler); - - printk(KERN_INFO "IR LIRC bridge handler initialized\n"); - return 0; -} - -static void __exit ir_lirc_codec_exit(void) -{ - ir_raw_handler_unregister(&lirc_handler); + lirc_unregister_device(dev->lirc_dev); + dev->lirc_dev = NULL; } - -module_init(ir_lirc_codec_init); -module_exit(ir_lirc_codec_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Jarod Wilson "); -MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); -MODULE_DESCRIPTION("LIRC IR handler bridge"); diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index dbc6e00bace2d..2c9ee0c1f4321 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -358,9 +358,6 @@ static int ir_mce_kbd_register(struct rc_dev *dev) struct input_dev *idev; int i, ret; - if (dev->driver_type == RC_DRIVER_IR_RAW_TX) - return 0; - idev = input_allocate_device(); if (!idev) return -ENOMEM; @@ -415,9 +412,6 @@ static int ir_mce_kbd_unregister(struct rc_dev *dev) struct mce_kbd_dec *mce_kbd = &dev->raw->mce_kbd; struct input_dev *idev = mce_kbd->idev; - if (dev->driver_type == RC_DRIVER_IR_RAW_TX) - return 0; - del_timer_sync(&mce_kbd->rx_timeout); input_unregister_device(idev); diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index ef7e915dc9a24..3cc95deaa84ea 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -26,7 +26,7 @@ #include #include -#include +#include "rc-core-priv.h" #include #include @@ -236,7 +236,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) d->open++; - lirc_init_pdata(inode, file); + file->private_data = d->rdev; nonseekable_open(inode, file); mutex_unlock(&d->mutex); @@ -250,11 +250,12 @@ EXPORT_SYMBOL(lirc_dev_fop_open); int lirc_dev_fop_close(struct inode *inode, struct file *file) { - struct lirc_dev *d = file->private_data; + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; mutex_lock(&d->mutex); - rc_close(d->rdev); + rc_close(rcdev); d->open--; mutex_unlock(&d->mutex); @@ -265,7 +266,8 @@ EXPORT_SYMBOL(lirc_dev_fop_close); unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) { - struct lirc_dev *d = file->private_data; + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; unsigned int ret; if (!d->attached) @@ -290,7 +292,8 @@ EXPORT_SYMBOL(lirc_dev_fop_poll); long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct lirc_dev *d = file->private_data; + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; __u32 mode; int result; @@ -349,7 +352,8 @@ ssize_t lirc_dev_fop_read(struct file *file, size_t length, loff_t *ppos) { - struct lirc_dev *d = file->private_data; + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; unsigned char *buf; int ret, written = 0; DECLARE_WAITQUEUE(wait, current); @@ -448,24 +452,7 @@ ssize_t lirc_dev_fop_read(struct file *file, } EXPORT_SYMBOL(lirc_dev_fop_read); -void lirc_init_pdata(struct inode *inode, struct file *file) -{ - struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); - - file->private_data = d; -} -EXPORT_SYMBOL(lirc_init_pdata); - -void *lirc_get_pdata(struct file *file) -{ - struct lirc_dev *d = file->private_data; - - return d->data; -} -EXPORT_SYMBOL(lirc_get_pdata); - - -static int __init lirc_dev_init(void) +int __init lirc_dev_init(void) { int retval; @@ -489,16 +476,8 @@ static int __init lirc_dev_init(void) return 0; } -static void __exit lirc_dev_exit(void) +void __exit lirc_dev_exit(void) { class_destroy(lirc_class); unregister_chrdev_region(lirc_base_dev, LIRC_MAX_DEVICES); - pr_info("module unloaded\n"); } - -module_init(lirc_dev_init); -module_exit(lirc_dev_exit); - -MODULE_DESCRIPTION("LIRC base driver module"); -MODULE_AUTHOR("Artur Lipowski"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 6014f116cba2b..face39c3a96cf 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -12,6 +12,20 @@ #include #include +/** + * rc_open - Opens a RC device + * + * @rdev: pointer to struct rc_dev. + */ +int rc_open(struct rc_dev *rdev); + +/** + * rc_close - Closes a RC device + * + * @rdev: pointer to struct rc_dev. + */ +void rc_close(struct rc_dev *rdev); + struct ir_raw_handler { struct list_head list; @@ -21,7 +35,7 @@ struct ir_raw_handler { struct ir_raw_event *events, unsigned int max); u32 carrier; - /* These two should only be used by the lirc decoder */ + /* These two should only be used by the mce kbd decoder */ int (*raw_register)(struct rc_dev *dev); int (*raw_unregister)(struct rc_dev *dev); }; @@ -95,17 +109,6 @@ struct ir_raw_event_ctrl { unsigned count; unsigned wanted_bits; } mce_kbd; - struct lirc_codec { - struct rc_dev *dev; - struct lirc_dev *ldev; - int carrier_low; - - ktime_t gap_start; - u64 gap_duration; - bool gap; - bool send_timeout_reports; - u8 send_mode; - } lirc; struct xmp_dec { int state; unsigned count; @@ -264,6 +267,24 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler); void ir_raw_load_modules(u64 *protocols); void ir_raw_init(void); +/* + * lirc interface + */ +#ifdef CONFIG_LIRC +int lirc_dev_init(void); +void lirc_dev_exit(void); +void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev); +int ir_lirc_register(struct rc_dev *dev); +void ir_lirc_unregister(struct rc_dev *dev); +#else +static inline int lirc_dev_init(void) { return 0; } +static inline void lirc_dev_exit(void) {} +static inline void ir_lirc_raw_event(struct rc_dev *dev, + struct ir_raw_event ev) { } +static inline int ir_lirc_register(struct rc_dev *dev) { return 0; } +static inline void ir_lirc_unregister(struct rc_dev *dev) { } +#endif + /* * Decoder initialization code * diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 78638d1b73ccc..3dabb783a1f0f 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -31,6 +31,7 @@ static int ir_raw_event_thread(void *data) if (raw->dev->enabled_protocols & handler->protocols || !handler->protocols) handler->decode(raw->dev, ev); + ir_lirc_raw_event(raw->dev, ev); raw->prev_ev = ev; } mutex_unlock(&ir_raw_handler_lock); @@ -521,16 +522,9 @@ EXPORT_SYMBOL(ir_raw_encode_carrier); */ int ir_raw_event_prepare(struct rc_dev *dev) { - static bool raw_init; /* 'false' default value, raw decoders loaded? */ - if (!dev) return -EINVAL; - if (!raw_init) { - request_module("ir-lirc-codec"); - raw_init = true; - } - dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL); if (!dev->raw) return -ENOMEM; @@ -548,19 +542,11 @@ int ir_raw_event_register(struct rc_dev *dev) struct ir_raw_handler *handler; struct task_struct *thread; - /* - * raw transmitters do not need any event registration - * because the event is coming from userspace - */ - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { - thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u", - dev->minor); + thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u", dev->minor); + if (IS_ERR(thread)) + return PTR_ERR(thread); - if (IS_ERR(thread)) - return PTR_ERR(thread); - - dev->raw->thread = thread; - } + dev->raw->thread = thread; mutex_lock(&ir_raw_handler_lock); list_add_tail(&dev->raw->list, &ir_raw_client_list); diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 29a90adb0f7c6..56b322b3d3258 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -846,7 +846,6 @@ int rc_open(struct rc_dev *rdev) return rval; } -EXPORT_SYMBOL_GPL(rc_open); static int ir_open(struct input_dev *idev) { @@ -866,7 +865,6 @@ void rc_close(struct rc_dev *rdev) mutex_unlock(&rdev->lock); } } -EXPORT_SYMBOL_GPL(rc_close); static void ir_close(struct input_dev *idev) { @@ -941,23 +939,6 @@ struct rc_filter_attribute { .mask = (_mask), \ } -static bool lirc_is_present(void) -{ -#if defined(CONFIG_LIRC_MODULE) - struct module *lirc; - - mutex_lock(&module_mutex); - lirc = find_module("lirc_dev"); - mutex_unlock(&module_mutex); - - return lirc ? true : false; -#elif defined(CONFIG_LIRC) - return true; -#else - return false; -#endif -} - /** * show_protocols() - shows the current IR protocol(s) * @device: the device descriptor @@ -1002,8 +983,10 @@ static ssize_t show_protocols(struct device *device, allowed &= ~proto_names[i].type; } - if (dev->driver_type == RC_DRIVER_IR_RAW && lirc_is_present()) +#ifdef CONFIG_LIRC + if (dev->driver_type == RC_DRIVER_IR_RAW) tmp += sprintf(tmp, "[lirc] "); +#endif if (tmp != buf) tmp--; @@ -1759,8 +1742,7 @@ int rc_register_device(struct rc_dev *dev) dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp; dev->sysfs_groups[attr++] = NULL; - if (dev->driver_type == RC_DRIVER_IR_RAW || - dev->driver_type == RC_DRIVER_IR_RAW_TX) { + if (dev->driver_type == RC_DRIVER_IR_RAW) { rc = ir_raw_event_prepare(dev); if (rc < 0) goto out_minor; @@ -1787,19 +1769,28 @@ int rc_register_device(struct rc_dev *dev) goto out_dev; } - if (dev->driver_type == RC_DRIVER_IR_RAW || - dev->driver_type == RC_DRIVER_IR_RAW_TX) { - rc = ir_raw_event_register(dev); + /* Ensure that the lirc kfifo is setup before we start the thread */ + if (dev->driver_type != RC_DRIVER_SCANCODE) { + rc = ir_lirc_register(dev); if (rc < 0) goto out_rx; } + if (dev->driver_type == RC_DRIVER_IR_RAW) { + rc = ir_raw_event_register(dev); + if (rc < 0) + goto out_lirc; + } + IR_dprintk(1, "Registered rc%u (driver: %s)\n", dev->minor, dev->driver_name ? dev->driver_name : "unknown"); return 0; +out_lirc: + if (dev->driver_type != RC_DRIVER_SCANCODE) + ir_lirc_unregister(dev); out_rx: rc_free_rx_device(dev); out_dev: @@ -1853,6 +1844,9 @@ void rc_unregister_device(struct rc_dev *dev) rc_free_rx_device(dev); + if (dev->driver_type != RC_DRIVER_SCANCODE) + ir_lirc_unregister(dev); + device_del(&dev->dev); ida_simple_remove(&rc_ida, dev->minor); @@ -1875,6 +1869,13 @@ static int __init rc_core_init(void) return rc; } + rc = lirc_dev_init(); + if (rc) { + pr_err("rc_core: unable to init lirc\n"); + class_unregister(&rc_class); + return 0; + } + led_trigger_register_simple("rc-feedback", &led_feedback); rc_map_register(&empty_map); @@ -1883,6 +1884,7 @@ static int __init rc_core_init(void) static void __exit rc_core_exit(void) { + lirc_dev_exit(); class_unregister(&rc_class); led_trigger_unregister_simple(led_feedback); rc_map_unregister(&empty_map); diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 0a03dd9e5a680..dd0c078796e89 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -121,7 +121,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * Only used if @rbuf is NULL. * @chunk_size: Size of each FIFO buffer. * Only used if @rbuf is NULL. - * @data: private per-driver data * @buf: if %NULL, lirc_dev will allocate and manage the buffer, * otherwise allocated by the caller which will * have to write to the buffer by other means, like irq's @@ -146,7 +145,6 @@ struct lirc_dev { struct lirc_buffer *buf; bool buf_internal; - void *data; struct rc_dev *rdev; const struct file_operations *fops; struct module *owner; @@ -168,14 +166,6 @@ int lirc_register_device(struct lirc_dev *d); void lirc_unregister_device(struct lirc_dev *d); -/* Must be called in the open fop before lirc_get_pdata() can be used */ -void lirc_init_pdata(struct inode *inode, struct file *file); - -/* Returns the private data stored in the lirc_dev - * associated with the given device file pointer. - */ -void *lirc_get_pdata(struct file *file); - /* default file operations * used by drivers if they override only some operations */ diff --git a/include/media/rc-core.h b/include/media/rc-core.h index ca48632ec8e2a..5d6e415c7acc2 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -20,6 +20,7 @@ #include #include #include +#include #include extern int rc_core_debug; @@ -115,6 +116,15 @@ enum rc_filter_type { * @max_timeout: maximum timeout supported by device * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler + * @lirc_dev: lirc char device + * @carrier_low: when setting the carrier range, first the low end must be + * set with an ioctl and then the high end with another ioctl + * @gap_start: time when gap starts + * @gap_duration: duration of initial gap + * @gap: true if we're in a gap + * @send_timeout_reports: report timeouts in lirc raw IR. + * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or + * LIRC_MODE_PULSE * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device * is opened. @@ -174,6 +184,15 @@ struct rc_dev { u32 max_timeout; u32 rx_resolution; u32 tx_resolution; +#ifdef CONFIG_LIRC + struct lirc_dev *lirc_dev; + int carrier_low; + ktime_t gap_start; + u64 gap_duration; + bool gap; + bool send_timeout_reports; + u8 send_mode; +#endif int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); int (*open)(struct rc_dev *dev); void (*close)(struct rc_dev *dev); @@ -248,20 +267,6 @@ int devm_rc_register_device(struct device *parent, struct rc_dev *dev); */ void rc_unregister_device(struct rc_dev *dev); -/** - * rc_open - Opens a RC device - * - * @rdev: pointer to struct rc_dev. - */ -int rc_open(struct rc_dev *rdev); - -/** - * rc_close - Closes a RC device - * - * @rdev: pointer to struct rc_dev. - */ -void rc_close(struct rc_dev *rdev); - void rc_repeat(struct rc_dev *dev); void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, u8 toggle); -- GitLab From 49a4b36ada336270b564cabbbcb727cadebd024d Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 27 Sep 2017 16:00:49 -0400 Subject: [PATCH 0201/1190] media: lirc: validate scancode for transmit Ensure we reject an attempt to transmit invalid scancodes. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 10 ++++++ drivers/media/rc/rc-core-priv.h | 1 + drivers/media/rc/rc-main.c | 53 ++++++++++++++++++++------------ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index aec0109b1a697..1ed69c9e64bf1 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -126,6 +126,16 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (scan.flags || scan.keycode || scan.timestamp) return -EINVAL; + /* + * The scancode field in lirc_scancode is 64-bit simply + * to future-proof it, since there are IR protocols encode + * use more than 32 bits. For now only 32-bit protocols + * are supported. + */ + if (scan.scancode > U32_MAX || + !rc_validate_scancode(scan.rc_proto, scan.scancode)) + return -EINVAL; + raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL); if (!raw) return -ENOMEM; diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index face39c3a96cf..6d5a36b8b550f 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -150,6 +150,7 @@ static inline bool is_timing_event(struct ir_raw_event ev) #define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") /* functions for IR encoders */ +bool rc_validate_scancode(enum rc_proto proto, u32 scancode); static inline void init_ir_raw_event_duration(struct ir_raw_event *ev, unsigned int pulse, diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 56b322b3d3258..ce8837b1facd6 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -775,6 +775,37 @@ void rc_keydown_notimeout(struct rc_dev *dev, enum rc_proto protocol, } EXPORT_SYMBOL_GPL(rc_keydown_notimeout); +/** + * rc_validate_scancode() - checks that a scancode is valid for a protocol + * @proto: protocol + * @scancode: scancode + */ +bool rc_validate_scancode(enum rc_proto proto, u32 scancode) +{ + switch (proto) { + case RC_PROTO_NECX: + if ((((scancode >> 16) ^ ~(scancode >> 8)) & 0xff) == 0) + return false; + break; + case RC_PROTO_NEC32: + if ((((scancode >> 24) ^ ~(scancode >> 16)) & 0xff) == 0) + return false; + break; + case RC_PROTO_RC6_MCE: + if ((scancode & 0xffff0000) != 0x800f0000) + return false; + break; + case RC_PROTO_RC6_6A_32: + if ((scancode & 0xffff0000) == 0x800f0000) + return false; + break; + default: + break; + } + + return true; +} + /** * rc_validate_filter() - checks that the scancode and mask are valid and * provides sensible defaults @@ -794,26 +825,8 @@ static int rc_validate_filter(struct rc_dev *dev, mask = protocols[protocol].scancode_bits; - switch (protocol) { - case RC_PROTO_NECX: - if ((((s >> 16) ^ ~(s >> 8)) & 0xff) == 0) - return -EINVAL; - break; - case RC_PROTO_NEC32: - if ((((s >> 24) ^ ~(s >> 16)) & 0xff) == 0) - return -EINVAL; - break; - case RC_PROTO_RC6_MCE: - if ((s & 0xffff0000) != 0x800f0000) - return -EINVAL; - break; - case RC_PROTO_RC6_6A_32: - if ((s & 0xffff0000) == 0x800f0000) - return -EINVAL; - break; - default: - break; - } + if (!rc_validate_scancode(protocol, s)) + return -EINVAL; filter->data &= mask; filter->mask &= mask; -- GitLab From 6b514c4a50cbbb9bd2080a95ed83d834b11f1e40 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Mon, 9 Oct 2017 16:32:41 -0400 Subject: [PATCH 0202/1190] media: rc: document and fix rc_validate_scancode() For some IR protocols, some scancode values not valid, i.e. they're part of a different protocol variant. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/rc-main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index ce8837b1facd6..e944d28b96d2b 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -776,21 +776,35 @@ void rc_keydown_notimeout(struct rc_dev *dev, enum rc_proto protocol, EXPORT_SYMBOL_GPL(rc_keydown_notimeout); /** - * rc_validate_scancode() - checks that a scancode is valid for a protocol + * rc_validate_scancode() - checks that a scancode is valid for a protocol. + * For nec, it should do the opposite of ir_nec_bytes_to_scancode() * @proto: protocol * @scancode: scancode */ bool rc_validate_scancode(enum rc_proto proto, u32 scancode) { switch (proto) { + /* + * NECX has a 16-bit address; if the lower 8 bits match the upper + * 8 bits inverted, then the address would match regular nec. + */ case RC_PROTO_NECX: if ((((scancode >> 16) ^ ~(scancode >> 8)) & 0xff) == 0) return false; break; + /* + * NEC32 has a 16 bit address and 16 bit command. If the lower 8 bits + * of the command match the upper 8 bits inverted, then it would + * be either NEC or NECX. + */ case RC_PROTO_NEC32: - if ((((scancode >> 24) ^ ~(scancode >> 16)) & 0xff) == 0) + if ((((scancode >> 8) ^ ~scancode) & 0xff) == 0) return false; break; + /* + * If the customer code (top 32-bit) is 0x800f, it is MCE else it + * is regular mode-6a 32 bit + */ case RC_PROTO_RC6_MCE: if ((scancode & 0xffff0000) != 0x800f0000) return false; -- GitLab From 95bc71e199e50487054adfd8222c5105deddbbd9 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 12:05:59 -0400 Subject: [PATCH 0203/1190] media: lirc: merge lirc_dev_fop_ioctl and ir_lirc_ioctl Calculate lirc features when necessary, and add LIRC_{S,G}ET_REC_MODE cases to ir_lirc_ioctl. This makes lirc_dev_fop_ioctl() unnecessary since all cases are already handled by ir_lirc_ioctl(). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 79 +++++++++++++++++++------------- drivers/media/rc/lirc_dev.c | 62 ++----------------------- include/media/lirc_dev.h | 4 -- 3 files changed, 50 insertions(+), 95 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 1ed69c9e64bf1..f933e76178829 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -231,8 +231,54 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, } switch (cmd) { + case LIRC_GET_FEATURES: + if (dev->driver_type == RC_DRIVER_IR_RAW) { + val |= LIRC_CAN_REC_MODE2; + if (dev->rx_resolution) + val |= LIRC_CAN_GET_REC_RESOLUTION; + } + + if (dev->tx_ir) { + val |= LIRC_CAN_SEND_PULSE | LIRC_CAN_SEND_SCANCODE; + if (dev->s_tx_mask) + val |= LIRC_CAN_SET_TRANSMITTER_MASK; + if (dev->s_tx_carrier) + val |= LIRC_CAN_SET_SEND_CARRIER; + if (dev->s_tx_duty_cycle) + val |= LIRC_CAN_SET_SEND_DUTY_CYCLE; + } + + if (dev->s_rx_carrier_range) + val |= LIRC_CAN_SET_REC_CARRIER | + LIRC_CAN_SET_REC_CARRIER_RANGE; + + if (dev->s_learning_mode) + val |= LIRC_CAN_USE_WIDEBAND_RECEIVER; + + if (dev->s_carrier_report) + val |= LIRC_CAN_MEASURE_CARRIER; + + if (dev->max_timeout) + val |= LIRC_CAN_SET_REC_TIMEOUT; + + break; /* mode support */ + case LIRC_GET_REC_MODE: + if (dev->driver_type == RC_DRIVER_IR_RAW_TX) + return -ENOTTY; + + val = LIRC_MODE_MODE2; + break; + + case LIRC_SET_REC_MODE: + if (dev->driver_type == RC_DRIVER_IR_RAW_TX) + return -ENOTTY; + + if (val != LIRC_MODE_MODE2) + return -EINVAL; + return 0; + case LIRC_GET_SEND_MODE: if (!dev->tx_ir) return -ENOTTY; @@ -353,7 +399,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, break; default: - return lirc_dev_fop_ioctl(filep, cmd, arg); + return -ENOTTY; } if (_IOC_DIR(cmd) & _IOC_READ) @@ -380,44 +426,13 @@ int ir_lirc_register(struct rc_dev *dev) { struct lirc_dev *ldev; int rc = -ENOMEM; - unsigned long features = 0; ldev = lirc_allocate_device(); if (!ldev) return rc; - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { - features |= LIRC_CAN_REC_MODE2; - if (dev->rx_resolution) - features |= LIRC_CAN_GET_REC_RESOLUTION; - } - - if (dev->tx_ir) { - features |= LIRC_CAN_SEND_PULSE | LIRC_CAN_SEND_SCANCODE; - if (dev->s_tx_mask) - features |= LIRC_CAN_SET_TRANSMITTER_MASK; - if (dev->s_tx_carrier) - features |= LIRC_CAN_SET_SEND_CARRIER; - if (dev->s_tx_duty_cycle) - features |= LIRC_CAN_SET_SEND_DUTY_CYCLE; - } - - if (dev->s_rx_carrier_range) - features |= LIRC_CAN_SET_REC_CARRIER | - LIRC_CAN_SET_REC_CARRIER_RANGE; - - if (dev->s_learning_mode) - features |= LIRC_CAN_USE_WIDEBAND_RECEIVER; - - if (dev->s_carrier_report) - features |= LIRC_CAN_MEASURE_CARRIER; - - if (dev->max_timeout) - features |= LIRC_CAN_SET_REC_TIMEOUT; - snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", dev->driver_name); - ldev->features = features; ldev->buf = NULL; ldev->chunk_size = sizeof(int); ldev->buffer_size = LIRCBUF_SIZE; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 3cc95deaa84ea..95058ea01e62a 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -109,6 +109,7 @@ EXPORT_SYMBOL(lirc_free_device); int lirc_register_device(struct lirc_dev *d) { + struct rc_dev *rcdev = d->rdev; int minor; int err; @@ -146,7 +147,7 @@ int lirc_register_device(struct lirc_dev *d) /* some safety check 8-) */ d->name[sizeof(d->name) - 1] = '\0'; - if (LIRC_CAN_REC(d->features)) { + if (rcdev->driver_type == RC_DRIVER_IR_RAW) { err = lirc_allocate_buffer(d); if (err) return err; @@ -290,63 +291,6 @@ unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) } EXPORT_SYMBOL(lirc_dev_fop_poll); -long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; - __u32 mode; - int result; - - dev_dbg(&d->dev, LOGHEAD "ioctl called (0x%x)\n", - d->name, d->minor, cmd); - - result = mutex_lock_interruptible(&d->mutex); - if (result) - return result; - - if (!d->attached) { - result = -ENODEV; - goto out; - } - - switch (cmd) { - case LIRC_GET_FEATURES: - result = put_user(d->features, (__u32 __user *)arg); - break; - case LIRC_GET_REC_MODE: - if (!LIRC_CAN_REC(d->features)) { - result = -ENOTTY; - break; - } - - result = put_user(LIRC_REC2MODE - (d->features & LIRC_CAN_REC_MASK), - (__u32 __user *)arg); - break; - case LIRC_SET_REC_MODE: - if (!LIRC_CAN_REC(d->features)) { - result = -ENOTTY; - break; - } - - result = get_user(mode, (__u32 __user *)arg); - if (!result && !(LIRC_MODE2REC(mode) & d->features)) - result = -EINVAL; - /* - * FIXME: We should actually set the mode somehow but - * for now, lirc_serial doesn't support mode changing either - */ - break; - default: - result = -ENOTTY; - } - -out: - mutex_unlock(&d->mutex); - return result; -} -EXPORT_SYMBOL(lirc_dev_fop_ioctl); - ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length, @@ -375,7 +319,7 @@ ssize_t lirc_dev_fop_read(struct file *file, goto out_locked; } - if (!LIRC_CAN_REC(d->features)) { + if (rcdev->driver_type != RC_DRIVER_IR_RAW) { ret = -EINVAL; goto out_locked; } diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index dd0c078796e89..86a3cf7987750 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -115,8 +115,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @features: lirc compatible hardware features, like LIRC_MODE_RAW, - * LIRC_CAN\_\*, as defined at include/media/lirc.h. * @buffer_size: Number of FIFO buffers with @chunk_size size. * Only used if @rbuf is NULL. * @chunk_size: Size of each FIFO buffer. @@ -138,7 +136,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, struct lirc_dev { char name[40]; unsigned int minor; - __u32 features; unsigned int buffer_size; /* in chunks holding one code each */ unsigned int chunk_size; @@ -172,7 +169,6 @@ void lirc_unregister_device(struct lirc_dev *d); int lirc_dev_fop_open(struct inode *inode, struct file *file); int lirc_dev_fop_close(struct inode *inode, struct file *file); unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); -long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg); ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length, loff_t *ppos); #endif -- GitLab From 71695aff9fe036857596965635e2607cf561a230 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 14:44:18 -0400 Subject: [PATCH 0204/1190] media: lirc: use kfifo rather than lirc_buffer for raw IR Since the only mode lirc devices can handle is raw IR, handle this in a plain kfifo. Remove lirc_buffer since this is no longer needed. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 81 ++++++++++--- drivers/media/rc/lirc_dev.c | 199 +++---------------------------- include/media/lirc_dev.h | 109 ----------------- include/media/rc-core.h | 4 + 4 files changed, 87 insertions(+), 306 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index f933e76178829..2fa1f905a266d 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -66,8 +66,6 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) } else { if (dev->gap) { - int gap_sample; - dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), dev->gap_start)); @@ -76,9 +74,7 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) dev->gap_duration = min_t(u64, dev->gap_duration, LIRC_VALUE_MASK); - gap_sample = LIRC_SPACE(dev->gap_duration); - lirc_buffer_write(dev->lirc_dev->buf, - (unsigned char *)&gap_sample); + kfifo_put(&dev->rawir, LIRC_SPACE(dev->gap_duration)); dev->gap = false; } @@ -88,10 +84,8 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) TO_US(ev.duration), TO_STR(ev.pulse)); } - lirc_buffer_write(dev->lirc_dev->buf, - (unsigned char *) &sample); - - wake_up(&dev->lirc_dev->buf->wait_poll); + kfifo_put(&dev->rawir, sample); + wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); } static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, @@ -408,6 +402,68 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, return ret; } +static unsigned int ir_lirc_poll(struct file *file, + struct poll_table_struct *wait) +{ + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; + unsigned int events = 0; + + poll_wait(file, &rcdev->wait_poll, wait); + + if (!d->attached) + events = POLLHUP | POLLERR; + else if (rcdev->driver_type == RC_DRIVER_IR_RAW && + !kfifo_is_empty(&rcdev->rawir)) + events = POLLIN | POLLRDNORM; + + return events; +} + +static ssize_t ir_lirc_read(struct file *file, char __user *buffer, + size_t length, loff_t *ppos) +{ + struct rc_dev *rcdev = file->private_data; + struct lirc_dev *d = rcdev->lirc_dev; + unsigned int copied; + int ret; + + if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) + return -EINVAL; + + if (length < sizeof(unsigned int) || length % sizeof(unsigned int)) + return -EINVAL; + + if (!d->attached) + return -ENODEV; + + do { + if (kfifo_is_empty(&rcdev->rawir)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible(rcdev->wait_poll, + !kfifo_is_empty(&rcdev->rawir) || + !d->attached); + if (ret) + return ret; + } + + if (!d->attached) + return -ENODEV; + + ret = mutex_lock_interruptible(&rcdev->lock); + if (ret) + return ret; + ret = kfifo_to_user(&rcdev->rawir, buffer, length, &copied); + mutex_unlock(&rcdev->lock); + if (ret) + return ret; + } while (copied == 0); + + return copied; +} + static const struct file_operations lirc_fops = { .owner = THIS_MODULE, .write = ir_lirc_transmit_ir, @@ -415,8 +471,8 @@ static const struct file_operations lirc_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = ir_lirc_ioctl, #endif - .read = lirc_dev_fop_read, - .poll = lirc_dev_fop_poll, + .read = ir_lirc_read, + .poll = ir_lirc_poll, .open = lirc_dev_fop_open, .release = lirc_dev_fop_close, .llseek = no_llseek, @@ -433,9 +489,6 @@ int ir_lirc_register(struct rc_dev *dev) snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", dev->driver_name); - ldev->buf = NULL; - ldev->chunk_size = sizeof(int); - ldev->buffer_size = LIRCBUF_SIZE; ldev->fops = &lirc_fops; ldev->dev.parent = &dev->dev; ldev->rdev = dev; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 95058ea01e62a..9a0ad8d9a0cbc 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -44,40 +44,14 @@ static struct class *lirc_class; static void lirc_release_device(struct device *ld) { struct lirc_dev *d = container_of(ld, struct lirc_dev, dev); + struct rc_dev *rcdev = d->rdev; - put_device(d->dev.parent); + if (rcdev->driver_type == RC_DRIVER_IR_RAW) + kfifo_free(&rcdev->rawir); - if (d->buf_internal) { - lirc_buffer_free(d->buf); - kfree(d->buf); - d->buf = NULL; - } kfree(d); module_put(THIS_MODULE); -} - -static int lirc_allocate_buffer(struct lirc_dev *d) -{ - int err; - - if (d->buf) { - d->buf_internal = false; - return 0; - } - - d->buf = kmalloc(sizeof(*d->buf), GFP_KERNEL); - if (!d->buf) - return -ENOMEM; - - err = lirc_buffer_init(d->buf, d->chunk_size, d->buffer_size); - if (err) { - kfree(d->buf); - d->buf = NULL; - return err; - } - - d->buf_internal = true; - return 0; + put_device(d->dev.parent); } struct lirc_dev * @@ -128,31 +102,16 @@ int lirc_register_device(struct lirc_dev *d) return -EINVAL; } - if (!d->buf && d->chunk_size < 1) { - pr_err("chunk_size must be set!\n"); - return -EINVAL; - } - - if (!d->buf && d->buffer_size < 1) { - pr_err("buffer_size must be set!\n"); - return -EINVAL; - } - - if (!d->buf && !(d->fops && d->fops->read && - d->fops->poll && d->fops->unlocked_ioctl)) { - dev_err(&d->dev, "undefined read, poll, ioctl\n"); - return -EBADRQC; - } - /* some safety check 8-) */ d->name[sizeof(d->name) - 1] = '\0'; if (rcdev->driver_type == RC_DRIVER_IR_RAW) { - err = lirc_allocate_buffer(d); - if (err) - return err; + if (kfifo_alloc(&rcdev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) + return -ENOMEM; } + init_waitqueue_head(&rcdev->wait_poll); + minor = ida_simple_get(&lirc_ida, 0, LIRC_MAX_DEVICES, GFP_KERNEL); if (minor < 0) return minor; @@ -182,9 +141,13 @@ EXPORT_SYMBOL(lirc_register_device); void lirc_unregister_device(struct lirc_dev *d) { + struct rc_dev *rcdev; + if (!d) return; + rcdev = d->rdev; + dev_dbg(&d->dev, "lirc_dev: driver %s unregistered from minor = %d\n", d->name, d->minor); @@ -194,7 +157,7 @@ void lirc_unregister_device(struct lirc_dev *d) if (d->open) { dev_dbg(&d->dev, LOGHEAD "releasing opened driver\n", d->name, d->minor); - wake_up_interruptible(&d->buf->wait_poll); + wake_up_poll(&rcdev->wait_poll, POLLHUP); } mutex_unlock(&d->mutex); @@ -208,6 +171,7 @@ EXPORT_SYMBOL(lirc_unregister_device); int lirc_dev_fop_open(struct inode *inode, struct file *file) { struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); + struct rc_dev *rcdev = d->rdev; int retval; dev_dbg(&d->dev, LOGHEAD "open called\n", d->name, d->minor); @@ -232,8 +196,8 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) goto out; } - if (d->buf) - lirc_buffer_clear(d->buf); + if (rcdev->driver_type == RC_DRIVER_IR_RAW) + kfifo_reset_out(&rcdev->rawir); d->open++; @@ -265,137 +229,6 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file) } EXPORT_SYMBOL(lirc_dev_fop_close); -unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) -{ - struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; - unsigned int ret; - - if (!d->attached) - return POLLHUP | POLLERR; - - if (d->buf) { - poll_wait(file, &d->buf->wait_poll, wait); - - if (lirc_buffer_empty(d->buf)) - ret = 0; - else - ret = POLLIN | POLLRDNORM; - } else { - ret = POLLERR; - } - - dev_dbg(&d->dev, LOGHEAD "poll result = %d\n", d->name, d->minor, ret); - - return ret; -} -EXPORT_SYMBOL(lirc_dev_fop_poll); - -ssize_t lirc_dev_fop_read(struct file *file, - char __user *buffer, - size_t length, - loff_t *ppos) -{ - struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; - unsigned char *buf; - int ret, written = 0; - DECLARE_WAITQUEUE(wait, current); - - buf = kzalloc(d->buf->chunk_size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - dev_dbg(&d->dev, LOGHEAD "read called\n", d->name, d->minor); - - ret = mutex_lock_interruptible(&d->mutex); - if (ret) { - kfree(buf); - return ret; - } - - if (!d->attached) { - ret = -ENODEV; - goto out_locked; - } - - if (rcdev->driver_type != RC_DRIVER_IR_RAW) { - ret = -EINVAL; - goto out_locked; - } - - if (length % d->buf->chunk_size) { - ret = -EINVAL; - goto out_locked; - } - - /* - * we add ourselves to the task queue before buffer check - * to avoid losing scan code (in case when queue is awaken somewhere - * between while condition checking and scheduling) - */ - add_wait_queue(&d->buf->wait_poll, &wait); - - /* - * while we didn't provide 'length' bytes, device is opened in blocking - * mode and 'copy_to_user' is happy, wait for data. - */ - while (written < length && ret == 0) { - if (lirc_buffer_empty(d->buf)) { - /* According to the read(2) man page, 'written' can be - * returned as less than 'length', instead of blocking - * again, returning -EWOULDBLOCK, or returning - * -ERESTARTSYS - */ - if (written) - break; - if (file->f_flags & O_NONBLOCK) { - ret = -EWOULDBLOCK; - break; - } - if (signal_pending(current)) { - ret = -ERESTARTSYS; - break; - } - - mutex_unlock(&d->mutex); - set_current_state(TASK_INTERRUPTIBLE); - schedule(); - set_current_state(TASK_RUNNING); - - ret = mutex_lock_interruptible(&d->mutex); - if (ret) { - remove_wait_queue(&d->buf->wait_poll, &wait); - goto out_unlocked; - } - - if (!d->attached) { - ret = -ENODEV; - goto out_locked; - } - } else { - lirc_buffer_read(d->buf, buf); - ret = copy_to_user((void __user *)buffer+written, buf, - d->buf->chunk_size); - if (!ret) - written += d->buf->chunk_size; - else - ret = -EFAULT; - } - } - - remove_wait_queue(&d->buf->wait_poll, &wait); - -out_locked: - mutex_unlock(&d->mutex); - -out_unlocked: - kfree(buf); - - return ret ? ret : written; -} -EXPORT_SYMBOL(lirc_dev_fop_read); - int __init lirc_dev_init(void) { int retval; diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 86a3cf7987750..14d3eb36672e3 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -18,112 +18,11 @@ #include #include -struct lirc_buffer { - wait_queue_head_t wait_poll; - spinlock_t fifo_lock; - unsigned int chunk_size; - unsigned int size; /* in chunks */ - /* Using chunks instead of bytes pretends to simplify boundary checking - * And should allow for some performance fine tunning later */ - struct kfifo fifo; -}; - -static inline void lirc_buffer_clear(struct lirc_buffer *buf) -{ - unsigned long flags; - - if (kfifo_initialized(&buf->fifo)) { - spin_lock_irqsave(&buf->fifo_lock, flags); - kfifo_reset(&buf->fifo); - spin_unlock_irqrestore(&buf->fifo_lock, flags); - } else - WARN(1, "calling %s on an uninitialized lirc_buffer\n", - __func__); -} - -static inline int lirc_buffer_init(struct lirc_buffer *buf, - unsigned int chunk_size, - unsigned int size) -{ - int ret; - - init_waitqueue_head(&buf->wait_poll); - spin_lock_init(&buf->fifo_lock); - buf->chunk_size = chunk_size; - buf->size = size; - ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL); - - return ret; -} - -static inline void lirc_buffer_free(struct lirc_buffer *buf) -{ - if (kfifo_initialized(&buf->fifo)) { - kfifo_free(&buf->fifo); - } else - WARN(1, "calling %s on an uninitialized lirc_buffer\n", - __func__); -} - -static inline int lirc_buffer_len(struct lirc_buffer *buf) -{ - int len; - unsigned long flags; - - spin_lock_irqsave(&buf->fifo_lock, flags); - len = kfifo_len(&buf->fifo); - spin_unlock_irqrestore(&buf->fifo_lock, flags); - - return len; -} - -static inline int lirc_buffer_full(struct lirc_buffer *buf) -{ - return lirc_buffer_len(buf) == buf->size * buf->chunk_size; -} - -static inline int lirc_buffer_empty(struct lirc_buffer *buf) -{ - return !lirc_buffer_len(buf); -} - -static inline unsigned int lirc_buffer_read(struct lirc_buffer *buf, - unsigned char *dest) -{ - unsigned int ret = 0; - - if (lirc_buffer_len(buf) >= buf->chunk_size) - ret = kfifo_out_locked(&buf->fifo, dest, buf->chunk_size, - &buf->fifo_lock); - return ret; - -} - -static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, - unsigned char *orig) -{ - unsigned int ret; - - ret = kfifo_in_locked(&buf->fifo, orig, buf->chunk_size, - &buf->fifo_lock); - - return ret; -} - /** * struct lirc_dev - represents a LIRC device * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @buffer_size: Number of FIFO buffers with @chunk_size size. - * Only used if @rbuf is NULL. - * @chunk_size: Size of each FIFO buffer. - * Only used if @rbuf is NULL. - * @buf: if %NULL, lirc_dev will allocate and manage the buffer, - * otherwise allocated by the caller which will - * have to write to the buffer by other means, like irq's - * (see also lirc_serial.c). - * @buf_internal: whether lirc_dev has allocated the read buffer or not * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct @@ -137,11 +36,6 @@ struct lirc_dev { char name[40]; unsigned int minor; - unsigned int buffer_size; /* in chunks holding one code each */ - unsigned int chunk_size; - struct lirc_buffer *buf; - bool buf_internal; - struct rc_dev *rdev; const struct file_operations *fops; struct module *owner; @@ -168,7 +62,4 @@ void lirc_unregister_device(struct lirc_dev *d); */ int lirc_dev_fop_open(struct inode *inode, struct file *file); int lirc_dev_fop_close(struct inode *inode, struct file *file); -unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); -ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length, - loff_t *ppos); #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 5d6e415c7acc2..fb91666bf8815 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -123,6 +123,8 @@ enum rc_filter_type { * @gap_duration: duration of initial gap * @gap: true if we're in a gap * @send_timeout_reports: report timeouts in lirc raw IR. + * @rawir: queue for incoming raw IR + * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE * @change_protocol: allow changing the protocol used on hardware decoders @@ -191,6 +193,8 @@ struct rc_dev { u64 gap_duration; bool gap; bool send_timeout_reports; + DECLARE_KFIFO_PTR(rawir, unsigned int); + wait_queue_head_t wait_poll; u8 send_mode; #endif int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- GitLab From 7790e81f7e1f7f122f8fcccd91443a2571421aba Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:31:29 -0400 Subject: [PATCH 0205/1190] media: lirc: move lirc_dev->attached to rc_dev->registered This is done to further remove the lirc kernel api. Ensure that every fops checks for this. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 16 ++++++++++------ drivers/media/rc/lirc_dev.c | 4 +--- drivers/media/rc/rc-main.c | 10 ++++++++++ include/media/lirc_dev.h | 2 -- include/media/rc-core.h | 3 +++ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 2fa1f905a266d..ff74a5d7a0f34 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -101,6 +101,9 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, unsigned int duration = 0; /* signal duration in us */ int i; + if (!dev->registered) + return -ENODEV; + start = ktime_get(); if (!dev->tx_ir) { @@ -224,6 +227,9 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, return ret; } + if (!dev->registered) + return -ENODEV; + switch (cmd) { case LIRC_GET_FEATURES: if (dev->driver_type == RC_DRIVER_IR_RAW) { @@ -406,12 +412,11 @@ static unsigned int ir_lirc_poll(struct file *file, struct poll_table_struct *wait) { struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; unsigned int events = 0; poll_wait(file, &rcdev->wait_poll, wait); - if (!d->attached) + if (!rcdev->registered) events = POLLHUP | POLLERR; else if (rcdev->driver_type == RC_DRIVER_IR_RAW && !kfifo_is_empty(&rcdev->rawir)) @@ -424,7 +429,6 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, size_t length, loff_t *ppos) { struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; unsigned int copied; int ret; @@ -434,7 +438,7 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, if (length < sizeof(unsigned int) || length % sizeof(unsigned int)) return -EINVAL; - if (!d->attached) + if (!rcdev->registered) return -ENODEV; do { @@ -444,12 +448,12 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, ret = wait_event_interruptible(rcdev->wait_poll, !kfifo_is_empty(&rcdev->rawir) || - !d->attached); + !rcdev->registered); if (ret) return ret; } - if (!d->attached) + if (!rcdev->registered) return -ENODEV; ret = mutex_lock_interruptible(&rcdev->lock); diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 9a0ad8d9a0cbc..22171267aa901 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -122,7 +122,6 @@ int lirc_register_device(struct lirc_dev *d) cdev_init(&d->cdev, d->fops); d->cdev.owner = d->owner; - d->attached = true; err = cdev_device_add(&d->cdev, &d->dev); if (err) { @@ -153,7 +152,6 @@ void lirc_unregister_device(struct lirc_dev *d) mutex_lock(&d->mutex); - d->attached = false; if (d->open) { dev_dbg(&d->dev, LOGHEAD "releasing opened driver\n", d->name, d->minor); @@ -180,7 +178,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) if (retval) return retval; - if (!d->attached) { + if (!rcdev->registered) { retval = -ENODEV; goto out; } diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index e944d28b96d2b..8b1b20e7a3c31 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1809,6 +1809,8 @@ int rc_register_device(struct rc_dev *dev) goto out_lirc; } + dev->registered = true; + IR_dprintk(1, "Registered rc%u (driver: %s)\n", dev->minor, dev->driver_name ? dev->driver_name : "unknown"); @@ -1871,6 +1873,14 @@ void rc_unregister_device(struct rc_dev *dev) rc_free_rx_device(dev); + mutex_lock(&dev->lock); + dev->registered = false; + mutex_unlock(&dev->lock); + + /* + * lirc device should be freed with dev->registered = false, so + * that userspace polling will get notified. + */ if (dev->driver_type != RC_DRIVER_SCANCODE) ir_lirc_unregister(dev); diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 14d3eb36672e3..5782add67edda 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -26,7 +26,6 @@ * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct - * @attached: if the device is still live * @open: open count for the device's chardev * @mutex: serialises file_operations calls * @dev: &struct device assigned to the device @@ -40,7 +39,6 @@ struct lirc_dev { const struct file_operations *fops; struct module *owner; - bool attached; int open; struct mutex mutex; /* protect from simultaneous accesses */ diff --git a/include/media/rc-core.h b/include/media/rc-core.h index fb91666bf8815..b6d719734744c 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -127,6 +127,8 @@ enum rc_filter_type { * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE + * @registered: set to true by rc_register_device(), false by + * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device * is opened. @@ -197,6 +199,7 @@ struct rc_dev { wait_queue_head_t wait_poll; u8 send_mode; #endif + bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); int (*open)(struct rc_dev *dev); void (*close)(struct rc_dev *dev); -- GitLab From cb84343fced1febb5b21a9ef9082a07bfc3e7427 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 17:44:03 -0400 Subject: [PATCH 0206/1190] media: lirc: do not call close() or open() on unregistered devices If a lirc chardev is held open after a device is unplugged, rc_close() will be called after rc_unregister_device(). The driver is not expecting any calls at this point, and the iguanair driver causes an oops in this scenario. rc_open() can be called when the device is removed too, by calling open on the chardev whilst the device is being removed. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/rc-main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 8b1b20e7a3c31..ace00e77c96ad 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -863,11 +863,15 @@ int rc_open(struct rc_dev *rdev) mutex_lock(&rdev->lock); - if (!rdev->users++ && rdev->open != NULL) - rval = rdev->open(rdev); + if (!rdev->registered) { + rval = -ENODEV; + } else { + if (!rdev->users++ && rdev->open) + rval = rdev->open(rdev); - if (rval) - rdev->users--; + if (rval) + rdev->users--; + } mutex_unlock(&rdev->lock); @@ -886,7 +890,7 @@ void rc_close(struct rc_dev *rdev) if (rdev) { mutex_lock(&rdev->lock); - if (!--rdev->users && rdev->close != NULL) + if (!--rdev->users && rdev->close && rdev->registered) rdev->close(rdev); mutex_unlock(&rdev->lock); -- GitLab From 111429fb73b1f5f584d977614b87ce9e6f8361c6 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:44:20 -0400 Subject: [PATCH 0207/1190] media: lirc: create rc-core open and close lirc functions Replace the generic kernel lirc api with ones which use rc-core, further reducing the lirc_dev members. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 59 ++++++++++++++++++++++++++- drivers/media/rc/lirc_dev.c | 68 ++------------------------------ include/media/lirc_dev.h | 11 ------ include/media/rc-core.h | 2 + 4 files changed, 62 insertions(+), 78 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index ff74a5d7a0f34..1e921e4f8839a 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -88,6 +88,61 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); } +static int ir_lirc_open(struct inode *inode, struct file *file) +{ + struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); + struct rc_dev *dev = d->rdev; + int retval; + + retval = rc_open(dev); + if (retval) + return retval; + + retval = mutex_lock_interruptible(&dev->lock); + if (retval) + goto out_rc; + + if (!dev->registered) { + retval = -ENODEV; + goto out_unlock; + } + + if (dev->lirc_open) { + retval = -EBUSY; + goto out_unlock; + } + + if (dev->driver_type == RC_DRIVER_IR_RAW) + kfifo_reset_out(&dev->rawir); + + dev->lirc_open++; + file->private_data = dev; + + nonseekable_open(inode, file); + mutex_unlock(&dev->lock); + + return 0; + +out_unlock: + mutex_unlock(&dev->lock); +out_rc: + rc_close(dev); + return retval; +} + +static int ir_lirc_close(struct inode *inode, struct file *file) +{ + struct rc_dev *dev = file->private_data; + + mutex_lock(&dev->lock); + dev->lirc_open--; + mutex_unlock(&dev->lock); + + rc_close(dev); + + return 0; +} + static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, size_t n, loff_t *ppos) { @@ -477,8 +532,8 @@ static const struct file_operations lirc_fops = { #endif .read = ir_lirc_read, .poll = ir_lirc_poll, - .open = lirc_dev_fop_open, - .release = lirc_dev_fop_close, + .open = ir_lirc_open, + .release = ir_lirc_close, .llseek = no_llseek, }; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 22171267aa901..32124fb5c88e7 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -61,7 +61,6 @@ lirc_allocate_device(void) d = kzalloc(sizeof(*d), GFP_KERNEL); if (d) { - mutex_init(&d->mutex); device_initialize(&d->dev); d->dev.class = lirc_class; d->dev.release = lirc_release_device; @@ -150,15 +149,15 @@ void lirc_unregister_device(struct lirc_dev *d) dev_dbg(&d->dev, "lirc_dev: driver %s unregistered from minor = %d\n", d->name, d->minor); - mutex_lock(&d->mutex); + mutex_lock(&rcdev->lock); - if (d->open) { + if (rcdev->lirc_open) { dev_dbg(&d->dev, LOGHEAD "releasing opened driver\n", d->name, d->minor); wake_up_poll(&rcdev->wait_poll, POLLHUP); } - mutex_unlock(&d->mutex); + mutex_unlock(&rcdev->lock); cdev_device_del(&d->cdev, &d->dev); ida_simple_remove(&lirc_ida, d->minor); @@ -166,67 +165,6 @@ void lirc_unregister_device(struct lirc_dev *d) } EXPORT_SYMBOL(lirc_unregister_device); -int lirc_dev_fop_open(struct inode *inode, struct file *file) -{ - struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); - struct rc_dev *rcdev = d->rdev; - int retval; - - dev_dbg(&d->dev, LOGHEAD "open called\n", d->name, d->minor); - - retval = mutex_lock_interruptible(&d->mutex); - if (retval) - return retval; - - if (!rcdev->registered) { - retval = -ENODEV; - goto out; - } - - if (d->open) { - retval = -EBUSY; - goto out; - } - - if (d->rdev) { - retval = rc_open(d->rdev); - if (retval) - goto out; - } - - if (rcdev->driver_type == RC_DRIVER_IR_RAW) - kfifo_reset_out(&rcdev->rawir); - - d->open++; - - file->private_data = d->rdev; - nonseekable_open(inode, file); - mutex_unlock(&d->mutex); - - return 0; - -out: - mutex_unlock(&d->mutex); - return retval; -} -EXPORT_SYMBOL(lirc_dev_fop_open); - -int lirc_dev_fop_close(struct inode *inode, struct file *file) -{ - struct rc_dev *rcdev = file->private_data; - struct lirc_dev *d = rcdev->lirc_dev; - - mutex_lock(&d->mutex); - - rc_close(rcdev); - d->open--; - - mutex_unlock(&d->mutex); - - return 0; -} -EXPORT_SYMBOL(lirc_dev_fop_close); - int __init lirc_dev_init(void) { int retval; diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 5782add67edda..b45af81b46332 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -26,8 +26,6 @@ * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct - * @open: open count for the device's chardev - * @mutex: serialises file_operations calls * @dev: &struct device assigned to the device * @cdev: &struct cdev assigned to the device */ @@ -39,10 +37,6 @@ struct lirc_dev { const struct file_operations *fops; struct module *owner; - int open; - - struct mutex mutex; /* protect from simultaneous accesses */ - struct device dev; struct cdev cdev; }; @@ -55,9 +49,4 @@ int lirc_register_device(struct lirc_dev *d); void lirc_unregister_device(struct lirc_dev *d); -/* default file operations - * used by drivers if they override only some operations - */ -int lirc_dev_fop_open(struct inode *inode, struct file *file); -int lirc_dev_fop_close(struct inode *inode, struct file *file); #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index b6d719734744c..4f585bff1347b 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -117,6 +117,7 @@ enum rc_filter_type { * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler * @lirc_dev: lirc char device + * @lirc_open: count of the number of times the device has been opened * @carrier_low: when setting the carrier range, first the low end must be * set with an ioctl and then the high end with another ioctl * @gap_start: time when gap starts @@ -190,6 +191,7 @@ struct rc_dev { u32 tx_resolution; #ifdef CONFIG_LIRC struct lirc_dev *lirc_dev; + int lirc_open; int carrier_low; ktime_t gap_start; u64 gap_duration; -- GitLab From bf01c82474bf1f5c07d90a0959a95ff51374cc6f Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:56:39 -0400 Subject: [PATCH 0208/1190] media: lirc: remove name from lirc_dev This is a duplicate of rcdev->driver_name. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/uapi/rc/lirc-dev-intro.rst | 2 +- drivers/media/rc/ir-lirc-codec.c | 2 -- drivers/media/rc/lirc_dev.c | 9 +++------ include/media/lirc_dev.h | 2 -- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Documentation/media/uapi/rc/lirc-dev-intro.rst b/Documentation/media/uapi/rc/lirc-dev-intro.rst index 3cacf9aeac409..a3fa3c1ef1693 100644 --- a/Documentation/media/uapi/rc/lirc-dev-intro.rst +++ b/Documentation/media/uapi/rc/lirc-dev-intro.rst @@ -18,7 +18,7 @@ Example dmesg output upon a driver registering w/LIRC: $ dmesg |grep lirc_dev lirc_dev: IR Remote Control driver registered, major 248 - rc rc0: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 0 + rc rc0: lirc_dev: driver mceusb registered at minor = 0 What you should see for a chardev: diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 1e921e4f8839a..6435306f385bd 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -546,8 +546,6 @@ int ir_lirc_register(struct rc_dev *dev) if (!ldev) return rc; - snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", - dev->driver_name); ldev->fops = &lirc_fops; ldev->dev.parent = &dev->dev; ldev->rdev = dev; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 32124fb5c88e7..4ac74fd86fd4e 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -101,9 +101,6 @@ int lirc_register_device(struct lirc_dev *d) return -EINVAL; } - /* some safety check 8-) */ - d->name[sizeof(d->name) - 1] = '\0'; - if (rcdev->driver_type == RC_DRIVER_IR_RAW) { if (kfifo_alloc(&rcdev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) return -ENOMEM; @@ -131,7 +128,7 @@ int lirc_register_device(struct lirc_dev *d) get_device(d->dev.parent); dev_info(&d->dev, "lirc_dev: driver %s registered at minor = %d\n", - d->name, d->minor); + rcdev->driver_name, d->minor); return 0; } @@ -147,13 +144,13 @@ void lirc_unregister_device(struct lirc_dev *d) rcdev = d->rdev; dev_dbg(&d->dev, "lirc_dev: driver %s unregistered from minor = %d\n", - d->name, d->minor); + rcdev->driver_name, d->minor); mutex_lock(&rcdev->lock); if (rcdev->lirc_open) { dev_dbg(&d->dev, LOGHEAD "releasing opened driver\n", - d->name, d->minor); + rcdev->driver_name, d->minor); wake_up_poll(&rcdev->wait_poll, POLLHUP); } diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index b45af81b46332..d12e1d1c3d67b 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -21,7 +21,6 @@ /** * struct lirc_dev - represents a LIRC device * - * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device @@ -30,7 +29,6 @@ * @cdev: &struct cdev assigned to the device */ struct lirc_dev { - char name[40]; unsigned int minor; struct rc_dev *rdev; -- GitLab From a6ddd4fecbb02d8ec5a865621bd2b746d585a01c Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 09:34:47 -0400 Subject: [PATCH 0209/1190] media: lirc: remove last remnants of lirc kapi rc-core has replaced the lirc kapi many years ago, and now with the last driver ported to rc-core, we can finally remove it. Note this has no effect on userspace. All future IR drivers should use the rc-core api. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/kapi/rc-core.rst | 5 - drivers/media/rc/ir-lirc-codec.c | 41 +------- drivers/media/rc/lirc_dev.c | 145 +++++++++------------------ drivers/media/rc/rc-core-priv.h | 3 + drivers/media/rc/rc-main.c | 1 - include/media/lirc_dev.h | 50 --------- include/media/rc-core.h | 8 +- 7 files changed, 60 insertions(+), 193 deletions(-) delete mode 100644 include/media/lirc_dev.h diff --git a/Documentation/media/kapi/rc-core.rst b/Documentation/media/kapi/rc-core.rst index a458958862573..41c2256dbf6ae 100644 --- a/Documentation/media/kapi/rc-core.rst +++ b/Documentation/media/kapi/rc-core.rst @@ -7,8 +7,3 @@ Remote Controller core .. kernel-doc:: include/media/rc-core.h .. kernel-doc:: include/media/rc-map.h - -LIRC -~~~~ - -.. kernel-doc:: include/media/lirc_dev.h diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 6435306f385bd..52daac9bc4704 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -12,10 +12,10 @@ * GNU General Public License for more details. */ +#include #include #include #include -#include #include #include "rc-core-priv.h" @@ -90,8 +90,8 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) static int ir_lirc_open(struct inode *inode, struct file *file) { - struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); - struct rc_dev *dev = d->rdev; + struct rc_dev *dev = container_of(inode->i_cdev, struct rc_dev, + lirc_cdev); int retval; retval = rc_open(dev); @@ -523,7 +523,7 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, return copied; } -static const struct file_operations lirc_fops = { +const struct file_operations lirc_fops = { .owner = THIS_MODULE, .write = ir_lirc_transmit_ir, .unlocked_ioctl = ir_lirc_ioctl, @@ -536,36 +536,3 @@ static const struct file_operations lirc_fops = { .release = ir_lirc_close, .llseek = no_llseek, }; - -int ir_lirc_register(struct rc_dev *dev) -{ - struct lirc_dev *ldev; - int rc = -ENOMEM; - - ldev = lirc_allocate_device(); - if (!ldev) - return rc; - - ldev->fops = &lirc_fops; - ldev->dev.parent = &dev->dev; - ldev->rdev = dev; - ldev->owner = THIS_MODULE; - - rc = lirc_register_device(ldev); - if (rc < 0) - goto out; - - dev->send_mode = LIRC_MODE_PULSE; - dev->lirc_dev = ldev; - return 0; - -out: - lirc_free_device(ldev); - return rc; -} - -void ir_lirc_unregister(struct rc_dev *dev) -{ - lirc_unregister_device(dev->lirc_dev); - dev->lirc_dev = NULL; -} diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 4ac74fd86fd4e..155a4de249a07 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -18,24 +18,19 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include -#include -#include #include #include -#include #include +#include #include "rc-core-priv.h" #include -#include #define LOGHEAD "lirc_dev (%s[%d]): " static dev_t lirc_base_dev; /* Used to keep track of allocated lirc devices */ -#define LIRC_MAX_DEVICES 256 static DEFINE_IDA(lirc_ida); /* Only used for sysfs but defined to void otherwise */ @@ -43,124 +38,80 @@ static struct class *lirc_class; static void lirc_release_device(struct device *ld) { - struct lirc_dev *d = container_of(ld, struct lirc_dev, dev); - struct rc_dev *rcdev = d->rdev; + struct rc_dev *rcdev = container_of(ld, struct rc_dev, lirc_dev); if (rcdev->driver_type == RC_DRIVER_IR_RAW) kfifo_free(&rcdev->rawir); - kfree(d); - module_put(THIS_MODULE); - put_device(d->dev.parent); -} - -struct lirc_dev * -lirc_allocate_device(void) -{ - struct lirc_dev *d; - - d = kzalloc(sizeof(*d), GFP_KERNEL); - if (d) { - device_initialize(&d->dev); - d->dev.class = lirc_class; - d->dev.release = lirc_release_device; - __module_get(THIS_MODULE); - } - - return d; -} -EXPORT_SYMBOL(lirc_allocate_device); - -void lirc_free_device(struct lirc_dev *d) -{ - if (!d) - return; - - put_device(&d->dev); + put_device(&rcdev->dev); } -EXPORT_SYMBOL(lirc_free_device); -int lirc_register_device(struct lirc_dev *d) +int ir_lirc_register(struct rc_dev *dev) { - struct rc_dev *rcdev = d->rdev; - int minor; - int err; + int err, minor; - if (!d) { - pr_err("driver pointer must be not NULL!\n"); - return -EBADRQC; - } + device_initialize(&dev->lirc_dev); + dev->lirc_dev.class = lirc_class; + dev->lirc_dev.release = lirc_release_device; + dev->send_mode = LIRC_MODE_PULSE; - if (!d->dev.parent) { - pr_err("dev parent pointer not filled in!\n"); - return -EINVAL; + if (dev->driver_type == RC_DRIVER_IR_RAW) { + if (kfifo_alloc(&dev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) + return -ENOMEM; } - if (!d->fops) { - pr_err("fops pointer not filled in!\n"); - return -EINVAL; - } + init_waitqueue_head(&dev->wait_poll); - if (rcdev->driver_type == RC_DRIVER_IR_RAW) { - if (kfifo_alloc(&rcdev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) - return -ENOMEM; + minor = ida_simple_get(&lirc_ida, 0, RC_DEV_MAX, GFP_KERNEL); + if (minor < 0) { + err = minor; + goto out_kfifo; } - init_waitqueue_head(&rcdev->wait_poll); - - minor = ida_simple_get(&lirc_ida, 0, LIRC_MAX_DEVICES, GFP_KERNEL); - if (minor < 0) - return minor; + dev->lirc_dev.parent = &dev->dev; + dev->lirc_dev.devt = MKDEV(MAJOR(lirc_base_dev), minor); + dev_set_name(&dev->lirc_dev, "lirc%d", minor); - d->minor = minor; - d->dev.devt = MKDEV(MAJOR(lirc_base_dev), d->minor); - dev_set_name(&d->dev, "lirc%d", d->minor); + cdev_init(&dev->lirc_cdev, &lirc_fops); - cdev_init(&d->cdev, d->fops); - d->cdev.owner = d->owner; + err = cdev_device_add(&dev->lirc_cdev, &dev->lirc_dev); + if (err) + goto out_ida; - err = cdev_device_add(&d->cdev, &d->dev); - if (err) { - ida_simple_remove(&lirc_ida, minor); - return err; - } + get_device(&dev->dev); - get_device(d->dev.parent); - - dev_info(&d->dev, "lirc_dev: driver %s registered at minor = %d\n", - rcdev->driver_name, d->minor); + dev_info(&dev->dev, "lirc_dev: driver %s registered at minor = %d", + dev->driver_name, minor); return 0; + +out_ida: + ida_simple_remove(&lirc_ida, minor); +out_kfifo: + if (dev->driver_type == RC_DRIVER_IR_RAW) + kfifo_free(&dev->rawir); + return err; } -EXPORT_SYMBOL(lirc_register_device); -void lirc_unregister_device(struct lirc_dev *d) +void ir_lirc_unregister(struct rc_dev *dev) { - struct rc_dev *rcdev; - - if (!d) - return; - - rcdev = d->rdev; - - dev_dbg(&d->dev, "lirc_dev: driver %s unregistered from minor = %d\n", - rcdev->driver_name, d->minor); + dev_dbg(&dev->dev, "lirc_dev: driver %s unregistered from minor = %d\n", + dev->driver_name, MINOR(dev->lirc_dev.devt)); - mutex_lock(&rcdev->lock); + mutex_lock(&dev->lock); - if (rcdev->lirc_open) { - dev_dbg(&d->dev, LOGHEAD "releasing opened driver\n", - rcdev->driver_name, d->minor); - wake_up_poll(&rcdev->wait_poll, POLLHUP); + if (dev->lirc_open) { + dev_dbg(&dev->dev, LOGHEAD "releasing opened driver\n", + dev->driver_name, MINOR(dev->lirc_dev.devt)); + wake_up_poll(&dev->wait_poll, POLLHUP); } - mutex_unlock(&rcdev->lock); + mutex_unlock(&dev->lock); - cdev_device_del(&d->cdev, &d->dev); - ida_simple_remove(&lirc_ida, d->minor); - put_device(&d->dev); + cdev_device_del(&dev->lirc_cdev, &dev->lirc_dev); + ida_simple_remove(&lirc_ida, MINOR(dev->lirc_dev.devt)); + put_device(&dev->lirc_dev); } -EXPORT_SYMBOL(lirc_unregister_device); int __init lirc_dev_init(void) { @@ -172,7 +123,7 @@ int __init lirc_dev_init(void) return PTR_ERR(lirc_class); } - retval = alloc_chrdev_region(&lirc_base_dev, 0, LIRC_MAX_DEVICES, + retval = alloc_chrdev_region(&lirc_base_dev, 0, RC_DEV_MAX, "BaseRemoteCtl"); if (retval) { class_destroy(lirc_class); @@ -189,5 +140,5 @@ int __init lirc_dev_init(void) void __exit lirc_dev_exit(void) { class_destroy(lirc_class); - unregister_chrdev_region(lirc_base_dev, LIRC_MAX_DEVICES); + unregister_chrdev_region(lirc_base_dev, RC_DEV_MAX); } diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 6d5a36b8b550f..9af43d16ca292 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -6,6 +6,7 @@ #ifndef _RC_CORE_PRIV #define _RC_CORE_PRIV +#define RC_DEV_MAX 256 /* Define the max number of pulse/space transitions to buffer */ #define MAX_IR_EVENT_SIZE 512 @@ -277,6 +278,8 @@ void lirc_dev_exit(void); void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev); int ir_lirc_register(struct rc_dev *dev); void ir_lirc_unregister(struct rc_dev *dev); + +extern const struct file_operations lirc_fops; #else static inline int lirc_dev_init(void) { return 0; } static inline void lirc_dev_exit(void) {} diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index ace00e77c96ad..12ff6d87b113f 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -20,7 +20,6 @@ /* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */ #define IR_TAB_MIN_SIZE 256 #define IR_TAB_MAX_SIZE 8192 -#define RC_DEV_MAX 256 static const struct { const char *name; diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h deleted file mode 100644 index d12e1d1c3d67b..0000000000000 --- a/include/media/lirc_dev.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * LIRC base driver - * - * by Artur Lipowski - * This code is licensed under GNU GPL - * - */ - -#ifndef _LINUX_LIRC_DEV_H -#define _LINUX_LIRC_DEV_H - -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * struct lirc_dev - represents a LIRC device - * - * @minor: the minor device (/dev/lircX) number for the device - * @rdev: &struct rc_dev associated with the device - * @fops: &struct file_operations for the device - * @owner: the module owning this struct - * @dev: &struct device assigned to the device - * @cdev: &struct cdev assigned to the device - */ -struct lirc_dev { - unsigned int minor; - - struct rc_dev *rdev; - const struct file_operations *fops; - struct module *owner; - - struct device dev; - struct cdev cdev; -}; - -struct lirc_dev *lirc_allocate_device(void); - -void lirc_free_device(struct lirc_dev *d); - -int lirc_register_device(struct lirc_dev *d); - -void lirc_unregister_device(struct lirc_dev *d); - -#endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 4f585bff1347b..2d24c88652aad 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -17,10 +17,10 @@ #define _RC_CORE #include +#include #include #include #include -#include #include extern int rc_core_debug; @@ -116,7 +116,8 @@ enum rc_filter_type { * @max_timeout: maximum timeout supported by device * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler - * @lirc_dev: lirc char device + * @lirc_dev: lirc device + * @lirc_cdev: lirc char cdev * @lirc_open: count of the number of times the device has been opened * @carrier_low: when setting the carrier range, first the low end must be * set with an ioctl and then the high end with another ioctl @@ -190,7 +191,8 @@ struct rc_dev { u32 rx_resolution; u32 tx_resolution; #ifdef CONFIG_LIRC - struct lirc_dev *lirc_dev; + struct device lirc_dev; + struct cdev lirc_cdev; int lirc_open; int carrier_low; ktime_t gap_start; -- GitLab From de142c32410649e64d44928505ffad2176a96a9e Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:32 -0500 Subject: [PATCH 0210/1190] media: lirc: implement reading scancode This implements LIRC_MODE_SCANCODE reading from the lirc device. The scancode can be read from the input device too, but with this interface you get the rc protocol, keycode, toggle and repeat status in addition to just the scancode. int main() { int fd, mode, rc; fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode; while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) { printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n", scancode.rc_proto, scancode.scancode, !!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE), !!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT)); } close(fd); } Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 104 ++++++++++++++++++++++---- drivers/media/rc/ir-mce_kbd-decoder.c | 5 ++ drivers/media/rc/lirc_dev.c | 13 ++++ drivers/media/rc/rc-core-priv.h | 3 + drivers/media/rc/rc-main.c | 7 ++ include/media/rc-core.h | 5 ++ 6 files changed, 122 insertions(+), 15 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 52daac9bc4704..817258c87b5c5 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -88,6 +88,21 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); } +/** + * ir_lirc_scancode_event() - Send scancode data to lirc to be relayed to + * userspace + * @dev: the struct rc_dev descriptor of the device + * @lsc: the struct lirc_scancode describing the decoded scancode + */ +void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc) +{ + lsc->timestamp = ktime_get_ns(); + + if (kfifo_put(&dev->scancodes, *lsc)) + wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); +} +EXPORT_SYMBOL_GPL(ir_lirc_scancode_event); + static int ir_lirc_open(struct inode *inode, struct file *file) { struct rc_dev *dev = container_of(inode->i_cdev, struct rc_dev, @@ -114,6 +129,8 @@ static int ir_lirc_open(struct inode *inode, struct file *file) if (dev->driver_type == RC_DRIVER_IR_RAW) kfifo_reset_out(&dev->rawir); + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_reset_out(&dev->scancodes); dev->lirc_open++; file->private_data = dev; @@ -288,7 +305,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, switch (cmd) { case LIRC_GET_FEATURES: if (dev->driver_type == RC_DRIVER_IR_RAW) { - val |= LIRC_CAN_REC_MODE2; + val |= LIRC_CAN_REC_MODE2 | LIRC_CAN_REC_SCANCODE; if (dev->rx_resolution) val |= LIRC_CAN_GET_REC_RESOLUTION; } @@ -323,15 +340,17 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (dev->driver_type == RC_DRIVER_IR_RAW_TX) return -ENOTTY; - val = LIRC_MODE_MODE2; + val = dev->rec_mode; break; case LIRC_SET_REC_MODE: if (dev->driver_type == RC_DRIVER_IR_RAW_TX) return -ENOTTY; - if (val != LIRC_MODE_MODE2) + if (!(val == LIRC_MODE_MODE2 || val == LIRC_MODE_SCANCODE)) return -EINVAL; + + dev->rec_mode = val; return 0; case LIRC_GET_SEND_MODE: @@ -471,31 +490,31 @@ static unsigned int ir_lirc_poll(struct file *file, poll_wait(file, &rcdev->wait_poll, wait); - if (!rcdev->registered) + if (!rcdev->registered) { events = POLLHUP | POLLERR; - else if (rcdev->driver_type == RC_DRIVER_IR_RAW && - !kfifo_is_empty(&rcdev->rawir)) - events = POLLIN | POLLRDNORM; + } else if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) { + if (rcdev->rec_mode == LIRC_MODE_SCANCODE && + !kfifo_is_empty(&rcdev->scancodes)) + events = POLLIN | POLLRDNORM; + + if (rcdev->rec_mode == LIRC_MODE_MODE2 && + !kfifo_is_empty(&rcdev->rawir)) + events = POLLIN | POLLRDNORM; + } return events; } -static ssize_t ir_lirc_read(struct file *file, char __user *buffer, - size_t length, loff_t *ppos) +static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, + size_t length) { struct rc_dev *rcdev = file->private_data; unsigned int copied; int ret; - if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) - return -EINVAL; - if (length < sizeof(unsigned int) || length % sizeof(unsigned int)) return -EINVAL; - if (!rcdev->registered) - return -ENODEV; - do { if (kfifo_is_empty(&rcdev->rawir)) { if (file->f_flags & O_NONBLOCK) @@ -523,6 +542,61 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, return copied; } +static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, + size_t length) +{ + struct rc_dev *rcdev = file->private_data; + unsigned int copied; + int ret; + + if (length < sizeof(struct lirc_scancode) || + length % sizeof(struct lirc_scancode)) + return -EINVAL; + + do { + if (kfifo_is_empty(&rcdev->scancodes)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible(rcdev->wait_poll, + !kfifo_is_empty(&rcdev->scancodes) || + !rcdev->registered); + if (ret) + return ret; + } + + if (!rcdev->registered) + return -ENODEV; + + ret = mutex_lock_interruptible(&rcdev->lock); + if (ret) + return ret; + ret = kfifo_to_user(&rcdev->scancodes, buffer, length, &copied); + mutex_unlock(&rcdev->lock); + if (ret) + return ret; + } while (copied == 0); + + return copied; +} + +static ssize_t ir_lirc_read(struct file *file, char __user *buffer, + size_t length, loff_t *ppos) +{ + struct rc_dev *rcdev = file->private_data; + + if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) + return -EINVAL; + + if (!rcdev->registered) + return -ENODEV; + + if (rcdev->rec_mode == LIRC_MODE_MODE2) + return ir_lirc_read_mode2(file, buffer, length); + else /* LIRC_MODE_SCANCODE */ + return ir_lirc_read_scancode(file, buffer, length); +} + const struct file_operations lirc_fops = { .owner = THIS_MODULE, .write = ir_lirc_transmit_ir, diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index 2c9ee0c1f4321..8cf4cf358052a 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -215,6 +215,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) struct mce_kbd_dec *data = &dev->raw->mce_kbd; u32 scancode; unsigned long delay; + struct lirc_scancode lsc = {}; if (!is_timing_event(ev)) { if (ev.reset) @@ -326,18 +327,22 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) mod_timer(&data->rx_timeout, jiffies + delay); /* Pass data to keyboard buffer parser */ ir_mce_kbd_process_keyboard_data(data->idev, scancode); + lsc.rc_proto = RC_PROTO_MCIR2_KBD; break; case MCIR2_MOUSE_NBITS: scancode = data->body & 0x1fffff; IR_dprintk(1, "mouse data 0x%06x\n", scancode); /* Pass data to mouse buffer parser */ ir_mce_kbd_process_mouse_data(data->idev, scancode); + lsc.rc_proto = RC_PROTO_MCIR2_MSE; break; default: IR_dprintk(1, "not keyboard or mouse data\n"); goto out; } + lsc.scancode = scancode; + ir_lirc_scancode_event(dev, &lsc); data->state = STATE_INACTIVE; input_event(data->idev, EV_MSC, MSC_SCAN, scancode); input_sync(data->idev); diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 155a4de249a07..d766abcffeac8 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -42,6 +42,8 @@ static void lirc_release_device(struct device *ld) if (rcdev->driver_type == RC_DRIVER_IR_RAW) kfifo_free(&rcdev->rawir); + if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_free(&rcdev->scancodes); put_device(&rcdev->dev); } @@ -55,11 +57,20 @@ int ir_lirc_register(struct rc_dev *dev) dev->lirc_dev.release = lirc_release_device; dev->send_mode = LIRC_MODE_PULSE; + dev->rec_mode = LIRC_MODE_MODE2; + if (dev->driver_type == RC_DRIVER_IR_RAW) { if (kfifo_alloc(&dev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) return -ENOMEM; } + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { + if (kfifo_alloc(&dev->scancodes, 32, GFP_KERNEL)) { + kfifo_free(&dev->rawir); + return -ENOMEM; + } + } + init_waitqueue_head(&dev->wait_poll); minor = ida_simple_get(&lirc_ida, 0, RC_DEV_MAX, GFP_KERNEL); @@ -90,6 +101,8 @@ int ir_lirc_register(struct rc_dev *dev) out_kfifo: if (dev->driver_type == RC_DRIVER_IR_RAW) kfifo_free(&dev->rawir); + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_free(&dev->scancodes); return err; } diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 9af43d16ca292..2a5e9cc3ddb31 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -276,6 +276,7 @@ void ir_raw_init(void); int lirc_dev_init(void); void lirc_dev_exit(void); void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev); +void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc); int ir_lirc_register(struct rc_dev *dev); void ir_lirc_unregister(struct rc_dev *dev); @@ -285,6 +286,8 @@ static inline int lirc_dev_init(void) { return 0; } static inline void lirc_dev_exit(void) {} static inline void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) { } +static inline void ir_lirc_scancode_event(struct rc_dev *dev, + struct lirc_scancode *lsc) { } static inline int ir_lirc_register(struct rc_dev *dev) { return 0; } static inline void ir_lirc_unregister(struct rc_dev *dev) { } #endif diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 12ff6d87b113f..b22443fe8c345 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -697,6 +697,13 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol, dev->last_protocol != protocol || dev->last_scancode != scancode || dev->last_toggle != toggle); + struct lirc_scancode sc = { + .scancode = scancode, .rc_proto = protocol, + .flags = toggle ? LIRC_SCANCODE_FLAG_TOGGLE : 0, + .keycode = keycode + }; + + ir_lirc_scancode_event(dev, &sc); if (new_event && dev->keypressed) ir_do_keyup(dev, false); diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 2d24c88652aad..fbf1648d2ec95 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -126,9 +126,12 @@ enum rc_filter_type { * @gap: true if we're in a gap * @send_timeout_reports: report timeouts in lirc raw IR. * @rawir: queue for incoming raw IR + * @scancodes: queue for incoming decoded scancodes * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE + * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or + * LIRC_MODE_MODE2 * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders @@ -200,8 +203,10 @@ struct rc_dev { bool gap; bool send_timeout_reports; DECLARE_KFIFO_PTR(rawir, unsigned int); + DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); wait_queue_head_t wait_poll; u8 send_mode; + u8 rec_mode; #endif bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- GitLab From b66218fddfd29f315a103db811152ab0c95fb054 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 30 Sep 2017 07:13:37 -0400 Subject: [PATCH 0211/1190] media: lirc: ensure lirc device receives nec repeats The lirc device should get lirc repeats whether there is a keymap match or not. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/rc-main.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index b22443fe8c345..058807bc80dcc 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -662,19 +662,25 @@ void rc_repeat(struct rc_dev *dev) { unsigned long flags; unsigned int timeout = protocols[dev->last_protocol].repeat_period; + struct lirc_scancode sc = { + .scancode = dev->last_scancode, .rc_proto = dev->last_protocol, + .keycode = dev->keypressed ? dev->last_keycode : KEY_RESERVED, + .flags = LIRC_SCANCODE_FLAG_REPEAT | + (dev->last_toggle ? LIRC_SCANCODE_FLAG_TOGGLE : 0) + }; - spin_lock_irqsave(&dev->keylock, flags); + ir_lirc_scancode_event(dev, &sc); - if (!dev->keypressed) - goto out; + spin_lock_irqsave(&dev->keylock, flags); input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); input_sync(dev->input_dev); - dev->keyup_jiffies = jiffies + msecs_to_jiffies(timeout); - mod_timer(&dev->timer_keyup, dev->keyup_jiffies); + if (dev->keypressed) { + dev->keyup_jiffies = jiffies + msecs_to_jiffies(timeout); + mod_timer(&dev->timer_keyup, dev->keyup_jiffies); + } -out: spin_unlock_irqrestore(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(rc_repeat); @@ -710,13 +716,14 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol, input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); + dev->last_protocol = protocol; + dev->last_scancode = scancode; + dev->last_toggle = toggle; + dev->last_keycode = keycode; + if (new_event && keycode != KEY_RESERVED) { /* Register a keypress */ dev->keypressed = true; - dev->last_protocol = protocol; - dev->last_scancode = scancode; - dev->last_toggle = toggle; - dev->last_keycode = keycode; IR_dprintk(1, "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n", dev->device_name, keycode, protocol, scancode); -- GitLab From 7d402db89b5b6d3ca5128937dc04653df8668978 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:34 -0500 Subject: [PATCH 0212/1190] media: lirc: document LIRC_MODE_SCANCODE Lirc supports a new mode which requires documentation. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/lirc.h.rst.exceptions | 26 ++++++++++ .../media/uapi/rc/lirc-dev-intro.rst | 51 +++++++++++++++++-- .../media/uapi/rc/lirc-get-features.rst | 16 ++++++ .../media/uapi/rc/lirc-get-rec-mode.rst | 3 +- .../media/uapi/rc/lirc-get-send-mode.rst | 3 +- Documentation/media/uapi/rc/lirc-read.rst | 15 ++++-- Documentation/media/uapi/rc/lirc-write.rst | 19 +++++-- 7 files changed, 118 insertions(+), 15 deletions(-) diff --git a/Documentation/media/lirc.h.rst.exceptions b/Documentation/media/lirc.h.rst.exceptions index 63ba1d341905b..c6e3a35d2c4ea 100644 --- a/Documentation/media/lirc.h.rst.exceptions +++ b/Documentation/media/lirc.h.rst.exceptions @@ -32,6 +32,32 @@ ignore define LIRC_CAN_SET_REC_DUTY_CYCLE ignore ioctl LIRC_GET_LENGTH +# rc protocols + +ignore symbol RC_PROTO_UNKNOWN +ignore symbol RC_PROTO_OTHER +ignore symbol RC_PROTO_RC5 +ignore symbol RC_PROTO_RC5X_20 +ignore symbol RC_PROTO_RC5_SZ +ignore symbol RC_PROTO_JVC +ignore symbol RC_PROTO_SONY12 +ignore symbol RC_PROTO_SONY15 +ignore symbol RC_PROTO_SONY20 +ignore symbol RC_PROTO_NEC +ignore symbol RC_PROTO_NECX +ignore symbol RC_PROTO_NEC32 +ignore symbol RC_PROTO_SANYO +ignore symbol RC_PROTO_MCIR2_KBD +ignore symbol RC_PROTO_MCIR2_MSE +ignore symbol RC_PROTO_RC6_0 +ignore symbol RC_PROTO_RC6_6A_20 +ignore symbol RC_PROTO_RC6_6A_24 +ignore symbol RC_PROTO_RC6_6A_32 +ignore symbol RC_PROTO_RC6_MCE +ignore symbol RC_PROTO_SHARP +ignore symbol RC_PROTO_XMP +ignore symbol RC_PROTO_CEC + # Undocumented macros ignore define PULSE_BIT diff --git a/Documentation/media/uapi/rc/lirc-dev-intro.rst b/Documentation/media/uapi/rc/lirc-dev-intro.rst index a3fa3c1ef1693..47c6c218e72a5 100644 --- a/Documentation/media/uapi/rc/lirc-dev-intro.rst +++ b/Documentation/media/uapi/rc/lirc-dev-intro.rst @@ -6,11 +6,12 @@ Introduction ************ -The LIRC device interface is a bi-directional interface for transporting -raw IR data between userspace and kernelspace. Fundamentally, it is just -a chardev (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard -struct file_operations defined on it. With respect to transporting raw -IR data to and fro, the essential fops are read, write and ioctl. +LIRC stands for Linux Infrared Remote Control. The LIRC device interface is +a bi-directional interface for transporting raw IR and decoded scancodes +data between userspace and kernelspace. Fundamentally, it is just a chardev +(/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct +file_operations defined on it. With respect to transporting raw IR and +decoded scancodes to and fro, the essential fops are read, write and ioctl. Example dmesg output upon a driver registering w/LIRC: @@ -36,6 +37,46 @@ LIRC modes LIRC supports some modes of receiving and sending IR codes, as shown on the following table. +.. _lirc-mode-scancode: +.. _lirc-scancode-flag-toggle: +.. _lirc-scancode-flag-repeat: + +``LIRC_MODE_SCANCODE`` + + This mode is for both sending and receiving IR. + + For transmitting (aka sending), create a ``struct lirc_scancode`` with + the desired scancode set in the ``scancode`` member, ``rc_proto`` set + the IR protocol, and all other members set to 0. Write this struct to + the lirc device. + + For receiving, you read ``struct lirc_scancode`` from the lirc device, + with ``scancode`` set to the received scancode and the IR protocol + ``rc_proto``. If the scancode maps to a valid key code, this is set + in the ``keycode`` field, else it is set to ``KEY_RESERVED``. + + The ``flags`` can have ``LIRC_SCANCODE_FLAG_TOGGLE`` set if the toggle + bit is set in protocols that support it (e.g. rc-5 and rc-6), or + ``LIRC_SCANCODE_FLAG_REPEAT`` for when a repeat is received for protocols + that support it (e.g. nec). + + In the Sanyo and NEC protocol, if you hold a button on remote, rather than + repeating the entire scancode, the remote sends a shorter message with + no scancode, which just means button is held, a "repeat". When this is + received, the ``LIRC_SCANCODE_FLAG_REPEAT`` is set and the scancode and + keycode is repeated. + + With nec, there is no way to distinguish "button hold" from "repeatedly + pressing the same button". The rc-5 and rc-6 protocols have a toggle bit. + When a button is released and pressed again, the toggle bit is inverted. + If the toggle bit is set, the ``LIRC_SCANCODE_FLAG_TOGGLE`` is set. + + The ``timestamp`` field is filled with the time nanoseconds + (in ``CLOCK_MONOTONIC``) when the scancode was decoded. + + An ``enum rc_proto`` in the :ref:`lirc_header` lists all the supported + IR protocols. + .. _lirc-mode-mode2: ``LIRC_MODE_MODE2`` diff --git a/Documentation/media/uapi/rc/lirc-get-features.rst b/Documentation/media/uapi/rc/lirc-get-features.rst index 50c2c26d8e89e..3ee44067de638 100644 --- a/Documentation/media/uapi/rc/lirc-get-features.rst +++ b/Documentation/media/uapi/rc/lirc-get-features.rst @@ -64,6 +64,14 @@ LIRC features Unused. Kept just to avoid breaking uAPI. +.. _LIRC-CAN-REC-SCANCODE: + +``LIRC_CAN_REC_SCANCODE`` + + The driver is capable of receiving using + :ref:`LIRC_MODE_SCANCODE `. + + .. _LIRC-CAN-SET-SEND-CARRIER: ``LIRC_CAN_SET_SEND_CARRIER`` @@ -171,6 +179,14 @@ LIRC features Unused. Kept just to avoid breaking uAPI. +.. _LIRC-CAN-SEND-SCANCODE: + +``LIRC_CAN_SEND_SCANCODE`` + + The driver supports sending (also called as IR blasting or IR TX) using + :ref:`LIRC_MODE_SCANCODE `. + + Return Value ============ diff --git a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst index b89de9add921d..34919feaf3923 100644 --- a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst +++ b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst @@ -34,7 +34,8 @@ Description =========== Get/set supported receive modes. Only :ref:`LIRC_MODE_MODE2 ` -is supported for IR receive. +and :ref:`LIRC_MODE_SCANCODE ` are supported. +Use :ref:`lirc_get_features` to find out which modes the driver supports. Return Value ============ diff --git a/Documentation/media/uapi/rc/lirc-get-send-mode.rst b/Documentation/media/uapi/rc/lirc-get-send-mode.rst index e686b21689a08..e39383f08e21b 100644 --- a/Documentation/media/uapi/rc/lirc-get-send-mode.rst +++ b/Documentation/media/uapi/rc/lirc-get-send-mode.rst @@ -36,7 +36,8 @@ Description Get/set current transmit mode. -Only :ref:`LIRC_MODE_PULSE ` is supported by for IR send, +Only :ref:`LIRC_MODE_PULSE ` and +:ref:`LIRC_MODE_SCANCODE ` are supported by for IR send, depending on the driver. Use :ref:`lirc_get_features` to find out which modes the driver supports. diff --git a/Documentation/media/uapi/rc/lirc-read.rst b/Documentation/media/uapi/rc/lirc-read.rst index ff14a69104e54..51d37ed10194c 100644 --- a/Documentation/media/uapi/rc/lirc-read.rst +++ b/Documentation/media/uapi/rc/lirc-read.rst @@ -45,13 +45,20 @@ descriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero, is greater than ``SSIZE_MAX``, the result is unspecified. The exact format of the data depends on what :ref:`lirc_modes` a driver -uses. Use :ref:`lirc_get_features` to get the supported mode. +uses. Use :ref:`lirc_get_features` to get the supported mode, and use +:ref:`lirc_set_rec_mode` set the current active mode. -The generally preferred mode for receive is -:ref:`LIRC_MODE_MODE2 `, -in which packets containing an int value describing an IR signal are +The mode :ref:`LIRC_MODE_MODE2 ` is for raw IR, +in which packets containing an unsigned int value describing an IR signal are read from the chardev. +Alternatively, :ref:`LIRC_MODE_SCANCODE ` can be available, +in this mode scancodes which are either decoded by software decoders, or +by hardware decoders. The ``rc_proto`` member is set to the +protocol used for transmission, and ``scancode`` to the decoded scancode, +and the ``keycode`` set to the keycode or ``KEY_RESERVED``. + + Return Value ============ diff --git a/Documentation/media/uapi/rc/lirc-write.rst b/Documentation/media/uapi/rc/lirc-write.rst index 2aad0fef4a5b1..3d7541bad8b9a 100644 --- a/Documentation/media/uapi/rc/lirc-write.rst +++ b/Documentation/media/uapi/rc/lirc-write.rst @@ -42,21 +42,32 @@ Description referenced by the file descriptor ``fd`` from the buffer starting at ``buf``. -The exact format of the data depends on what mode a driver uses, use -:ref:`lirc_get_features` to get the supported mode. +The exact format of the data depends on what mode a driver is in, use +:ref:`lirc_get_features` to get the supported modes and use +:ref:`lirc_set_send_mode` set the mode. When in :ref:`LIRC_MODE_PULSE ` mode, the data written to the chardev is a pulse/space sequence of integer values. Pulses and spaces are only marked implicitly by their position. The data must start and end with a pulse, therefore, the data must always include an uneven number of -samples. The write function must block until the data has been transmitted +samples. The write function blocks until the data has been transmitted by the hardware. If more data is provided than the hardware can send, the driver returns ``EINVAL``. +When in :ref:`LIRC_MODE_SCANCODE ` mode, one +``struct lirc_scancode`` must be written to the chardev at a time, else +``EINVAL`` is returned. Set the desired scancode in the ``scancode`` member, +and the protocol in the ``rc_proto`` member. All other members must be set +to 0, else ``EINVAL`` is returned. If there is no protocol encoder +for the protocol or the scancode is not valid for the specified protocol, +``EINVAL`` is returned. The write function may not wait until the scancode +is transmitted. + + Return Value ============ -On success, the number of bytes read is returned. It is not an error if +On success, the number of bytes written is returned. It is not an error if this number is smaller than the number of bytes requested, or the amount of data required for one frame. On error, -1 is returned, and the ``errno`` variable is set appropriately. The generic error codes are described at the -- GitLab From 62d6f1994b41b9210b07ca453372797f59141e5c Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sun, 24 Sep 2017 12:43:24 -0400 Subject: [PATCH 0213/1190] media: lirc: scancode rc devices should have a lirc device too Now that the lirc interface supports scancodes, RC scancode devices can also have a lirc device. The only receiving feature they will have enabled is LIRC_CAN_REC_SCANCODE. Note that CEC devices have no lirc device, since they can be controlled from their /dev/cecN chardev. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-lirc-codec.c | 19 +++++++++++++++---- drivers/media/rc/lirc_dev.c | 5 ++++- drivers/media/rc/rc-main.c | 6 +++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 817258c87b5c5..8c5df6e8579eb 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -304,6 +304,9 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, switch (cmd) { case LIRC_GET_FEATURES: + if (dev->driver_type == RC_DRIVER_SCANCODE) + val |= LIRC_CAN_REC_SCANCODE; + if (dev->driver_type == RC_DRIVER_IR_RAW) { val |= LIRC_CAN_REC_MODE2 | LIRC_CAN_REC_SCANCODE; if (dev->rx_resolution) @@ -344,11 +347,19 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, break; case LIRC_SET_REC_MODE: - if (dev->driver_type == RC_DRIVER_IR_RAW_TX) + switch (dev->driver_type) { + case RC_DRIVER_IR_RAW_TX: return -ENOTTY; - - if (!(val == LIRC_MODE_MODE2 || val == LIRC_MODE_SCANCODE)) - return -EINVAL; + case RC_DRIVER_SCANCODE: + if (val != LIRC_MODE_SCANCODE) + return -EINVAL; + break; + case RC_DRIVER_IR_RAW: + if (!(val == LIRC_MODE_MODE2 || + val == LIRC_MODE_SCANCODE)) + return -EINVAL; + break; + } dev->rec_mode = val; return 0; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index d766abcffeac8..2a0c48698309c 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -57,7 +57,10 @@ int ir_lirc_register(struct rc_dev *dev) dev->lirc_dev.release = lirc_release_device; dev->send_mode = LIRC_MODE_PULSE; - dev->rec_mode = LIRC_MODE_MODE2; + if (dev->driver_type == RC_DRIVER_SCANCODE) + dev->rec_mode = LIRC_MODE_SCANCODE; + else + dev->rec_mode = LIRC_MODE_MODE2; if (dev->driver_type == RC_DRIVER_IR_RAW) { if (kfifo_alloc(&dev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 058807bc80dcc..5830cb2c59436 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1814,7 +1814,7 @@ int rc_register_device(struct rc_dev *dev) } /* Ensure that the lirc kfifo is setup before we start the thread */ - if (dev->driver_type != RC_DRIVER_SCANCODE) { + if (dev->allowed_protocols != RC_PROTO_BIT_CEC) { rc = ir_lirc_register(dev); if (rc < 0) goto out_rx; @@ -1835,7 +1835,7 @@ int rc_register_device(struct rc_dev *dev) return 0; out_lirc: - if (dev->driver_type != RC_DRIVER_SCANCODE) + if (dev->allowed_protocols != RC_PROTO_BIT_CEC) ir_lirc_unregister(dev); out_rx: rc_free_rx_device(dev); @@ -1898,7 +1898,7 @@ void rc_unregister_device(struct rc_dev *dev) * lirc device should be freed with dev->registered = false, so * that userspace polling will get notified. */ - if (dev->driver_type != RC_DRIVER_SCANCODE) + if (dev->allowed_protocols != RC_PROTO_BIT_CEC) ir_lirc_unregister(dev); device_del(&dev->dev); -- GitLab From 8a866fee3909c49738e1c4429a8d2b9bf27e015d Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sun, 8 Oct 2017 12:12:16 -0400 Subject: [PATCH 0214/1190] kfifo: DECLARE_KIFO_PTR(fifo, u64) does not work on arm 32 bit If you try to store u64 in a kfifo (or a struct with u64 members), then the buf member of __STRUCT_KFIFO_PTR will cause 4 bytes padding due to alignment (note that struct __kfifo is 20 bytes on 32 bit). That in turn causes the __is_kfifo_ptr() to fail, which is caught by kfifo_alloc(), which now returns EINVAL. So, ensure that __is_kfifo_ptr() compares to the right structure. Signed-off-by: Sean Young Acked-by: Stefani Seibold Signed-off-by: Mauro Carvalho Chehab --- include/linux/kfifo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index 7b45959ebd92d..e251533a59396 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h @@ -113,7 +113,8 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void); * array is a part of the structure and the fifo type where the array is * outside of the fifo structure. */ -#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo)) +#define __is_kfifo_ptr(fifo) \ + (sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type)))) /** * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object -- GitLab From 42e0442f8a237d3de9ea3f2dd2be2739e6db7fdb Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 2 Nov 2017 16:39:16 -0400 Subject: [PATCH 0215/1190] media: rc: move ir-lirc-codec.c contents into lirc_dev.c Since removing the lirc kapi, ir-lirc-codec.c only contains lirc fops so the file name is no longer correct. By moving its content into lirc_dev.c the ugly extern struct lirc_fops is not longer needed, and everything lirc related is in one file. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/Makefile | 2 +- drivers/media/rc/ir-lirc-codec.c | 623 ------------------------------- drivers/media/rc/lirc_dev.c | 604 ++++++++++++++++++++++++++++++ drivers/media/rc/rc-core-priv.h | 2 - 4 files changed, 605 insertions(+), 626 deletions(-) delete mode 100644 drivers/media/rc/ir-lirc-codec.c diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile index 081b34f971647..0e857816ac2d9 100644 --- a/drivers/media/rc/Makefile +++ b/drivers/media/rc/Makefile @@ -4,7 +4,7 @@ obj-y += keymaps/ obj-$(CONFIG_RC_CORE) += rc-core.o rc-core-y := rc-main.o rc-ir-raw.o -rc-core-$(CONFIG_LIRC) += lirc_dev.o ir-lirc-codec.o +rc-core-$(CONFIG_LIRC) += lirc_dev.o obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c deleted file mode 100644 index 8c5df6e8579eb..0000000000000 --- a/drivers/media/rc/ir-lirc-codec.c +++ /dev/null @@ -1,623 +0,0 @@ -/* ir-lirc-codec.c - rc-core to classic lirc interface bridge - * - * Copyright (C) 2010 by Jarod Wilson - * - * 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 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. - */ - -#include -#include -#include -#include -#include -#include "rc-core-priv.h" - -#define LIRCBUF_SIZE 256 - -/** - * ir_lirc_raw_event() - Send raw IR data to lirc to be relayed to userspace - * - * @dev: the struct rc_dev descriptor of the device - * @ev: the struct ir_raw_event descriptor of the pulse/space - */ -void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) -{ - int sample; - - /* Packet start */ - if (ev.reset) { - /* Userspace expects a long space event before the start of - * the signal to use as a sync. This may be done with repeat - * packets and normal samples. But if a reset has been sent - * then we assume that a long time has passed, so we send a - * space with the maximum time value. */ - sample = LIRC_SPACE(LIRC_VALUE_MASK); - IR_dprintk(2, "delivering reset sync space to lirc_dev\n"); - - /* Carrier reports */ - } else if (ev.carrier_report) { - sample = LIRC_FREQUENCY(ev.carrier); - IR_dprintk(2, "carrier report (freq: %d)\n", sample); - - /* Packet end */ - } else if (ev.timeout) { - - if (dev->gap) - return; - - dev->gap_start = ktime_get(); - dev->gap = true; - dev->gap_duration = ev.duration; - - if (!dev->send_timeout_reports) - return; - - sample = LIRC_TIMEOUT(ev.duration / 1000); - IR_dprintk(2, "timeout report (duration: %d)\n", sample); - - /* Normal sample */ - } else { - - if (dev->gap) { - dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), - dev->gap_start)); - - /* Convert to ms and cap by LIRC_VALUE_MASK */ - do_div(dev->gap_duration, 1000); - dev->gap_duration = min_t(u64, dev->gap_duration, - LIRC_VALUE_MASK); - - kfifo_put(&dev->rawir, LIRC_SPACE(dev->gap_duration)); - dev->gap = false; - } - - sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) : - LIRC_SPACE(ev.duration / 1000); - IR_dprintk(2, "delivering %uus %s to lirc_dev\n", - TO_US(ev.duration), TO_STR(ev.pulse)); - } - - kfifo_put(&dev->rawir, sample); - wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); -} - -/** - * ir_lirc_scancode_event() - Send scancode data to lirc to be relayed to - * userspace - * @dev: the struct rc_dev descriptor of the device - * @lsc: the struct lirc_scancode describing the decoded scancode - */ -void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc) -{ - lsc->timestamp = ktime_get_ns(); - - if (kfifo_put(&dev->scancodes, *lsc)) - wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); -} -EXPORT_SYMBOL_GPL(ir_lirc_scancode_event); - -static int ir_lirc_open(struct inode *inode, struct file *file) -{ - struct rc_dev *dev = container_of(inode->i_cdev, struct rc_dev, - lirc_cdev); - int retval; - - retval = rc_open(dev); - if (retval) - return retval; - - retval = mutex_lock_interruptible(&dev->lock); - if (retval) - goto out_rc; - - if (!dev->registered) { - retval = -ENODEV; - goto out_unlock; - } - - if (dev->lirc_open) { - retval = -EBUSY; - goto out_unlock; - } - - if (dev->driver_type == RC_DRIVER_IR_RAW) - kfifo_reset_out(&dev->rawir); - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) - kfifo_reset_out(&dev->scancodes); - - dev->lirc_open++; - file->private_data = dev; - - nonseekable_open(inode, file); - mutex_unlock(&dev->lock); - - return 0; - -out_unlock: - mutex_unlock(&dev->lock); -out_rc: - rc_close(dev); - return retval; -} - -static int ir_lirc_close(struct inode *inode, struct file *file) -{ - struct rc_dev *dev = file->private_data; - - mutex_lock(&dev->lock); - dev->lirc_open--; - mutex_unlock(&dev->lock); - - rc_close(dev); - - return 0; -} - -static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, - size_t n, loff_t *ppos) -{ - struct rc_dev *dev = file->private_data; - unsigned int *txbuf = NULL; - struct ir_raw_event *raw = NULL; - ssize_t ret = -EINVAL; - size_t count; - ktime_t start; - s64 towait; - unsigned int duration = 0; /* signal duration in us */ - int i; - - if (!dev->registered) - return -ENODEV; - - start = ktime_get(); - - if (!dev->tx_ir) { - ret = -EINVAL; - goto out; - } - - if (dev->send_mode == LIRC_MODE_SCANCODE) { - struct lirc_scancode scan; - - if (n != sizeof(scan)) - return -EINVAL; - - if (copy_from_user(&scan, buf, sizeof(scan))) - return -EFAULT; - - if (scan.flags || scan.keycode || scan.timestamp) - return -EINVAL; - - /* - * The scancode field in lirc_scancode is 64-bit simply - * to future-proof it, since there are IR protocols encode - * use more than 32 bits. For now only 32-bit protocols - * are supported. - */ - if (scan.scancode > U32_MAX || - !rc_validate_scancode(scan.rc_proto, scan.scancode)) - return -EINVAL; - - raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL); - if (!raw) - return -ENOMEM; - - ret = ir_raw_encode_scancode(scan.rc_proto, scan.scancode, - raw, LIRCBUF_SIZE); - if (ret < 0) - goto out; - - count = ret; - - txbuf = kmalloc_array(count, sizeof(unsigned int), GFP_KERNEL); - if (!txbuf) { - ret = -ENOMEM; - goto out; - } - - for (i = 0; i < count; i++) - /* Convert from NS to US */ - txbuf[i] = DIV_ROUND_UP(raw[i].duration, 1000); - - if (dev->s_tx_carrier) { - int carrier = ir_raw_encode_carrier(scan.rc_proto); - - if (carrier > 0) - dev->s_tx_carrier(dev, carrier); - } - } else { - if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) - return -EINVAL; - - count = n / sizeof(unsigned int); - if (count > LIRCBUF_SIZE || count % 2 == 0) - return -EINVAL; - - txbuf = memdup_user(buf, n); - if (IS_ERR(txbuf)) - return PTR_ERR(txbuf); - } - - for (i = 0; i < count; i++) { - if (txbuf[i] > IR_MAX_DURATION / 1000 - duration || !txbuf[i]) { - ret = -EINVAL; - goto out; - } - - duration += txbuf[i]; - } - - ret = dev->tx_ir(dev, txbuf, count); - if (ret < 0) - goto out; - - if (dev->send_mode == LIRC_MODE_SCANCODE) { - ret = n; - } else { - for (duration = i = 0; i < ret; i++) - duration += txbuf[i]; - - ret *= sizeof(unsigned int); - - /* - * The lircd gap calculation expects the write function to - * wait for the actual IR signal to be transmitted before - * returning. - */ - towait = ktime_us_delta(ktime_add_us(start, duration), - ktime_get()); - if (towait > 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(usecs_to_jiffies(towait)); - } - } - -out: - kfree(txbuf); - kfree(raw); - return ret; -} - -static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - struct rc_dev *dev = filep->private_data; - u32 __user *argp = (u32 __user *)(arg); - int ret = 0; - __u32 val = 0, tmp; - - if (_IOC_DIR(cmd) & _IOC_WRITE) { - ret = get_user(val, argp); - if (ret) - return ret; - } - - if (!dev->registered) - return -ENODEV; - - switch (cmd) { - case LIRC_GET_FEATURES: - if (dev->driver_type == RC_DRIVER_SCANCODE) - val |= LIRC_CAN_REC_SCANCODE; - - if (dev->driver_type == RC_DRIVER_IR_RAW) { - val |= LIRC_CAN_REC_MODE2 | LIRC_CAN_REC_SCANCODE; - if (dev->rx_resolution) - val |= LIRC_CAN_GET_REC_RESOLUTION; - } - - if (dev->tx_ir) { - val |= LIRC_CAN_SEND_PULSE | LIRC_CAN_SEND_SCANCODE; - if (dev->s_tx_mask) - val |= LIRC_CAN_SET_TRANSMITTER_MASK; - if (dev->s_tx_carrier) - val |= LIRC_CAN_SET_SEND_CARRIER; - if (dev->s_tx_duty_cycle) - val |= LIRC_CAN_SET_SEND_DUTY_CYCLE; - } - - if (dev->s_rx_carrier_range) - val |= LIRC_CAN_SET_REC_CARRIER | - LIRC_CAN_SET_REC_CARRIER_RANGE; - - if (dev->s_learning_mode) - val |= LIRC_CAN_USE_WIDEBAND_RECEIVER; - - if (dev->s_carrier_report) - val |= LIRC_CAN_MEASURE_CARRIER; - - if (dev->max_timeout) - val |= LIRC_CAN_SET_REC_TIMEOUT; - - break; - - /* mode support */ - case LIRC_GET_REC_MODE: - if (dev->driver_type == RC_DRIVER_IR_RAW_TX) - return -ENOTTY; - - val = dev->rec_mode; - break; - - case LIRC_SET_REC_MODE: - switch (dev->driver_type) { - case RC_DRIVER_IR_RAW_TX: - return -ENOTTY; - case RC_DRIVER_SCANCODE: - if (val != LIRC_MODE_SCANCODE) - return -EINVAL; - break; - case RC_DRIVER_IR_RAW: - if (!(val == LIRC_MODE_MODE2 || - val == LIRC_MODE_SCANCODE)) - return -EINVAL; - break; - } - - dev->rec_mode = val; - return 0; - - case LIRC_GET_SEND_MODE: - if (!dev->tx_ir) - return -ENOTTY; - - val = dev->send_mode; - break; - - case LIRC_SET_SEND_MODE: - if (!dev->tx_ir) - return -ENOTTY; - - if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) - return -EINVAL; - - dev->send_mode = val; - return 0; - - /* TX settings */ - case LIRC_SET_TRANSMITTER_MASK: - if (!dev->s_tx_mask) - return -ENOTTY; - - return dev->s_tx_mask(dev, val); - - case LIRC_SET_SEND_CARRIER: - if (!dev->s_tx_carrier) - return -ENOTTY; - - return dev->s_tx_carrier(dev, val); - - case LIRC_SET_SEND_DUTY_CYCLE: - if (!dev->s_tx_duty_cycle) - return -ENOTTY; - - if (val <= 0 || val >= 100) - return -EINVAL; - - return dev->s_tx_duty_cycle(dev, val); - - /* RX settings */ - case LIRC_SET_REC_CARRIER: - if (!dev->s_rx_carrier_range) - return -ENOTTY; - - if (val <= 0) - return -EINVAL; - - return dev->s_rx_carrier_range(dev, - dev->carrier_low, - val); - - case LIRC_SET_REC_CARRIER_RANGE: - if (!dev->s_rx_carrier_range) - return -ENOTTY; - - if (val <= 0) - return -EINVAL; - - dev->carrier_low = val; - return 0; - - case LIRC_GET_REC_RESOLUTION: - if (!dev->rx_resolution) - return -ENOTTY; - - val = dev->rx_resolution / 1000; - break; - - case LIRC_SET_WIDEBAND_RECEIVER: - if (!dev->s_learning_mode) - return -ENOTTY; - - return dev->s_learning_mode(dev, !!val); - - case LIRC_SET_MEASURE_CARRIER_MODE: - if (!dev->s_carrier_report) - return -ENOTTY; - - return dev->s_carrier_report(dev, !!val); - - /* Generic timeout support */ - case LIRC_GET_MIN_TIMEOUT: - if (!dev->max_timeout) - return -ENOTTY; - val = DIV_ROUND_UP(dev->min_timeout, 1000); - break; - - case LIRC_GET_MAX_TIMEOUT: - if (!dev->max_timeout) - return -ENOTTY; - val = dev->max_timeout / 1000; - break; - - case LIRC_SET_REC_TIMEOUT: - if (!dev->max_timeout) - return -ENOTTY; - - /* Check for multiply overflow */ - if (val > U32_MAX / 1000) - return -EINVAL; - - tmp = val * 1000; - - if (tmp < dev->min_timeout || tmp > dev->max_timeout) - return -EINVAL; - - if (dev->s_timeout) - ret = dev->s_timeout(dev, tmp); - if (!ret) - dev->timeout = tmp; - break; - - case LIRC_SET_REC_TIMEOUT_REPORTS: - if (!dev->timeout) - return -ENOTTY; - - dev->send_timeout_reports = !!val; - break; - - default: - return -ENOTTY; - } - - if (_IOC_DIR(cmd) & _IOC_READ) - ret = put_user(val, argp); - - return ret; -} - -static unsigned int ir_lirc_poll(struct file *file, - struct poll_table_struct *wait) -{ - struct rc_dev *rcdev = file->private_data; - unsigned int events = 0; - - poll_wait(file, &rcdev->wait_poll, wait); - - if (!rcdev->registered) { - events = POLLHUP | POLLERR; - } else if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) { - if (rcdev->rec_mode == LIRC_MODE_SCANCODE && - !kfifo_is_empty(&rcdev->scancodes)) - events = POLLIN | POLLRDNORM; - - if (rcdev->rec_mode == LIRC_MODE_MODE2 && - !kfifo_is_empty(&rcdev->rawir)) - events = POLLIN | POLLRDNORM; - } - - return events; -} - -static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, - size_t length) -{ - struct rc_dev *rcdev = file->private_data; - unsigned int copied; - int ret; - - if (length < sizeof(unsigned int) || length % sizeof(unsigned int)) - return -EINVAL; - - do { - if (kfifo_is_empty(&rcdev->rawir)) { - if (file->f_flags & O_NONBLOCK) - return -EAGAIN; - - ret = wait_event_interruptible(rcdev->wait_poll, - !kfifo_is_empty(&rcdev->rawir) || - !rcdev->registered); - if (ret) - return ret; - } - - if (!rcdev->registered) - return -ENODEV; - - ret = mutex_lock_interruptible(&rcdev->lock); - if (ret) - return ret; - ret = kfifo_to_user(&rcdev->rawir, buffer, length, &copied); - mutex_unlock(&rcdev->lock); - if (ret) - return ret; - } while (copied == 0); - - return copied; -} - -static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, - size_t length) -{ - struct rc_dev *rcdev = file->private_data; - unsigned int copied; - int ret; - - if (length < sizeof(struct lirc_scancode) || - length % sizeof(struct lirc_scancode)) - return -EINVAL; - - do { - if (kfifo_is_empty(&rcdev->scancodes)) { - if (file->f_flags & O_NONBLOCK) - return -EAGAIN; - - ret = wait_event_interruptible(rcdev->wait_poll, - !kfifo_is_empty(&rcdev->scancodes) || - !rcdev->registered); - if (ret) - return ret; - } - - if (!rcdev->registered) - return -ENODEV; - - ret = mutex_lock_interruptible(&rcdev->lock); - if (ret) - return ret; - ret = kfifo_to_user(&rcdev->scancodes, buffer, length, &copied); - mutex_unlock(&rcdev->lock); - if (ret) - return ret; - } while (copied == 0); - - return copied; -} - -static ssize_t ir_lirc_read(struct file *file, char __user *buffer, - size_t length, loff_t *ppos) -{ - struct rc_dev *rcdev = file->private_data; - - if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) - return -EINVAL; - - if (!rcdev->registered) - return -ENODEV; - - if (rcdev->rec_mode == LIRC_MODE_MODE2) - return ir_lirc_read_mode2(file, buffer, length); - else /* LIRC_MODE_SCANCODE */ - return ir_lirc_read_scancode(file, buffer, length); -} - -const struct file_operations lirc_fops = { - .owner = THIS_MODULE, - .write = ir_lirc_transmit_ir, - .unlocked_ioctl = ir_lirc_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = ir_lirc_ioctl, -#endif - .read = ir_lirc_read, - .poll = ir_lirc_poll, - .open = ir_lirc_open, - .release = ir_lirc_close, - .llseek = no_llseek, -}; diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 2a0c48698309c..97d60f0b58366 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -22,11 +22,14 @@ #include #include #include +#include +#include #include "rc-core-priv.h" #include #define LOGHEAD "lirc_dev (%s[%d]): " +#define LIRCBUF_SIZE 256 static dev_t lirc_base_dev; @@ -36,6 +39,607 @@ static DEFINE_IDA(lirc_ida); /* Only used for sysfs but defined to void otherwise */ static struct class *lirc_class; +/** + * ir_lirc_raw_event() - Send raw IR data to lirc to be relayed to userspace + * + * @dev: the struct rc_dev descriptor of the device + * @ev: the struct ir_raw_event descriptor of the pulse/space + */ +void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) +{ + int sample; + + /* Packet start */ + if (ev.reset) { + /* + * Userspace expects a long space event before the start of + * the signal to use as a sync. This may be done with repeat + * packets and normal samples. But if a reset has been sent + * then we assume that a long time has passed, so we send a + * space with the maximum time value. + */ + sample = LIRC_SPACE(LIRC_VALUE_MASK); + IR_dprintk(2, "delivering reset sync space to lirc_dev\n"); + + /* Carrier reports */ + } else if (ev.carrier_report) { + sample = LIRC_FREQUENCY(ev.carrier); + IR_dprintk(2, "carrier report (freq: %d)\n", sample); + + /* Packet end */ + } else if (ev.timeout) { + if (dev->gap) + return; + + dev->gap_start = ktime_get(); + dev->gap = true; + dev->gap_duration = ev.duration; + + if (!dev->send_timeout_reports) + return; + + sample = LIRC_TIMEOUT(ev.duration / 1000); + IR_dprintk(2, "timeout report (duration: %d)\n", sample); + + /* Normal sample */ + } else { + if (dev->gap) { + dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), + dev->gap_start)); + + /* Convert to ms and cap by LIRC_VALUE_MASK */ + do_div(dev->gap_duration, 1000); + dev->gap_duration = min_t(u64, dev->gap_duration, + LIRC_VALUE_MASK); + + kfifo_put(&dev->rawir, LIRC_SPACE(dev->gap_duration)); + dev->gap = false; + } + + sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) : + LIRC_SPACE(ev.duration / 1000); + IR_dprintk(2, "delivering %uus %s to lirc_dev\n", + TO_US(ev.duration), TO_STR(ev.pulse)); + } + + kfifo_put(&dev->rawir, sample); + wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); +} + +/** + * ir_lirc_scancode_event() - Send scancode data to lirc to be relayed to + * userspace + * @dev: the struct rc_dev descriptor of the device + * @lsc: the struct lirc_scancode describing the decoded scancode + */ +void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc) +{ + lsc->timestamp = ktime_get_ns(); + + if (kfifo_put(&dev->scancodes, *lsc)) + wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); +} +EXPORT_SYMBOL_GPL(ir_lirc_scancode_event); + +static int ir_lirc_open(struct inode *inode, struct file *file) +{ + struct rc_dev *dev = container_of(inode->i_cdev, struct rc_dev, + lirc_cdev); + int retval; + + retval = rc_open(dev); + if (retval) + return retval; + + retval = mutex_lock_interruptible(&dev->lock); + if (retval) + goto out_rc; + + if (!dev->registered) { + retval = -ENODEV; + goto out_unlock; + } + + if (dev->lirc_open) { + retval = -EBUSY; + goto out_unlock; + } + + if (dev->driver_type == RC_DRIVER_IR_RAW) + kfifo_reset_out(&dev->rawir); + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_reset_out(&dev->scancodes); + + dev->lirc_open++; + file->private_data = dev; + + nonseekable_open(inode, file); + mutex_unlock(&dev->lock); + + return 0; + +out_unlock: + mutex_unlock(&dev->lock); +out_rc: + rc_close(dev); + return retval; +} + +static int ir_lirc_close(struct inode *inode, struct file *file) +{ + struct rc_dev *dev = file->private_data; + + mutex_lock(&dev->lock); + dev->lirc_open--; + mutex_unlock(&dev->lock); + + rc_close(dev); + + return 0; +} + +static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, + size_t n, loff_t *ppos) +{ + struct rc_dev *dev = file->private_data; + unsigned int *txbuf = NULL; + struct ir_raw_event *raw = NULL; + ssize_t ret = -EINVAL; + size_t count; + ktime_t start; + s64 towait; + unsigned int duration = 0; /* signal duration in us */ + int i; + + if (!dev->registered) + return -ENODEV; + + start = ktime_get(); + + if (!dev->tx_ir) { + ret = -EINVAL; + goto out; + } + + if (dev->send_mode == LIRC_MODE_SCANCODE) { + struct lirc_scancode scan; + + if (n != sizeof(scan)) + return -EINVAL; + + if (copy_from_user(&scan, buf, sizeof(scan))) + return -EFAULT; + + if (scan.flags || scan.keycode || scan.timestamp) + return -EINVAL; + + /* + * The scancode field in lirc_scancode is 64-bit simply + * to future-proof it, since there are IR protocols encode + * use more than 32 bits. For now only 32-bit protocols + * are supported. + */ + if (scan.scancode > U32_MAX || + !rc_validate_scancode(scan.rc_proto, scan.scancode)) + return -EINVAL; + + raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL); + if (!raw) + return -ENOMEM; + + ret = ir_raw_encode_scancode(scan.rc_proto, scan.scancode, + raw, LIRCBUF_SIZE); + if (ret < 0) + goto out; + + count = ret; + + txbuf = kmalloc_array(count, sizeof(unsigned int), GFP_KERNEL); + if (!txbuf) { + ret = -ENOMEM; + goto out; + } + + for (i = 0; i < count; i++) + /* Convert from NS to US */ + txbuf[i] = DIV_ROUND_UP(raw[i].duration, 1000); + + if (dev->s_tx_carrier) { + int carrier = ir_raw_encode_carrier(scan.rc_proto); + + if (carrier > 0) + dev->s_tx_carrier(dev, carrier); + } + } else { + if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) + return -EINVAL; + + count = n / sizeof(unsigned int); + if (count > LIRCBUF_SIZE || count % 2 == 0) + return -EINVAL; + + txbuf = memdup_user(buf, n); + if (IS_ERR(txbuf)) + return PTR_ERR(txbuf); + } + + for (i = 0; i < count; i++) { + if (txbuf[i] > IR_MAX_DURATION / 1000 - duration || !txbuf[i]) { + ret = -EINVAL; + goto out; + } + + duration += txbuf[i]; + } + + ret = dev->tx_ir(dev, txbuf, count); + if (ret < 0) + goto out; + + if (dev->send_mode == LIRC_MODE_SCANCODE) { + ret = n; + } else { + for (duration = i = 0; i < ret; i++) + duration += txbuf[i]; + + ret *= sizeof(unsigned int); + + /* + * The lircd gap calculation expects the write function to + * wait for the actual IR signal to be transmitted before + * returning. + */ + towait = ktime_us_delta(ktime_add_us(start, duration), + ktime_get()); + if (towait > 0) { + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(usecs_to_jiffies(towait)); + } + } + +out: + kfree(txbuf); + kfree(raw); + return ret; +} + +static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, + unsigned long arg) +{ + struct rc_dev *dev = filep->private_data; + u32 __user *argp = (u32 __user *)(arg); + int ret = 0; + __u32 val = 0, tmp; + + if (_IOC_DIR(cmd) & _IOC_WRITE) { + ret = get_user(val, argp); + if (ret) + return ret; + } + + if (!dev->registered) + return -ENODEV; + + switch (cmd) { + case LIRC_GET_FEATURES: + if (dev->driver_type == RC_DRIVER_SCANCODE) + val |= LIRC_CAN_REC_SCANCODE; + + if (dev->driver_type == RC_DRIVER_IR_RAW) { + val |= LIRC_CAN_REC_MODE2 | LIRC_CAN_REC_SCANCODE; + if (dev->rx_resolution) + val |= LIRC_CAN_GET_REC_RESOLUTION; + } + + if (dev->tx_ir) { + val |= LIRC_CAN_SEND_PULSE | LIRC_CAN_SEND_SCANCODE; + if (dev->s_tx_mask) + val |= LIRC_CAN_SET_TRANSMITTER_MASK; + if (dev->s_tx_carrier) + val |= LIRC_CAN_SET_SEND_CARRIER; + if (dev->s_tx_duty_cycle) + val |= LIRC_CAN_SET_SEND_DUTY_CYCLE; + } + + if (dev->s_rx_carrier_range) + val |= LIRC_CAN_SET_REC_CARRIER | + LIRC_CAN_SET_REC_CARRIER_RANGE; + + if (dev->s_learning_mode) + val |= LIRC_CAN_USE_WIDEBAND_RECEIVER; + + if (dev->s_carrier_report) + val |= LIRC_CAN_MEASURE_CARRIER; + + if (dev->max_timeout) + val |= LIRC_CAN_SET_REC_TIMEOUT; + + break; + + /* mode support */ + case LIRC_GET_REC_MODE: + if (dev->driver_type == RC_DRIVER_IR_RAW_TX) + return -ENOTTY; + + val = dev->rec_mode; + break; + + case LIRC_SET_REC_MODE: + switch (dev->driver_type) { + case RC_DRIVER_IR_RAW_TX: + return -ENOTTY; + case RC_DRIVER_SCANCODE: + if (val != LIRC_MODE_SCANCODE) + return -EINVAL; + break; + case RC_DRIVER_IR_RAW: + if (!(val == LIRC_MODE_MODE2 || + val == LIRC_MODE_SCANCODE)) + return -EINVAL; + break; + } + + dev->rec_mode = val; + return 0; + + case LIRC_GET_SEND_MODE: + if (!dev->tx_ir) + return -ENOTTY; + + val = dev->send_mode; + break; + + case LIRC_SET_SEND_MODE: + if (!dev->tx_ir) + return -ENOTTY; + + if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) + return -EINVAL; + + dev->send_mode = val; + return 0; + + /* TX settings */ + case LIRC_SET_TRANSMITTER_MASK: + if (!dev->s_tx_mask) + return -ENOTTY; + + return dev->s_tx_mask(dev, val); + + case LIRC_SET_SEND_CARRIER: + if (!dev->s_tx_carrier) + return -ENOTTY; + + return dev->s_tx_carrier(dev, val); + + case LIRC_SET_SEND_DUTY_CYCLE: + if (!dev->s_tx_duty_cycle) + return -ENOTTY; + + if (val <= 0 || val >= 100) + return -EINVAL; + + return dev->s_tx_duty_cycle(dev, val); + + /* RX settings */ + case LIRC_SET_REC_CARRIER: + if (!dev->s_rx_carrier_range) + return -ENOTTY; + + if (val <= 0) + return -EINVAL; + + return dev->s_rx_carrier_range(dev, + dev->carrier_low, + val); + + case LIRC_SET_REC_CARRIER_RANGE: + if (!dev->s_rx_carrier_range) + return -ENOTTY; + + if (val <= 0) + return -EINVAL; + + dev->carrier_low = val; + return 0; + + case LIRC_GET_REC_RESOLUTION: + if (!dev->rx_resolution) + return -ENOTTY; + + val = dev->rx_resolution / 1000; + break; + + case LIRC_SET_WIDEBAND_RECEIVER: + if (!dev->s_learning_mode) + return -ENOTTY; + + return dev->s_learning_mode(dev, !!val); + + case LIRC_SET_MEASURE_CARRIER_MODE: + if (!dev->s_carrier_report) + return -ENOTTY; + + return dev->s_carrier_report(dev, !!val); + + /* Generic timeout support */ + case LIRC_GET_MIN_TIMEOUT: + if (!dev->max_timeout) + return -ENOTTY; + val = DIV_ROUND_UP(dev->min_timeout, 1000); + break; + + case LIRC_GET_MAX_TIMEOUT: + if (!dev->max_timeout) + return -ENOTTY; + val = dev->max_timeout / 1000; + break; + + case LIRC_SET_REC_TIMEOUT: + if (!dev->max_timeout) + return -ENOTTY; + + /* Check for multiply overflow */ + if (val > U32_MAX / 1000) + return -EINVAL; + + tmp = val * 1000; + + if (tmp < dev->min_timeout || tmp > dev->max_timeout) + return -EINVAL; + + if (dev->s_timeout) + ret = dev->s_timeout(dev, tmp); + if (!ret) + dev->timeout = tmp; + break; + + case LIRC_SET_REC_TIMEOUT_REPORTS: + if (!dev->timeout) + return -ENOTTY; + + dev->send_timeout_reports = !!val; + break; + + default: + return -ENOTTY; + } + + if (_IOC_DIR(cmd) & _IOC_READ) + ret = put_user(val, argp); + + return ret; +} + +static unsigned int ir_lirc_poll(struct file *file, + struct poll_table_struct *wait) +{ + struct rc_dev *rcdev = file->private_data; + unsigned int events = 0; + + poll_wait(file, &rcdev->wait_poll, wait); + + if (!rcdev->registered) { + events = POLLHUP | POLLERR; + } else if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) { + if (rcdev->rec_mode == LIRC_MODE_SCANCODE && + !kfifo_is_empty(&rcdev->scancodes)) + events = POLLIN | POLLRDNORM; + + if (rcdev->rec_mode == LIRC_MODE_MODE2 && + !kfifo_is_empty(&rcdev->rawir)) + events = POLLIN | POLLRDNORM; + } + + return events; +} + +static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, + size_t length) +{ + struct rc_dev *rcdev = file->private_data; + unsigned int copied; + int ret; + + if (length < sizeof(unsigned int) || length % sizeof(unsigned int)) + return -EINVAL; + + do { + if (kfifo_is_empty(&rcdev->rawir)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible(rcdev->wait_poll, + !kfifo_is_empty(&rcdev->rawir) || + !rcdev->registered); + if (ret) + return ret; + } + + if (!rcdev->registered) + return -ENODEV; + + ret = mutex_lock_interruptible(&rcdev->lock); + if (ret) + return ret; + ret = kfifo_to_user(&rcdev->rawir, buffer, length, &copied); + mutex_unlock(&rcdev->lock); + if (ret) + return ret; + } while (copied == 0); + + return copied; +} + +static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, + size_t length) +{ + struct rc_dev *rcdev = file->private_data; + unsigned int copied; + int ret; + + if (length < sizeof(struct lirc_scancode) || + length % sizeof(struct lirc_scancode)) + return -EINVAL; + + do { + if (kfifo_is_empty(&rcdev->scancodes)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible(rcdev->wait_poll, + !kfifo_is_empty(&rcdev->scancodes) || + !rcdev->registered); + if (ret) + return ret; + } + + if (!rcdev->registered) + return -ENODEV; + + ret = mutex_lock_interruptible(&rcdev->lock); + if (ret) + return ret; + ret = kfifo_to_user(&rcdev->scancodes, buffer, length, &copied); + mutex_unlock(&rcdev->lock); + if (ret) + return ret; + } while (copied == 0); + + return copied; +} + +static ssize_t ir_lirc_read(struct file *file, char __user *buffer, + size_t length, loff_t *ppos) +{ + struct rc_dev *rcdev = file->private_data; + + if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) + return -EINVAL; + + if (!rcdev->registered) + return -ENODEV; + + if (rcdev->rec_mode == LIRC_MODE_MODE2) + return ir_lirc_read_mode2(file, buffer, length); + else /* LIRC_MODE_SCANCODE */ + return ir_lirc_read_scancode(file, buffer, length); +} + +static const struct file_operations lirc_fops = { + .owner = THIS_MODULE, + .write = ir_lirc_transmit_ir, + .unlocked_ioctl = ir_lirc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ir_lirc_ioctl, +#endif + .read = ir_lirc_read, + .poll = ir_lirc_poll, + .open = ir_lirc_open, + .release = ir_lirc_close, + .llseek = no_llseek, +}; + static void lirc_release_device(struct device *ld) { struct rc_dev *rcdev = container_of(ld, struct rc_dev, lirc_dev); diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 2a5e9cc3ddb31..915434855a63a 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -279,8 +279,6 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev); void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc); int ir_lirc_register(struct rc_dev *dev); void ir_lirc_unregister(struct rc_dev *dev); - -extern const struct file_operations lirc_fops; #else static inline int lirc_dev_init(void) { return 0; } static inline void lirc_dev_exit(void) {} -- GitLab From aefb5e3434db4a98f30fee460b0d8885aad0f456 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 2 Nov 2017 16:44:21 -0400 Subject: [PATCH 0216/1190] media: rc: include rather than This removes the need for include/media/lirc.h, which just includes the uapi file. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/lirc_dev.c | 2 +- include/media/lirc.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 include/media/lirc.h diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 97d60f0b58366..8a0e9f74329ad 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -26,7 +26,7 @@ #include #include "rc-core-priv.h" -#include +#include #define LOGHEAD "lirc_dev (%s[%d]): " #define LIRCBUF_SIZE 256 diff --git a/include/media/lirc.h b/include/media/lirc.h deleted file mode 100644 index 554988c860c1e..0000000000000 --- a/include/media/lirc.h +++ /dev/null @@ -1 +0,0 @@ -#include -- GitLab From 7e45d660e4d487aa2cbeb003bd4338433feba30a Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 2 Nov 2017 17:21:13 -0400 Subject: [PATCH 0217/1190] media: lirc: allow lirc device to be opened more than once This makes it possible for lircd to read from a lirc chardev, and not keep it busy. Note that this changes the default for timeout reports to on. lircd already enables timeout reports when it opens a lirc device, leaving them on until the next reboot. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/lirc_dev.c | 247 +++++++++++++++++++----------------- include/media/rc-core.h | 50 +++++--- 2 files changed, 165 insertions(+), 132 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 8a0e9f74329ad..7b9246fb96525 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -28,7 +28,6 @@ #include "rc-core-priv.h" #include -#define LOGHEAD "lirc_dev (%s[%d]): " #define LIRCBUF_SIZE 256 static dev_t lirc_base_dev; @@ -47,6 +46,8 @@ static struct class *lirc_class; */ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) { + unsigned long flags; + struct lirc_fh *fh; int sample; /* Packet start */ @@ -75,9 +76,6 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) dev->gap = true; dev->gap_duration = ev.duration; - if (!dev->send_timeout_reports) - return; - sample = LIRC_TIMEOUT(ev.duration / 1000); IR_dprintk(2, "timeout report (duration: %d)\n", sample); @@ -92,7 +90,11 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) dev->gap_duration = min_t(u64, dev->gap_duration, LIRC_VALUE_MASK); - kfifo_put(&dev->rawir, LIRC_SPACE(dev->gap_duration)); + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_for_each_entry(fh, &dev->lirc_fh, list) + kfifo_put(&fh->rawir, + LIRC_SPACE(dev->gap_duration)); + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); dev->gap = false; } @@ -102,22 +104,35 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) TO_US(ev.duration), TO_STR(ev.pulse)); } - kfifo_put(&dev->rawir, sample); - wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_for_each_entry(fh, &dev->lirc_fh, list) { + if (LIRC_IS_TIMEOUT(sample) && !fh->send_timeout_reports) + continue; + if (kfifo_put(&fh->rawir, sample)) + wake_up_poll(&fh->wait_poll, POLLIN | POLLRDNORM); + } + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); } /** * ir_lirc_scancode_event() - Send scancode data to lirc to be relayed to - * userspace + * userspace. This can be called in atomic context. * @dev: the struct rc_dev descriptor of the device * @lsc: the struct lirc_scancode describing the decoded scancode */ void ir_lirc_scancode_event(struct rc_dev *dev, struct lirc_scancode *lsc) { + unsigned long flags; + struct lirc_fh *fh; + lsc->timestamp = ktime_get_ns(); - if (kfifo_put(&dev->scancodes, *lsc)) - wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM); + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_for_each_entry(fh, &dev->lirc_fh, list) { + if (kfifo_put(&fh->scancodes, *lsc)) + wake_up_poll(&fh->wait_poll, POLLIN | POLLRDNORM); + } + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); } EXPORT_SYMBOL_GPL(ir_lirc_scancode_event); @@ -125,55 +140,88 @@ static int ir_lirc_open(struct inode *inode, struct file *file) { struct rc_dev *dev = container_of(inode->i_cdev, struct rc_dev, lirc_cdev); + struct lirc_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL); + unsigned long flags; int retval; - retval = rc_open(dev); - if (retval) - return retval; + if (!fh) + return -ENOMEM; - retval = mutex_lock_interruptible(&dev->lock); - if (retval) - goto out_rc; + get_device(&dev->dev); if (!dev->registered) { retval = -ENODEV; - goto out_unlock; + goto out_fh; } - if (dev->lirc_open) { - retval = -EBUSY; - goto out_unlock; + if (dev->driver_type == RC_DRIVER_IR_RAW) { + if (kfifo_alloc(&fh->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) { + retval = -ENOMEM; + goto out_fh; + } } - if (dev->driver_type == RC_DRIVER_IR_RAW) - kfifo_reset_out(&dev->rawir); - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) - kfifo_reset_out(&dev->scancodes); + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { + if (kfifo_alloc(&fh->scancodes, 32, GFP_KERNEL)) { + retval = -ENOMEM; + goto out_rawir; + } + } + + fh->send_mode = LIRC_MODE_PULSE; + fh->rc = dev; + fh->send_timeout_reports = true; + + if (dev->driver_type == RC_DRIVER_SCANCODE) + fh->rec_mode = LIRC_MODE_SCANCODE; + else + fh->rec_mode = LIRC_MODE_MODE2; + + retval = rc_open(dev); + if (retval) + goto out_kfifo; + + init_waitqueue_head(&fh->wait_poll); - dev->lirc_open++; - file->private_data = dev; + file->private_data = fh; + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_add(&fh->list, &dev->lirc_fh); + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); nonseekable_open(inode, file); - mutex_unlock(&dev->lock); return 0; +out_kfifo: + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_free(&fh->scancodes); +out_rawir: + if (dev->driver_type == RC_DRIVER_IR_RAW) + kfifo_free(&fh->rawir); +out_fh: + kfree(fh); + put_device(&dev->dev); -out_unlock: - mutex_unlock(&dev->lock); -out_rc: - rc_close(dev); return retval; } static int ir_lirc_close(struct inode *inode, struct file *file) { - struct rc_dev *dev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *dev = fh->rc; + unsigned long flags; - mutex_lock(&dev->lock); - dev->lirc_open--; - mutex_unlock(&dev->lock); + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_del(&fh->list); + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); + + if (dev->driver_type == RC_DRIVER_IR_RAW) + kfifo_free(&fh->rawir); + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) + kfifo_free(&fh->scancodes); + kfree(fh); rc_close(dev); + put_device(&dev->dev); return 0; } @@ -181,7 +229,8 @@ static int ir_lirc_close(struct inode *inode, struct file *file) static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, size_t n, loff_t *ppos) { - struct rc_dev *dev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *dev = fh->rc; unsigned int *txbuf = NULL; struct ir_raw_event *raw = NULL; ssize_t ret = -EINVAL; @@ -201,7 +250,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, goto out; } - if (dev->send_mode == LIRC_MODE_SCANCODE) { + if (fh->send_mode == LIRC_MODE_SCANCODE) { struct lirc_scancode scan; if (n != sizeof(scan)) @@ -276,7 +325,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (ret < 0) goto out; - if (dev->send_mode == LIRC_MODE_SCANCODE) { + if (fh->send_mode == LIRC_MODE_SCANCODE) { ret = n; } else { for (duration = i = 0; i < ret; i++) @@ -303,10 +352,11 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, return ret; } -static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, +static long ir_lirc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct rc_dev *dev = filep->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *dev = fh->rc; u32 __user *argp = (u32 __user *)(arg); int ret = 0; __u32 val = 0, tmp; @@ -361,7 +411,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (dev->driver_type == RC_DRIVER_IR_RAW_TX) return -ENOTTY; - val = dev->rec_mode; + val = fh->rec_mode; break; case LIRC_SET_REC_MODE: @@ -379,14 +429,14 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, break; } - dev->rec_mode = val; + fh->rec_mode = val; return 0; case LIRC_GET_SEND_MODE: if (!dev->tx_ir) return -ENOTTY; - val = dev->send_mode; + val = fh->send_mode; break; case LIRC_SET_SEND_MODE: @@ -396,7 +446,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) return -EINVAL; - dev->send_mode = val; + fh->send_mode = val; return 0; /* TX settings */ @@ -430,7 +480,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, return -EINVAL; return dev->s_rx_carrier_range(dev, - dev->carrier_low, + fh->carrier_low, val); case LIRC_SET_REC_CARRIER_RANGE: @@ -440,7 +490,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (val <= 0) return -EINVAL; - dev->carrier_low = val; + fh->carrier_low = val; return 0; case LIRC_GET_REC_RESOLUTION: @@ -498,7 +548,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!dev->timeout) return -ENOTTY; - dev->send_timeout_reports = !!val; + fh->send_timeout_reports = !!val; break; default: @@ -514,20 +564,21 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, static unsigned int ir_lirc_poll(struct file *file, struct poll_table_struct *wait) { - struct rc_dev *rcdev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *rcdev = fh->rc; unsigned int events = 0; - poll_wait(file, &rcdev->wait_poll, wait); + poll_wait(file, &fh->wait_poll, wait); if (!rcdev->registered) { events = POLLHUP | POLLERR; } else if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) { - if (rcdev->rec_mode == LIRC_MODE_SCANCODE && - !kfifo_is_empty(&rcdev->scancodes)) + if (fh->rec_mode == LIRC_MODE_SCANCODE && + !kfifo_is_empty(&fh->scancodes)) events = POLLIN | POLLRDNORM; - if (rcdev->rec_mode == LIRC_MODE_MODE2 && - !kfifo_is_empty(&rcdev->rawir)) + if (fh->rec_mode == LIRC_MODE_MODE2 && + !kfifo_is_empty(&fh->rawir)) events = POLLIN | POLLRDNORM; } @@ -537,7 +588,8 @@ static unsigned int ir_lirc_poll(struct file *file, static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, size_t length) { - struct rc_dev *rcdev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *rcdev = fh->rc; unsigned int copied; int ret; @@ -545,12 +597,12 @@ static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, return -EINVAL; do { - if (kfifo_is_empty(&rcdev->rawir)) { + if (kfifo_is_empty(&fh->rawir)) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; - ret = wait_event_interruptible(rcdev->wait_poll, - !kfifo_is_empty(&rcdev->rawir) || + ret = wait_event_interruptible(fh->wait_poll, + !kfifo_is_empty(&fh->rawir) || !rcdev->registered); if (ret) return ret; @@ -562,7 +614,7 @@ static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, ret = mutex_lock_interruptible(&rcdev->lock); if (ret) return ret; - ret = kfifo_to_user(&rcdev->rawir, buffer, length, &copied); + ret = kfifo_to_user(&fh->rawir, buffer, length, &copied); mutex_unlock(&rcdev->lock); if (ret) return ret; @@ -574,7 +626,8 @@ static ssize_t ir_lirc_read_mode2(struct file *file, char __user *buffer, static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, size_t length) { - struct rc_dev *rcdev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *rcdev = fh->rc; unsigned int copied; int ret; @@ -583,12 +636,12 @@ static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, return -EINVAL; do { - if (kfifo_is_empty(&rcdev->scancodes)) { + if (kfifo_is_empty(&fh->scancodes)) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; - ret = wait_event_interruptible(rcdev->wait_poll, - !kfifo_is_empty(&rcdev->scancodes) || + ret = wait_event_interruptible(fh->wait_poll, + !kfifo_is_empty(&fh->scancodes) || !rcdev->registered); if (ret) return ret; @@ -600,7 +653,7 @@ static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, ret = mutex_lock_interruptible(&rcdev->lock); if (ret) return ret; - ret = kfifo_to_user(&rcdev->scancodes, buffer, length, &copied); + ret = kfifo_to_user(&fh->scancodes, buffer, length, &copied); mutex_unlock(&rcdev->lock); if (ret) return ret; @@ -612,7 +665,8 @@ static ssize_t ir_lirc_read_scancode(struct file *file, char __user *buffer, static ssize_t ir_lirc_read(struct file *file, char __user *buffer, size_t length, loff_t *ppos) { - struct rc_dev *rcdev = file->private_data; + struct lirc_fh *fh = file->private_data; + struct rc_dev *rcdev = fh->rc; if (rcdev->driver_type == RC_DRIVER_IR_RAW_TX) return -EINVAL; @@ -620,7 +674,7 @@ static ssize_t ir_lirc_read(struct file *file, char __user *buffer, if (!rcdev->registered) return -ENODEV; - if (rcdev->rec_mode == LIRC_MODE_MODE2) + if (fh->rec_mode == LIRC_MODE_MODE2) return ir_lirc_read_mode2(file, buffer, length); else /* LIRC_MODE_SCANCODE */ return ir_lirc_read_scancode(file, buffer, length); @@ -644,11 +698,6 @@ static void lirc_release_device(struct device *ld) { struct rc_dev *rcdev = container_of(ld, struct rc_dev, lirc_dev); - if (rcdev->driver_type == RC_DRIVER_IR_RAW) - kfifo_free(&rcdev->rawir); - if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX) - kfifo_free(&rcdev->scancodes); - put_device(&rcdev->dev); } @@ -656,40 +705,20 @@ int ir_lirc_register(struct rc_dev *dev) { int err, minor; - device_initialize(&dev->lirc_dev); - dev->lirc_dev.class = lirc_class; - dev->lirc_dev.release = lirc_release_device; - dev->send_mode = LIRC_MODE_PULSE; - - if (dev->driver_type == RC_DRIVER_SCANCODE) - dev->rec_mode = LIRC_MODE_SCANCODE; - else - dev->rec_mode = LIRC_MODE_MODE2; - - if (dev->driver_type == RC_DRIVER_IR_RAW) { - if (kfifo_alloc(&dev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL)) - return -ENOMEM; - } - - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { - if (kfifo_alloc(&dev->scancodes, 32, GFP_KERNEL)) { - kfifo_free(&dev->rawir); - return -ENOMEM; - } - } - - init_waitqueue_head(&dev->wait_poll); - minor = ida_simple_get(&lirc_ida, 0, RC_DEV_MAX, GFP_KERNEL); - if (minor < 0) { - err = minor; - goto out_kfifo; - } + if (minor < 0) + return minor; + device_initialize(&dev->lirc_dev); + dev->lirc_dev.class = lirc_class; dev->lirc_dev.parent = &dev->dev; + dev->lirc_dev.release = lirc_release_device; dev->lirc_dev.devt = MKDEV(MAJOR(lirc_base_dev), minor); dev_set_name(&dev->lirc_dev, "lirc%d", minor); + INIT_LIST_HEAD(&dev->lirc_fh); + spin_lock_init(&dev->lirc_fh_lock); + cdev_init(&dev->lirc_cdev, &lirc_fops); err = cdev_device_add(&dev->lirc_cdev, &dev->lirc_dev); @@ -705,32 +734,24 @@ int ir_lirc_register(struct rc_dev *dev) out_ida: ida_simple_remove(&lirc_ida, minor); -out_kfifo: - if (dev->driver_type == RC_DRIVER_IR_RAW) - kfifo_free(&dev->rawir); - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) - kfifo_free(&dev->scancodes); return err; } void ir_lirc_unregister(struct rc_dev *dev) { + unsigned long flags; + struct lirc_fh *fh; + dev_dbg(&dev->dev, "lirc_dev: driver %s unregistered from minor = %d\n", dev->driver_name, MINOR(dev->lirc_dev.devt)); - mutex_lock(&dev->lock); - - if (dev->lirc_open) { - dev_dbg(&dev->dev, LOGHEAD "releasing opened driver\n", - dev->driver_name, MINOR(dev->lirc_dev.devt)); - wake_up_poll(&dev->wait_poll, POLLHUP); - } - - mutex_unlock(&dev->lock); + spin_lock_irqsave(&dev->lirc_fh_lock, flags); + list_for_each_entry(fh, &dev->lirc_fh, list) + wake_up_poll(&fh->wait_poll, POLLHUP | POLLERR); + spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); cdev_device_del(&dev->lirc_cdev, &dev->lirc_dev); ida_simple_remove(&lirc_ida, MINOR(dev->lirc_dev.devt)); - put_device(&dev->lirc_dev); } int __init lirc_dev_init(void) diff --git a/include/media/rc-core.h b/include/media/rc-core.h index fbf1648d2ec95..3a47a25a65930 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -68,6 +68,33 @@ enum rc_filter_type { RC_FILTER_MAX }; +/** + * struct lirc_fh - represents an open lirc file + * @list: list of open file handles + * @rc: rcdev for this lirc chardev + * @carrier_low: when setting the carrier range, first the low end must be + * set with an ioctl and then the high end with another ioctl + * @send_timeout_reports: report timeouts in lirc raw IR. + * @rawir: queue for incoming raw IR + * @scancodes: queue for incoming decoded scancodes + * @wait_poll: poll struct for lirc device + * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or + * LIRC_MODE_PULSE + * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or + * LIRC_MODE_MODE2 + */ +struct lirc_fh { + struct list_head list; + struct rc_dev *rc; + int carrier_low; + bool send_timeout_reports; + DECLARE_KFIFO_PTR(rawir, unsigned int); + DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); + wait_queue_head_t wait_poll; + u8 send_mode; + u8 rec_mode; +}; + /** * struct rc_dev - represents a remote control device * @dev: driver model's view of this device @@ -118,20 +145,11 @@ enum rc_filter_type { * @tx_resolution: resolution (in ns) of output sampler * @lirc_dev: lirc device * @lirc_cdev: lirc char cdev - * @lirc_open: count of the number of times the device has been opened - * @carrier_low: when setting the carrier range, first the low end must be - * set with an ioctl and then the high end with another ioctl * @gap_start: time when gap starts * @gap_duration: duration of initial gap * @gap: true if we're in a gap - * @send_timeout_reports: report timeouts in lirc raw IR. - * @rawir: queue for incoming raw IR - * @scancodes: queue for incoming decoded scancodes - * @wait_poll: poll struct for lirc device - * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or - * LIRC_MODE_PULSE - * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or - * LIRC_MODE_MODE2 + * @lirc_fh_lock: protects lirc_fh list + * @lirc_fh: list of open files * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders @@ -196,17 +214,11 @@ struct rc_dev { #ifdef CONFIG_LIRC struct device lirc_dev; struct cdev lirc_cdev; - int lirc_open; - int carrier_low; ktime_t gap_start; u64 gap_duration; bool gap; - bool send_timeout_reports; - DECLARE_KFIFO_PTR(rawir, unsigned int); - DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); - wait_queue_head_t wait_poll; - u8 send_mode; - u8 rec_mode; + spinlock_t lirc_fh_lock; + struct list_head lirc_fh; #endif bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- GitLab From 4957133fe32fec9a5fc57ce95b6107e976dcc251 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 4 Nov 2017 08:30:45 -0400 Subject: [PATCH 0218/1190] media: lirc: improve locking Once rc_unregister_device() has been called, no driver function should be called. This prevents some nasty race conditions with an ioctl calls driver functions when the driver specific data has been freed. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/lirc_dev.c | 239 +++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 102 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 7b9246fb96525..218658917cf62 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -233,15 +233,21 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, struct rc_dev *dev = fh->rc; unsigned int *txbuf = NULL; struct ir_raw_event *raw = NULL; - ssize_t ret = -EINVAL; + ssize_t ret; size_t count; ktime_t start; s64 towait; unsigned int duration = 0; /* signal duration in us */ int i; - if (!dev->registered) - return -ENODEV; + ret = mutex_lock_interruptible(&dev->lock); + if (ret) + return ret; + + if (!dev->registered) { + ret = -ENODEV; + goto out; + } start = ktime_get(); @@ -253,14 +259,20 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, if (fh->send_mode == LIRC_MODE_SCANCODE) { struct lirc_scancode scan; - if (n != sizeof(scan)) - return -EINVAL; + if (n != sizeof(scan)) { + ret = -EINVAL; + goto out; + } - if (copy_from_user(&scan, buf, sizeof(scan))) - return -EFAULT; + if (copy_from_user(&scan, buf, sizeof(scan))) { + ret = -EFAULT; + goto out; + } - if (scan.flags || scan.keycode || scan.timestamp) - return -EINVAL; + if (scan.flags || scan.keycode || scan.timestamp) { + ret = -EINVAL; + goto out; + } /* * The scancode field in lirc_scancode is 64-bit simply @@ -269,12 +281,16 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, * are supported. */ if (scan.scancode > U32_MAX || - !rc_validate_scancode(scan.rc_proto, scan.scancode)) - return -EINVAL; + !rc_validate_scancode(scan.rc_proto, scan.scancode)) { + ret = -EINVAL; + goto out; + } raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL); - if (!raw) - return -ENOMEM; + if (!raw) { + ret = -ENOMEM; + goto out; + } ret = ir_raw_encode_scancode(scan.rc_proto, scan.scancode, raw, LIRCBUF_SIZE); @@ -300,16 +316,22 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, dev->s_tx_carrier(dev, carrier); } } else { - if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) - return -EINVAL; + if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) { + ret = -EINVAL; + goto out; + } count = n / sizeof(unsigned int); - if (count > LIRCBUF_SIZE || count % 2 == 0) - return -EINVAL; + if (count > LIRCBUF_SIZE || count % 2 == 0) { + ret = -EINVAL; + goto out; + } txbuf = memdup_user(buf, n); - if (IS_ERR(txbuf)) - return PTR_ERR(txbuf); + if (IS_ERR(txbuf)) { + ret = PTR_ERR(txbuf); + goto out; + } } for (i = 0; i < count; i++) { @@ -347,6 +369,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, } out: + mutex_unlock(&dev->lock); kfree(txbuf); kfree(raw); return ret; @@ -358,8 +381,8 @@ static long ir_lirc_ioctl(struct file *file, unsigned int cmd, struct lirc_fh *fh = file->private_data; struct rc_dev *dev = fh->rc; u32 __user *argp = (u32 __user *)(arg); - int ret = 0; - __u32 val = 0, tmp; + u32 val = 0; + int ret; if (_IOC_DIR(cmd) & _IOC_WRITE) { ret = get_user(val, argp); @@ -367,8 +390,14 @@ static long ir_lirc_ioctl(struct file *file, unsigned int cmd, return ret; } - if (!dev->registered) - return -ENODEV; + ret = mutex_lock_interruptible(&dev->lock); + if (ret) + return ret; + + if (!dev->registered) { + ret = -ENODEV; + goto out; + } switch (cmd) { case LIRC_GET_FEATURES: @@ -409,155 +438,161 @@ static long ir_lirc_ioctl(struct file *file, unsigned int cmd, /* mode support */ case LIRC_GET_REC_MODE: if (dev->driver_type == RC_DRIVER_IR_RAW_TX) - return -ENOTTY; - - val = fh->rec_mode; + ret = -ENOTTY; + else + val = fh->rec_mode; break; case LIRC_SET_REC_MODE: switch (dev->driver_type) { case RC_DRIVER_IR_RAW_TX: - return -ENOTTY; + ret = -ENOTTY; + break; case RC_DRIVER_SCANCODE: if (val != LIRC_MODE_SCANCODE) - return -EINVAL; + ret = -EINVAL; break; case RC_DRIVER_IR_RAW: if (!(val == LIRC_MODE_MODE2 || val == LIRC_MODE_SCANCODE)) - return -EINVAL; + ret = -EINVAL; break; } - fh->rec_mode = val; - return 0; + if (!ret) + fh->rec_mode = val; + break; case LIRC_GET_SEND_MODE: if (!dev->tx_ir) - return -ENOTTY; - - val = fh->send_mode; + ret = -ENOTTY; + else + val = fh->send_mode; break; case LIRC_SET_SEND_MODE: if (!dev->tx_ir) - return -ENOTTY; - - if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) - return -EINVAL; - - fh->send_mode = val; - return 0; + ret = -ENOTTY; + else if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) + ret = -EINVAL; + else + fh->send_mode = val; + break; /* TX settings */ case LIRC_SET_TRANSMITTER_MASK: if (!dev->s_tx_mask) - return -ENOTTY; - - return dev->s_tx_mask(dev, val); + ret = -ENOTTY; + else + ret = dev->s_tx_mask(dev, val); + break; case LIRC_SET_SEND_CARRIER: if (!dev->s_tx_carrier) - return -ENOTTY; - - return dev->s_tx_carrier(dev, val); + ret = -ENOTTY; + else + ret = dev->s_tx_carrier(dev, val); + break; case LIRC_SET_SEND_DUTY_CYCLE: if (!dev->s_tx_duty_cycle) - return -ENOTTY; - - if (val <= 0 || val >= 100) - return -EINVAL; - - return dev->s_tx_duty_cycle(dev, val); + ret = -ENOTTY; + else if (val <= 0 || val >= 100) + ret = -EINVAL; + else + ret = dev->s_tx_duty_cycle(dev, val); + break; /* RX settings */ case LIRC_SET_REC_CARRIER: if (!dev->s_rx_carrier_range) - return -ENOTTY; - - if (val <= 0) - return -EINVAL; - - return dev->s_rx_carrier_range(dev, - fh->carrier_low, - val); + ret = -ENOTTY; + else if (val <= 0) + ret = -EINVAL; + else + ret = dev->s_rx_carrier_range(dev, fh->carrier_low, + val); + break; case LIRC_SET_REC_CARRIER_RANGE: if (!dev->s_rx_carrier_range) - return -ENOTTY; - - if (val <= 0) - return -EINVAL; - - fh->carrier_low = val; - return 0; + ret = -ENOTTY; + else if (val <= 0) + ret = -EINVAL; + else + fh->carrier_low = val; + break; case LIRC_GET_REC_RESOLUTION: if (!dev->rx_resolution) - return -ENOTTY; - - val = dev->rx_resolution / 1000; + ret = -ENOTTY; + else + val = dev->rx_resolution / 1000; break; case LIRC_SET_WIDEBAND_RECEIVER: if (!dev->s_learning_mode) - return -ENOTTY; - - return dev->s_learning_mode(dev, !!val); + ret = -ENOTTY; + else + ret = dev->s_learning_mode(dev, !!val); + break; case LIRC_SET_MEASURE_CARRIER_MODE: if (!dev->s_carrier_report) - return -ENOTTY; - - return dev->s_carrier_report(dev, !!val); + ret = -ENOTTY; + else + ret = dev->s_carrier_report(dev, !!val); + break; /* Generic timeout support */ case LIRC_GET_MIN_TIMEOUT: if (!dev->max_timeout) - return -ENOTTY; - val = DIV_ROUND_UP(dev->min_timeout, 1000); + ret = -ENOTTY; + else + val = DIV_ROUND_UP(dev->min_timeout, 1000); break; case LIRC_GET_MAX_TIMEOUT: if (!dev->max_timeout) - return -ENOTTY; - val = dev->max_timeout / 1000; + ret = -ENOTTY; + else + val = dev->max_timeout / 1000; break; case LIRC_SET_REC_TIMEOUT: - if (!dev->max_timeout) - return -ENOTTY; - - /* Check for multiply overflow */ - if (val > U32_MAX / 1000) - return -EINVAL; - - tmp = val * 1000; - - if (tmp < dev->min_timeout || tmp > dev->max_timeout) - return -EINVAL; - - if (dev->s_timeout) - ret = dev->s_timeout(dev, tmp); - if (!ret) - dev->timeout = tmp; + if (!dev->max_timeout) { + ret = -ENOTTY; + } else if (val > U32_MAX / 1000) { + /* Check for multiply overflow */ + ret = -EINVAL; + } else { + u32 tmp = val * 1000; + + if (tmp < dev->min_timeout || tmp > dev->max_timeout) + ret = -EINVAL; + else if (dev->s_timeout) + ret = dev->s_timeout(dev, tmp); + else if (!ret) + dev->timeout = tmp; + } break; case LIRC_SET_REC_TIMEOUT_REPORTS: if (!dev->timeout) - return -ENOTTY; - - fh->send_timeout_reports = !!val; + ret = -ENOTTY; + else + fh->send_timeout_reports = !!val; break; default: - return -ENOTTY; + ret = -ENOTTY; } - if (_IOC_DIR(cmd) & _IOC_READ) + if (!ret && _IOC_DIR(cmd) & _IOC_READ) ret = put_user(val, argp); +out: + mutex_unlock(&dev->lock); return ret; } -- GitLab From 1edba6484b19d288e11722d72b55a4b919fb059e Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Mon, 6 Nov 2017 09:06:10 -0500 Subject: [PATCH 0219/1190] media: rc: Replace timeval with ktime_t in imon.c This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of all uses of timeval in imon.c This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. Signed-off-by: Chunyan Zhang Signed-off-by: Arnd Bergmann Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/imon.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index eb943e862515d..c7a19a8fa77e5 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,6 @@ #include #include -#include #include #define MOD_AUTHOR "Jarod Wilson " @@ -1201,16 +1201,16 @@ static inline int tv2int(const struct timeval *a, const struct timeval *b) */ static int stabilize(int a, int b, u16 timeout, u16 threshold) { - struct timeval ct; - static struct timeval prev_time = {0, 0}; - static struct timeval hit_time = {0, 0}; + ktime_t ct; + static ktime_t prev_time; + static ktime_t hit_time; static int x, y, prev_result, hits; int result = 0; - int msec, msec_hit; + long msec, msec_hit; - do_gettimeofday(&ct); - msec = tv2int(&ct, &prev_time); - msec_hit = tv2int(&ct, &hit_time); + ct = ktime_get(); + msec = ktime_ms_delta(ct, prev_time); + msec_hit = ktime_ms_delta(ct, hit_time); if (msec > 100) { x = 0; @@ -1688,9 +1688,9 @@ static void imon_incoming_scancode(struct imon_context *ictx, u32 kc; u64 scancode; int press_type = 0; - int msec; - struct timeval t; - static struct timeval prev_time = { 0, 0 }; + long msec; + ktime_t t; + static ktime_t prev_time; u8 ktype; /* filter out junk data on the older 0xffdc imon devices */ @@ -1783,10 +1783,10 @@ static void imon_incoming_scancode(struct imon_context *ictx, /* Only panel type events left to process now */ spin_lock_irqsave(&ictx->kc_lock, flags); - do_gettimeofday(&t); + t = ktime_get(); /* KEY_MUTE repeats from knob need to be suppressed */ if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { - msec = tv2int(&t, &prev_time); + msec = ktime_ms_delta(t, prev_time); if (msec < ictx->idev->rep[REP_DELAY]) { spin_unlock_irqrestore(&ictx->kc_lock, flags); return; -- GitLab From 621fa19a2485ca6f4612b3c044766bc173551d76 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 15 Nov 2017 23:37:51 -0500 Subject: [PATCH 0220/1190] media: winbond-cir: Fix pnp_irq's error checking for wbcir_probe The pnp_irq() function returns -1 if an error occurs. pnp_irq() error checking for zero is not correct. Signed-off-by: Arvind Yadav Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/winbond-cir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 3ca7ab48293de..0adf0991f5abe 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -1044,7 +1044,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) data->irq = pnp_irq(device, 0); if (data->wbase == 0 || data->ebase == 0 || - data->sbase == 0 || data->irq == 0) { + data->sbase == 0 || data->irq == -1) { err = -ENODEV; dev_err(dev, "Invalid resources\n"); goto exit_free_data; -- GitLab From 6d4a36d183fe1ca051961e1e4a79853427605a01 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 21 Nov 2017 15:51:39 -0500 Subject: [PATCH 0221/1190] media: imon: auto-config ffdc 30 device Another device with the 0xffdc device id, this one with 0x30 in the config byte. Its an iMON VFD + iMON IR (it does not understand rc6). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/imon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index c7a19a8fa77e5..2c26d917fe0fe 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -1956,6 +1956,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx) break; /* iMON VFD, iMON IR */ case 0x24: + case 0x30: case 0x85: dev_info(ictx->dev, "0xffdc iMON VFD, iMON IR"); detected_display_type = IMON_DISPLAY_TYPE_VFD; -- GitLab From 57c642cb45d6f7d0d950c3bc67439989062ac743 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 23 Nov 2017 17:37:10 -0500 Subject: [PATCH 0222/1190] media: cec: move cec autorepeat handling to rc-core CEC autorepeat is different than other protocols. Autorepeat is triggered by the first repeated user control pressed CEC message, rather than a fixed REP_DELAY. This change also does away with the KEY_UP event directly after the first KEY_DOWN event, which was used to stop autorepeat from starting. See commit a9a249a2c997 ("media: cec: fix remote control passthrough") for the original change. Acked-by: Hans Verkuil Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/cec/cec-adap.c | 56 ++++-------------------------------- drivers/media/cec/cec-core.c | 12 -------- drivers/media/rc/rc-main.c | 49 ++++++++++++++++++++++++++++++- include/media/cec.h | 5 ---- include/media/rc-core.h | 3 ++ 5 files changed, 56 insertions(+), 69 deletions(-) diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 2a097e016414e..2b1e540587d6a 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -1788,9 +1788,6 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, int la_idx = cec_log_addr2idx(adap, dest_laddr); bool from_unregistered = init_laddr == 0xf; struct cec_msg tx_cec_msg = { }; -#ifdef CONFIG_MEDIA_CEC_RC - int scancode; -#endif dprintk(2, "%s: %*ph\n", __func__, msg->len, msg->msg); @@ -1886,9 +1883,11 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, */ case 0x60: if (msg->len == 2) - scancode = msg->msg[2]; + rc_keydown(adap->rc, RC_PROTO_CEC, + msg->msg[2], 0); else - scancode = msg->msg[2] << 8 | msg->msg[3]; + rc_keydown(adap->rc, RC_PROTO_CEC, + msg->msg[2] << 8 | msg->msg[3], 0); break; /* * Other function messages that are not handled. @@ -1901,54 +1900,11 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, */ case 0x56: case 0x57: case 0x67: case 0x68: case 0x69: case 0x6a: - scancode = -1; break; default: - scancode = msg->msg[2]; - break; - } - - /* Was repeating, but keypress timed out */ - if (adap->rc_repeating && !adap->rc->keypressed) { - adap->rc_repeating = false; - adap->rc_last_scancode = -1; - } - /* Different keypress from last time, ends repeat mode */ - if (adap->rc_last_scancode != scancode) { - rc_keyup(adap->rc); - adap->rc_repeating = false; - } - /* We can't handle this scancode */ - if (scancode < 0) { - adap->rc_last_scancode = scancode; - break; - } - - /* Send key press */ - rc_keydown(adap->rc, RC_PROTO_CEC, scancode, 0); - - /* When in repeating mode, we're done */ - if (adap->rc_repeating) - break; - - /* - * We are not repeating, but the new scancode is - * the same as the last one, and this second key press is - * within 550 ms (the 'Follower Safety Timeout') from the - * previous key press, so we now enable the repeating mode. - */ - if (adap->rc_last_scancode == scancode && - msg->rx_ts - adap->rc_last_keypress < 550 * NSEC_PER_MSEC) { - adap->rc_repeating = true; + rc_keydown(adap->rc, RC_PROTO_CEC, msg->msg[2], 0); break; } - /* - * Not in repeating mode, so avoid triggering repeat mode - * by calling keyup. - */ - rc_keyup(adap->rc); - adap->rc_last_scancode = scancode; - adap->rc_last_keypress = msg->rx_ts; #endif break; @@ -1958,8 +1914,6 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, break; #ifdef CONFIG_MEDIA_CEC_RC rc_keyup(adap->rc); - adap->rc_repeating = false; - adap->rc_last_scancode = -1; #endif break; diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c index b5845b47fe6c2..a9f9525db9ae8 100644 --- a/drivers/media/cec/cec-core.c +++ b/drivers/media/cec/cec-core.c @@ -286,7 +286,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, adap->rc->priv = adap; adap->rc->map_name = RC_MAP_CEC; adap->rc->timeout = MS_TO_NS(100); - adap->rc_last_scancode = -1; #endif return adap; } @@ -318,17 +317,6 @@ int cec_register_adapter(struct cec_adapter *adap, adap->rc = NULL; return res; } - /* - * The REP_DELAY for CEC is really the time between the initial - * 'User Control Pressed' message and the second. The first - * keypress is always seen as non-repeating, the second - * (provided it has the same UI Command) will start the 'Press - * and Hold' (aka repeat) behavior. By setting REP_DELAY to the - * same value as REP_PERIOD the expected CEC behavior is - * reproduced. - */ - adap->rc->input_dev->rep[REP_DELAY] = - adap->rc->input_dev->rep[REP_PERIOD]; } #endif diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 5830cb2c59436..1870b79990628 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -597,6 +597,7 @@ static void ir_do_keyup(struct rc_dev *dev, bool sync) return; IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode); + del_timer_sync(&dev->timer_repeat); input_report_key(dev->input_dev, dev->last_keycode, 0); led_trigger_event(led_feedback, LED_OFF); if (sync) @@ -650,6 +651,31 @@ static void ir_timer_keyup(struct timer_list *t) spin_unlock_irqrestore(&dev->keylock, flags); } +/** + * ir_timer_repeat() - generates a repeat event after a timeout + * + * @t: a pointer to the struct timer_list + * + * This routine will generate a soft repeat event every REP_PERIOD + * milliseconds. + */ +static void ir_timer_repeat(struct timer_list *t) +{ + struct rc_dev *dev = from_timer(dev, t, timer_repeat); + struct input_dev *input = dev->input_dev; + unsigned long flags; + + spin_lock_irqsave(&dev->keylock, flags); + if (dev->keypressed) { + input_event(input, EV_KEY, dev->last_keycode, 2); + input_sync(input); + if (input->rep[REP_PERIOD]) + mod_timer(&dev->timer_repeat, jiffies + + msecs_to_jiffies(input->rep[REP_PERIOD])); + } + spin_unlock_irqrestore(&dev->keylock, flags); +} + /** * rc_repeat() - signals that a key is still pressed * @dev: the struct rc_dev descriptor of the device @@ -732,6 +758,22 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol, led_trigger_event(led_feedback, LED_FULL); } + /* + * For CEC, start sending repeat messages as soon as the first + * repeated message is sent, as long as REP_DELAY = 0 and REP_PERIOD + * is non-zero. Otherwise, the input layer will generate repeat + * messages. + */ + if (!new_event && keycode != KEY_RESERVED && + dev->allowed_protocols == RC_PROTO_BIT_CEC && + !timer_pending(&dev->timer_repeat) && + dev->input_dev->rep[REP_PERIOD] && + !dev->input_dev->rep[REP_DELAY]) { + input_event(dev->input_dev, EV_KEY, keycode, 2); + mod_timer(&dev->timer_repeat, jiffies + + msecs_to_jiffies(dev->input_dev->rep[REP_PERIOD])); + } + input_sync(dev->input_dev); } @@ -1599,6 +1641,7 @@ struct rc_dev *rc_allocate_device(enum rc_driver_type type) input_set_drvdata(dev->input_dev, dev); timer_setup(&dev->timer_keyup, ir_timer_keyup, 0); + timer_setup(&dev->timer_repeat, ir_timer_repeat, 0); spin_lock_init(&dev->rc_map.lock); spin_lock_init(&dev->keylock); @@ -1732,7 +1775,10 @@ static int rc_setup_rx_device(struct rc_dev *dev) * to avoid wrong repetition of the keycodes. Note that this must be * set after the call to input_register_device(). */ - dev->input_dev->rep[REP_DELAY] = 500; + if (dev->allowed_protocols == RC_PROTO_BIT_CEC) + dev->input_dev->rep[REP_DELAY] = 0; + else + dev->input_dev->rep[REP_DELAY] = 500; /* * As a repeat event on protocols like RC-5 and NEC take as long as @@ -1884,6 +1930,7 @@ void rc_unregister_device(struct rc_dev *dev) return; del_timer_sync(&dev->timer_keyup); + del_timer_sync(&dev->timer_repeat); if (dev->driver_type == RC_DRIVER_IR_RAW) ir_raw_event_unregister(dev); diff --git a/include/media/cec.h b/include/media/cec.h index 1c6a797cb6d4a..7cdf71d7125a3 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -192,11 +192,6 @@ struct cec_adapter { u32 tx_timeouts; -#ifdef CONFIG_MEDIA_CEC_RC - bool rc_repeating; - int rc_last_scancode; - u64 rc_last_keypress; -#endif #ifdef CONFIG_CEC_NOTIFIER struct cec_notifier *notifier; #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 3a47a25a65930..0a4026cf64f33 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -134,6 +134,8 @@ struct lirc_fh { * @keypressed: whether a key is currently pressed * @keyup_jiffies: time (in jiffies) when the current keypress should be released * @timer_keyup: timer for releasing a keypress + * @timer_repeat: timer for autorepeat events. This is needed for CEC, which + * has non-standard repeats. * @last_keycode: keycode of last keypress * @last_protocol: protocol of last keypress * @last_scancode: scancode of last keypress @@ -202,6 +204,7 @@ struct rc_dev { bool keypressed; unsigned long keyup_jiffies; struct timer_list timer_keyup; + struct timer_list timer_repeat; u32 last_keycode; enum rc_proto last_protocol; u32 last_scancode; -- GitLab From c6b73bfcead9500e6b841cadb44f38324202ef77 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 30 Nov 2017 08:00:45 -0500 Subject: [PATCH 0223/1190] media: RC docs: add enum rc_proto description at the docs This is part of the uAPI. Add it to the documentation again, and fix cross-references. Signed-off-by: Mauro Carvalho Chehab Acked-by: Sean Young --- .../media/uapi/rc/lirc-dev-intro.rst | 19 +++++++++++++------ Documentation/media/uapi/rc/lirc-read.rst | 2 +- Documentation/media/uapi/rc/lirc-write.rst | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Documentation/media/uapi/rc/lirc-dev-intro.rst b/Documentation/media/uapi/rc/lirc-dev-intro.rst index 47c6c218e72a5..3a74fec66d69f 100644 --- a/Documentation/media/uapi/rc/lirc-dev-intro.rst +++ b/Documentation/media/uapi/rc/lirc-dev-intro.rst @@ -46,13 +46,13 @@ on the following table. This mode is for both sending and receiving IR. For transmitting (aka sending), create a ``struct lirc_scancode`` with - the desired scancode set in the ``scancode`` member, ``rc_proto`` set - the IR protocol, and all other members set to 0. Write this struct to + the desired scancode set in the ``scancode`` member, :c:type:`rc_proto` + set the IR protocol, and all other members set to 0. Write this struct to the lirc device. For receiving, you read ``struct lirc_scancode`` from the lirc device, with ``scancode`` set to the received scancode and the IR protocol - ``rc_proto``. If the scancode maps to a valid key code, this is set + :c:type:`rc_proto`. If the scancode maps to a valid key code, this is set in the ``keycode`` field, else it is set to ``KEY_RESERVED``. The ``flags`` can have ``LIRC_SCANCODE_FLAG_TOGGLE`` set if the toggle @@ -74,9 +74,6 @@ on the following table. The ``timestamp`` field is filled with the time nanoseconds (in ``CLOCK_MONOTONIC``) when the scancode was decoded. - An ``enum rc_proto`` in the :ref:`lirc_header` lists all the supported - IR protocols. - .. _lirc-mode-mode2: ``LIRC_MODE_MODE2`` @@ -125,3 +122,13 @@ on the following table. of entries. This mode is used only for IR send. + + +************************** +Remote Controller protocol +************************** + +An enum :c:type:`rc_proto` in the :ref:`lirc_header` lists all the +supported IR protocols: + +.. kernel-doc:: include/uapi/linux/lirc.h diff --git a/Documentation/media/uapi/rc/lirc-read.rst b/Documentation/media/uapi/rc/lirc-read.rst index 51d37ed10194c..c024aaffb8ad3 100644 --- a/Documentation/media/uapi/rc/lirc-read.rst +++ b/Documentation/media/uapi/rc/lirc-read.rst @@ -54,7 +54,7 @@ read from the chardev. Alternatively, :ref:`LIRC_MODE_SCANCODE ` can be available, in this mode scancodes which are either decoded by software decoders, or -by hardware decoders. The ``rc_proto`` member is set to the +by hardware decoders. The :c:type:`rc_proto` member is set to the protocol used for transmission, and ``scancode`` to the decoded scancode, and the ``keycode`` set to the keycode or ``KEY_RESERVED``. diff --git a/Documentation/media/uapi/rc/lirc-write.rst b/Documentation/media/uapi/rc/lirc-write.rst index 3d7541bad8b9a..dd3d1fe807a62 100644 --- a/Documentation/media/uapi/rc/lirc-write.rst +++ b/Documentation/media/uapi/rc/lirc-write.rst @@ -57,8 +57,8 @@ driver returns ``EINVAL``. When in :ref:`LIRC_MODE_SCANCODE ` mode, one ``struct lirc_scancode`` must be written to the chardev at a time, else ``EINVAL`` is returned. Set the desired scancode in the ``scancode`` member, -and the protocol in the ``rc_proto`` member. All other members must be set -to 0, else ``EINVAL`` is returned. If there is no protocol encoder +and the protocol in the :c:type:`rc_proto`: member. All other members must be +set to 0, else ``EINVAL`` is returned. If there is no protocol encoder for the protocol or the scancode is not valid for the specified protocol, ``EINVAL`` is returned. The write function may not wait until the scancode is transmitted. -- GitLab From 8ff230fb4f48816cd18a558a0d26f580178a26df Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 11 Dec 2017 07:06:04 -0500 Subject: [PATCH 0224/1190] media: tuners: tda8290: reduce stack usage with kasan With CONFIG_KASAN enabled, we get a relatively large stack frame in one function drivers/media/tuners/tda8290.c: In function 'tda8290_set_params': drivers/media/tuners/tda8290.c:310:1: warning: the frame size of 1520 bytes is larger than 1024 bytes [-Wframe-larger-than=] With CONFIG_KASAN_EXTRA this goes up to drivers/media/tuners/tda8290.c: In function 'tda8290_set_params': drivers/media/tuners/tda8290.c:310:1: error: the frame size of 3200 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] We can significantly reduce this by marking local arrays as 'static const', and this should result in better compiled code for everyone. [mchehab@s-opensource.com: fix a trivial merge conflict] Signed-off-by: Arnd Bergmann Reviewed-by: Michael Ira Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/tda8290.c | 78 +++++++++++++++++----------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c index f226e6ecc1754..9f1f1d2b8bdc4 100644 --- a/drivers/media/tuners/tda8290.c +++ b/drivers/media/tuners/tda8290.c @@ -63,8 +63,8 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char enable[2] = { 0x21, 0xC0 }; - unsigned char disable[2] = { 0x21, 0x00 }; + static unsigned char enable[2] = { 0x21, 0xC0 }; + static unsigned char disable[2] = { 0x21, 0x00 }; unsigned char *msg; if (close) { @@ -84,9 +84,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char enable[2] = { 0x45, 0xc1 }; - unsigned char disable[2] = { 0x46, 0x00 }; - unsigned char buf[3] = { 0x45, 0x01, 0x00 }; + static unsigned char enable[2] = { 0x45, 0xc1 }; + static unsigned char disable[2] = { 0x46, 0x00 }; + static unsigned char buf[3] = { 0x45, 0x01, 0x00 }; unsigned char *msg; if (close) { @@ -178,25 +178,25 @@ static void tda8290_set_params(struct dvb_frontend *fe, { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char soft_reset[] = { 0x00, 0x00 }; + static unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; - unsigned char expert_mode[] = { 0x01, 0x80 }; - unsigned char agc_out_on[] = { 0x02, 0x00 }; - unsigned char gainset_off[] = { 0x28, 0x14 }; - unsigned char if_agc_spd[] = { 0x0f, 0x88 }; - unsigned char adc_head_6[] = { 0x05, 0x04 }; - unsigned char adc_head_9[] = { 0x05, 0x02 }; - unsigned char adc_head_12[] = { 0x05, 0x01 }; - unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; - unsigned char pll_bw_low[] = { 0x0d, 0x27 }; - unsigned char gainset_2[] = { 0x28, 0x64 }; - unsigned char agc_rst_on[] = { 0x0e, 0x0b }; - unsigned char agc_rst_off[] = { 0x0e, 0x09 }; - unsigned char if_agc_set[] = { 0x0f, 0x81 }; - unsigned char addr_adc_sat = 0x1a; - unsigned char addr_agc_stat = 0x1d; - unsigned char addr_pll_stat = 0x1b; - unsigned char adc_sat = 0, agc_stat = 0, + static unsigned char expert_mode[] = { 0x01, 0x80 }; + static unsigned char agc_out_on[] = { 0x02, 0x00 }; + static unsigned char gainset_off[] = { 0x28, 0x14 }; + static unsigned char if_agc_spd[] = { 0x0f, 0x88 }; + static unsigned char adc_head_6[] = { 0x05, 0x04 }; + static unsigned char adc_head_9[] = { 0x05, 0x02 }; + static unsigned char adc_head_12[] = { 0x05, 0x01 }; + static unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; + static unsigned char pll_bw_low[] = { 0x0d, 0x27 }; + static unsigned char gainset_2[] = { 0x28, 0x64 }; + static unsigned char agc_rst_on[] = { 0x0e, 0x0b }; + static unsigned char agc_rst_off[] = { 0x0e, 0x09 }; + static unsigned char if_agc_set[] = { 0x0f, 0x81 }; + static unsigned char addr_adc_sat = 0x1a; + static unsigned char addr_agc_stat = 0x1d; + static unsigned char addr_pll_stat = 0x1b; + static unsigned char adc_sat = 0, agc_stat = 0, pll_stat; int i; @@ -468,9 +468,9 @@ static void tda8290_standby(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char cb1[] = { 0x30, 0xD0 }; - unsigned char tda8290_standby[] = { 0x00, 0x02 }; - unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; + static unsigned char cb1[] = { 0x30, 0xD0 }; + static unsigned char tda8290_standby[] = { 0x00, 0x02 }; + static unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; if (fe->ops.analog_ops.i2c_gate_ctrl) @@ -495,9 +495,9 @@ static void tda8290_init_if(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char set_VS[] = { 0x30, 0x6F }; - unsigned char set_GP00_CF[] = { 0x20, 0x01 }; - unsigned char set_GP01_CF[] = { 0x20, 0x0B }; + static unsigned char set_VS[] = { 0x30, 0x6F }; + static unsigned char set_GP00_CF[] = { 0x20, 0x01 }; + static unsigned char set_GP01_CF[] = { 0x20, 0x0B }; if ((priv->cfg.config == TDA8290_LNA_GP0_HIGH_ON) || (priv->cfg.config == TDA8290_LNA_GP0_HIGH_OFF)) @@ -539,10 +539,12 @@ static void tda8295_init_if(struct dvb_frontend *fe) static void tda8290_init_tuner(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, - 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; - unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, - 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; + static unsigned char tda8275_init[] = + { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, + 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; + static unsigned char tda8275a_init[] = + { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, + 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=tda8275_init, .len = 14}; if (priv->ver & TDA8275A) @@ -834,11 +836,11 @@ int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) .addr = i2c_addr, }; - unsigned char soft_reset[] = { 0x00, 0x00 }; - unsigned char easy_mode_b[] = { 0x01, 0x02 }; - unsigned char easy_mode_g[] = { 0x01, 0x04 }; - unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 }; - unsigned char addr_dto_lsb = 0x07; + static unsigned char soft_reset[] = { 0x00, 0x00 }; + static unsigned char easy_mode_b[] = { 0x01, 0x02 }; + static unsigned char easy_mode_g[] = { 0x01, 0x04 }; + static unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 }; + static unsigned char addr_dto_lsb = 0x07; unsigned char data; #define PROBE_BUFFER_SIZE 8 unsigned char buf[PROBE_BUFFER_SIZE]; -- GitLab From 78e41c16c0b5d47415f01ead3a3730d5b9a6a52c Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Mon, 11 Dec 2017 15:12:49 -0500 Subject: [PATCH 0225/1190] media: ddbridge: stv09xx: detach frontends on lnb failure While the failure handling in dvb_input_attach() has been improved lately so any tuner failure won't result in demod driver modules with a usecount > 0 anymore (thus requiring rmmod -f), there's still an issue with stv090x and stv0910 based tuner modules, in that LNB driver attach failures leave an attached demod frontend driver behind which have a usecount of > 0 in this failure case, due to them not being detached/ released. Fix this by detaching the demod frontends if the LNB driver fails. Richard tested and verified the changes with STV0910 hardware, thus adding his Tested-by. Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ddbridge/ddbridge-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 11c5cae92408b..eb43dcb4e5d2d 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1114,6 +1114,7 @@ static int demod_attach_stv0900(struct ddb_input *input, int type) 0, (input->nr & 1) ? (0x09 - type) : (0x0b - type))) { dev_err(dev, "No LNBH24 found!\n"); + dvb_frontend_detach(dvb->fe); return -ENODEV; } return 0; @@ -1196,6 +1197,7 @@ static int demod_attach_stv0910(struct ddb_input *input, int type) lnbcfg.i2c_address = (((input->nr & 1) ? 0x09 : 0x08) << 1); if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) { dev_err(dev, "No LNBH25 found!\n"); + dvb_frontend_detach(dvb->fe); return -ENODEV; } } -- GitLab From 380a6c86457573aa42d27ae11e025eb25941a0b7 Mon Sep 17 00:00:00 2001 From: Ron Economos Date: Mon, 11 Dec 2017 19:51:53 -0500 Subject: [PATCH 0226/1190] media: [RESEND] media: dvb-frontends: Add delay to Si2168 restart On faster CPUs a delay is required after the resume command and the restart command. Without the delay, the restart command often returns -EREMOTEIO and the Si2168 does not restart. Note that this patch fixes the same issue as https://patchwork.linuxtv.org/patch/44304/, but I believe my udelay() fix addresses the actual problem. Signed-off-by: Ron Economos Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2168.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 41d9c513b7e8f..539399dac5514 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -14,6 +14,8 @@ * GNU General Public License for more details. */ +#include + #include "si2168_priv.h" static const struct dvb_frontend_ops si2168_ops; @@ -435,6 +437,7 @@ static int si2168_init(struct dvb_frontend *fe) if (ret) goto err; + udelay(100); memcpy(cmd.args, "\x85", 1); cmd.wlen = 1; cmd.rlen = 1; -- GitLab From 65ac8c84b5712fe31055856d03117b16dd7f8730 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Tue, 12 Dec 2017 13:46:55 -0500 Subject: [PATCH 0227/1190] media: staging/cxd2099: fix remaining checkpatch-strict issues Fix up all remaining cosmetic issues as reported by checkpatch.pl. Signed-off-by: Daniel Scheller Signed-off-by: Jasmin Jessich Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/cxd2099/cxd2099.c | 19 +++++-------------- drivers/staging/media/cxd2099/cxd2099.h | 14 +++----------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/staging/media/cxd2099/cxd2099.c b/drivers/staging/media/cxd2099/cxd2099.c index 3e30f4864e2b7..21b1c6fcf9bfc 100644 --- a/drivers/staging/media/cxd2099/cxd2099.c +++ b/drivers/staging/media/cxd2099/cxd2099.c @@ -3,23 +3,14 @@ * * Copyright (C) 2010-2013 Digital Devices GmbH * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 only, as published by the Free Software Foundation. * - * * 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., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #include @@ -59,7 +50,7 @@ struct cxd { int amem_read; int cammode; - struct mutex lock; + struct mutex lock; /* device access lock */ u8 rbuf[1028]; u8 wbuf[1028]; @@ -101,7 +92,7 @@ static int i2c_read_reg(struct i2c_adapter *adapter, u8 adr, .buf = val, .len = 1} }; if (i2c_transfer(adapter, msgs, 2) != 2) { - dev_err(&adapter->dev, "error in i2c_read_reg\n"); + dev_err(&adapter->dev, "error in %s()\n", __func__); return -1; } return 0; @@ -116,7 +107,7 @@ static int i2c_read(struct i2c_adapter *adapter, u8 adr, .buf = data, .len = n} }; if (i2c_transfer(adapter, msgs, 2) != 2) { - dev_err(&adapter->dev, "error in i2c_read\n"); + dev_err(&adapter->dev, "error in %s()\n", __func__); return -1; } return 0; @@ -134,7 +125,7 @@ static int read_block(struct cxd *ci, u8 adr, u8 *data, u16 n) while (n) { int len = n; - if (ci->cfg.max_i2c && (len > ci->cfg.max_i2c)) + if (ci->cfg.max_i2c && len > ci->cfg.max_i2c) len = ci->cfg.max_i2c; status = i2c_read(ci->i2c, ci->cfg.adr, 1, data, len); if (status) @@ -591,7 +582,7 @@ static int campoll(struct cxd *ci) } } if ((istat & 8) && - (ci->slot_stat == DVB_CA_EN50221_POLL_CAM_PRESENT)) { + ci->slot_stat == DVB_CA_EN50221_POLL_CAM_PRESENT) { ci->ready = 1; ci->slot_stat |= DVB_CA_EN50221_POLL_CAM_READY; } diff --git a/drivers/staging/media/cxd2099/cxd2099.h b/drivers/staging/media/cxd2099/cxd2099.h index f4b29b1d6eb88..aba803268e94d 100644 --- a/drivers/staging/media/cxd2099/cxd2099.h +++ b/drivers/staging/media/cxd2099/cxd2099.h @@ -3,23 +3,14 @@ * * Copyright (C) 2010-2011 Digital Devices GmbH * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 only, as published by the Free Software Foundation. * - * * 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., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #ifndef _CXD2099_H_ @@ -42,8 +33,9 @@ struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, void *priv, struct i2c_adapter *i2c); #else -static inline struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, - void *priv, struct i2c_adapter *i2c) +static inline struct +dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, void *priv, + struct i2c_adapter *i2c) { dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__); return NULL; -- GitLab From 902ea1dfbbe4ceca04f16c8198170ec3eee1da03 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Tue, 12 Dec 2017 13:46:56 -0500 Subject: [PATCH 0228/1190] media: staging/cxd2099: fix debug message severity Debug messages should go to KERN_DEBUG, thus change the slot_shutdown() notice from dev_info() to dev_dbg(). Signed-off-by: Daniel Scheller Signed-off-by: Jasmin Jessich Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/cxd2099/cxd2099.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/cxd2099/cxd2099.c b/drivers/staging/media/cxd2099/cxd2099.c index 21b1c6fcf9bfc..38d43647d4bfc 100644 --- a/drivers/staging/media/cxd2099/cxd2099.c +++ b/drivers/staging/media/cxd2099/cxd2099.c @@ -518,7 +518,7 @@ static int slot_shutdown(struct dvb_ca_en50221 *ca, int slot) { struct cxd *ci = ca->data; - dev_info(&ci->i2c->dev, "%s\n", __func__); + dev_dbg(&ci->i2c->dev, "%s\n", __func__); if (ci->cammode) read_data(ca, slot, ci->rbuf, 0); mutex_lock(&ci->lock); -- GitLab From 6c84bbfe11a80e4d8a33483bc1d736abef60dd9e Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Tue, 12 Dec 2017 13:46:57 -0500 Subject: [PATCH 0229/1190] media: staging/cxd2099: cosmetics: improve strings Prefix dev_*() I2C address prints with 0x, change CXD2099 to CXD2099AR, change the MODULE_DESCRIPTION to a proper one and have a better (and shorter) description for the buffermode modparam. Signed-off-by: Daniel Scheller Signed-off-by: Jasmin Jessich Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/cxd2099/cxd2099.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/cxd2099/cxd2099.c b/drivers/staging/media/cxd2099/cxd2099.c index 38d43647d4bfc..dc9cbd8f2104d 100644 --- a/drivers/staging/media/cxd2099/cxd2099.c +++ b/drivers/staging/media/cxd2099/cxd2099.c @@ -26,7 +26,7 @@ static int buffermode; module_param(buffermode, int, 0444); -MODULE_PARM_DESC(buffermode, "Enable use of the CXD2099AR buffer mode (default: disabled)"); +MODULE_PARM_DESC(buffermode, "Enable CXD2099AR buffer mode (default: disabled)"); static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount); @@ -668,7 +668,8 @@ struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, u8 val; if (i2c_read_reg(i2c, cfg->adr, 0, &val) < 0) { - dev_info(&i2c->dev, "No CXD2099 detected at %02x\n", cfg->adr); + dev_info(&i2c->dev, "No CXD2099AR detected at 0x%02x\n", + cfg->adr); return NULL; } @@ -686,7 +687,7 @@ struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, ci->en = en_templ; ci->en.data = ci; init(ci); - dev_info(&i2c->dev, "Attached CXD2099AR at %02x\n", ci->cfg.adr); + dev_info(&i2c->dev, "Attached CXD2099AR at 0x%02x\n", ci->cfg.adr); if (!buffermode) { ci->en.read_data = NULL; @@ -699,6 +700,6 @@ struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, } EXPORT_SYMBOL(cxd2099_attach); -MODULE_DESCRIPTION("cxd2099"); +MODULE_DESCRIPTION("CXD2099AR Common Interface controller driver"); MODULE_AUTHOR("Ralph Metzler"); MODULE_LICENSE("GPL"); -- GitLab From d9806f11b36a389f5cb34bf28055b510974177b2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 13 Dec 2017 04:54:04 -0500 Subject: [PATCH 0230/1190] media: vidioc-g-dv-timings.rst: fix typo (frontporch -> backporch) The description of V4L2_DV_FL_HALF_LINE mixed up frontporch with backporch. It's the backporch that has different sizes for interlaced formats, the frontporch remains constant. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst index 2696380626d46..1a034e825161b 100644 --- a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst +++ b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst @@ -267,7 +267,7 @@ EBUSY will also be cleared. * - ``V4L2_DV_FL_HALF_LINE`` - Specific to interlaced formats: if set, then the vertical - frontporch of field 1 (aka the odd field) is really one half-line + backporch of field 1 (aka the odd field) is really one half-line longer and the vertical backporch of field 2 (aka the even field) is really one half-line shorter, so each field has exactly the same number of half-lines. Whether half-lines can be detected or -- GitLab From 0ca4e3130402caea8731a7b54afde56a6edb17c9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 13 Dec 2017 05:19:03 -0500 Subject: [PATCH 0231/1190] media: pxa_camera: rename the soc_camera_ prefix to pxa_camera_ Rename soc_camera to pxa_camera as this has no longer anything to do with the old soc_camera driver/framework. It's confusing when grepping on soc_camera. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/pxa_camera.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index 32047aefa1e83..305cf1cac210f 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -646,16 +646,16 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cf } /** - * struct soc_camera_format_xlate - match between host and sensor formats + * struct pxa_camera_format_xlate - match between host and sensor formats * @code: code of a sensor provided format * @host_fmt: host format after host translation from code * * Host and sensor translation structure. Used in table of host and sensor - * formats matchings in soc_camera_device. A host can override the generic list + * formats matchings in pxa_camera_device. A host can override the generic list * generation by implementing get_formats(), and use it for format checks and * format setup. */ -struct soc_camera_format_xlate { +struct pxa_camera_format_xlate { u32 code; const struct pxa_mbus_pixelfmt *host_fmt; }; @@ -692,8 +692,8 @@ struct pxa_camera_dev { struct v4l2_async_notifier notifier; struct vb2_queue vb2_vq; struct v4l2_subdev *sensor; - struct soc_camera_format_xlate *user_formats; - const struct soc_camera_format_xlate *current_fmt; + struct pxa_camera_format_xlate *user_formats; + const struct pxa_camera_format_xlate *current_fmt; struct v4l2_pix_format current_pix; struct v4l2_async_subdev asd; @@ -742,8 +742,8 @@ static const char *pxa_cam_driver_description = "PXA_Camera"; /* * Format translation functions */ -static const struct soc_camera_format_xlate -*pxa_mbus_xlate_by_fourcc(struct soc_camera_format_xlate *user_formats, +static const struct pxa_camera_format_xlate +*pxa_mbus_xlate_by_fourcc(struct pxa_camera_format_xlate *user_formats, unsigned int fourcc) { unsigned int i; @@ -754,17 +754,17 @@ static const struct soc_camera_format_xlate return NULL; } -static struct soc_camera_format_xlate *pxa_mbus_build_fmts_xlate( +static struct pxa_camera_format_xlate *pxa_mbus_build_fmts_xlate( struct v4l2_device *v4l2_dev, struct v4l2_subdev *subdev, int (*get_formats)(struct v4l2_device *, unsigned int, - struct soc_camera_format_xlate *xlate)) + struct pxa_camera_format_xlate *xlate)) { unsigned int i, fmts = 0, raw_fmts = 0; int ret; struct v4l2_subdev_mbus_code_enum code = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - struct soc_camera_format_xlate *user_formats; + struct pxa_camera_format_xlate *user_formats; while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) { raw_fmts++; @@ -1721,7 +1721,7 @@ static bool pxa_camera_packing_supported(const struct pxa_mbus_pixelfmt *fmt) static int pxa_camera_get_formats(struct v4l2_device *v4l2_dev, unsigned int idx, - struct soc_camera_format_xlate *xlate) + struct pxa_camera_format_xlate *xlate) { struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev); int formats = 0, ret; @@ -1793,7 +1793,7 @@ static int pxa_camera_get_formats(struct v4l2_device *v4l2_dev, static int pxa_camera_build_formats(struct pxa_camera_dev *pcdev) { - struct soc_camera_format_xlate *xlate; + struct pxa_camera_format_xlate *xlate; xlate = pxa_mbus_build_fmts_xlate(&pcdev->v4l2_dev, pcdev->sensor, pxa_camera_get_formats); @@ -1882,7 +1882,7 @@ static int pxac_vidioc_try_fmt_vid_cap(struct file *filp, void *priv, struct v4l2_format *f) { struct pxa_camera_dev *pcdev = video_drvdata(filp); - const struct soc_camera_format_xlate *xlate; + const struct pxa_camera_format_xlate *xlate; struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_subdev_pad_config pad_cfg; struct v4l2_subdev_format format = { @@ -1946,7 +1946,7 @@ static int pxac_vidioc_s_fmt_vid_cap(struct file *filp, void *priv, struct v4l2_format *f) { struct pxa_camera_dev *pcdev = video_drvdata(filp); - const struct soc_camera_format_xlate *xlate; + const struct pxa_camera_format_xlate *xlate; struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, -- GitLab From 16c3ada89cff9a8c2a0eea34ffa1aa20af3f6008 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 30 Nov 2017 06:08:05 -0500 Subject: [PATCH 0232/1190] media: r820t: fix r820t_write_reg for KASAN With CONFIG_KASAN, we get an overly long stack frame due to inlining the register access functions: drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7': drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] This is caused by a gcc bug that has now been fixed in gcc-8. To work around the problem, we can pass the register data through a local variable that older gcc versions can optimize out as well. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Signed-off-by: Arnd Bergmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 69a507f355b59..bc9299059f483 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -384,9 +384,11 @@ static int r820t_write(struct r820t_priv *priv, u8 reg, const u8 *val, return 0; } -static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val) +static inline int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val) { - return r820t_write(priv, reg, &val, 1); + u8 tmp = val; /* work around GCC PR81715 with asan-stack=1 */ + + return r820t_write(priv, reg, &tmp, 1); } static int r820t_read_cache_reg(struct r820t_priv *priv, int reg) @@ -399,17 +401,18 @@ static int r820t_read_cache_reg(struct r820t_priv *priv, int reg) return -EINVAL; } -static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val, +static inline int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val, u8 bit_mask) { + u8 tmp = val; int rc = r820t_read_cache_reg(priv, reg); if (rc < 0) return rc; - val = (rc & ~bit_mask) | (val & bit_mask); + tmp = (rc & ~bit_mask) | (tmp & bit_mask); - return r820t_write(priv, reg, &val, 1); + return r820t_write(priv, reg, &tmp, 1); } static int r820t_read(struct r820t_priv *priv, u8 reg, u8 *val, int len) -- GitLab From 3cd890dbe2a4f14cc44c85bb6cf37e5e22d4dd0e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 30 Nov 2017 11:55:46 -0500 Subject: [PATCH 0233/1190] media: dvb-frontends: fix i2c access helpers for KASAN A typical code fragment was copied across many dvb-frontend drivers and causes large stack frames when built with with CONFIG_KASAN on gcc-5/6/7: drivers/media/dvb-frontends/cxd2841er.c:3225:1: error: the frame size of 3992 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/cxd2841er.c:3404:1: error: the frame size of 3136 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv0367.c:3143:1: error: the frame size of 4016 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:4248:1: error: the frame size of 4872 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] gcc-8 now solves this by consolidating the stack slots for the argument variables, but on older compilers we can get the same behavior by taking the pointer of a local variable rather than the inline function argument. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/ascot2e.c | 4 +++- drivers/media/dvb-frontends/cxd2841er.c | 4 +++- drivers/media/dvb-frontends/helene.c | 4 +++- drivers/media/dvb-frontends/horus3a.c | 4 +++- drivers/media/dvb-frontends/itd1000.c | 5 +++-- drivers/media/dvb-frontends/mt312.c | 5 ++++- drivers/media/dvb-frontends/stb0899_drv.c | 3 ++- drivers/media/dvb-frontends/stb6100.c | 6 ++++-- drivers/media/dvb-frontends/stv0367.c | 4 +++- drivers/media/dvb-frontends/stv090x.c | 4 +++- drivers/media/dvb-frontends/stv6110x.c | 4 +++- drivers/media/dvb-frontends/zl10039.c | 4 +++- 12 files changed, 37 insertions(+), 14 deletions(-) diff --git a/drivers/media/dvb-frontends/ascot2e.c b/drivers/media/dvb-frontends/ascot2e.c index 0ee0df53b91bb..79d5d89bc95e7 100644 --- a/drivers/media/dvb-frontends/ascot2e.c +++ b/drivers/media/dvb-frontends/ascot2e.c @@ -155,7 +155,9 @@ static int ascot2e_write_regs(struct ascot2e_priv *priv, static int ascot2e_write_reg(struct ascot2e_priv *priv, u8 reg, u8 val) { - return ascot2e_write_regs(priv, reg, &val, 1); + u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return ascot2e_write_regs(priv, reg, &tmp, 1); } static int ascot2e_read_regs(struct ascot2e_priv *priv, diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 17e4db7900e5b..16763903d4ad1 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -258,7 +258,9 @@ static int cxd2841er_write_regs(struct cxd2841er_priv *priv, static int cxd2841er_write_reg(struct cxd2841er_priv *priv, u8 addr, u8 reg, u8 val) { - return cxd2841er_write_regs(priv, addr, reg, &val, 1); + u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return cxd2841er_write_regs(priv, addr, reg, &tmp, 1); } static int cxd2841er_read_regs(struct cxd2841er_priv *priv, diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c index 4bf5a551ba403..2ab8d83e55768 100644 --- a/drivers/media/dvb-frontends/helene.c +++ b/drivers/media/dvb-frontends/helene.c @@ -331,7 +331,9 @@ static int helene_write_regs(struct helene_priv *priv, static int helene_write_reg(struct helene_priv *priv, u8 reg, u8 val) { - return helene_write_regs(priv, reg, &val, 1); + u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return helene_write_regs(priv, reg, &tmp, 1); } static int helene_read_regs(struct helene_priv *priv, diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c index 68d759c4c52ec..5c8b405f2ddc5 100644 --- a/drivers/media/dvb-frontends/horus3a.c +++ b/drivers/media/dvb-frontends/horus3a.c @@ -89,7 +89,9 @@ static int horus3a_write_regs(struct horus3a_priv *priv, static int horus3a_write_reg(struct horus3a_priv *priv, u8 reg, u8 val) { - return horus3a_write_regs(priv, reg, &val, 1); + u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return horus3a_write_regs(priv, reg, &tmp, 1); } static int horus3a_enter_power_save(struct horus3a_priv *priv) diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c index 5bb1e73a10b43..ce7c443d3eacd 100644 --- a/drivers/media/dvb-frontends/itd1000.c +++ b/drivers/media/dvb-frontends/itd1000.c @@ -95,8 +95,9 @@ static int itd1000_read_reg(struct itd1000_state *state, u8 reg) static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v) { - int ret = itd1000_write_regs(state, r, &v, 1); - state->shadow[r] = v; + u8 tmp = v; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + int ret = itd1000_write_regs(state, r, &tmp, 1); + state->shadow[r] = tmp; return ret; } diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c index 961b9a2508e0c..0b23cbc021b81 100644 --- a/drivers/media/dvb-frontends/mt312.c +++ b/drivers/media/dvb-frontends/mt312.c @@ -142,7 +142,10 @@ static inline int mt312_readreg(struct mt312_state *state, static inline int mt312_writereg(struct mt312_state *state, const enum mt312_reg_addr reg, const u8 val) { - return mt312_write(state, reg, &val, 1); + u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + + return mt312_write(state, reg, &tmp, 1); } static inline u32 mt312_div(u32 a, u32 b) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 02347598277af..db5dde3215f02 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -539,7 +539,8 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, int stb0899_write_reg(struct stb0899_state *state, unsigned int reg, u8 data) { - return stb0899_write_regs(state, reg, &data, 1); + u8 tmp = data; + return stb0899_write_regs(state, reg, &tmp, 1); } /* diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c index 17a955d0031bb..75509bec66e4c 100644 --- a/drivers/media/dvb-frontends/stb6100.c +++ b/drivers/media/dvb-frontends/stb6100.c @@ -226,12 +226,14 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st static int stb6100_write_reg(struct stb6100_state *state, u8 reg, u8 data) { + u8 tmp = data; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + if (unlikely(reg >= STB6100_NUMREGS)) { dprintk(verbose, FE_ERROR, 1, "Invalid register offset 0x%x", reg); return -EREMOTEIO; } - data = (data & stb6100_template[reg].mask) | stb6100_template[reg].set; - return stb6100_write_reg_range(state, &data, reg, 1); + tmp = (tmp & stb6100_template[reg].mask) | stb6100_template[reg].set; + return stb6100_write_reg_range(state, &tmp, reg, 1); } diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index ebad100d913f3..4fa119d83bc58 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -166,7 +166,9 @@ int stv0367_writeregs(struct stv0367_state *state, u16 reg, u8 *data, int len) static int stv0367_writereg(struct stv0367_state *state, u16 reg, u8 data) { - return stv0367_writeregs(state, reg, &data, 1); + u8 tmp = data; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return stv0367_writeregs(state, reg, &tmp, 1); } static u8 stv0367_readreg(struct stv0367_state *state, u16 reg) diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index 0f375df13fbeb..77510bc95dcf8 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c @@ -755,7 +755,9 @@ static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8 static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 data) { - return stv090x_write_regs(state, reg, &data, 1); + u8 tmp = data; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return stv090x_write_regs(state, reg, &tmp, 1); } static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable) diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c index 66eba38f1014c..7e8e01389c55f 100644 --- a/drivers/media/dvb-frontends/stv6110x.c +++ b/drivers/media/dvb-frontends/stv6110x.c @@ -97,7 +97,9 @@ static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 da static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) { - return stv6110x_write_regs(stv6110x, reg, &data, 1); + u8 tmp = data; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return stv6110x_write_regs(stv6110x, reg, &tmp, 1); } static int stv6110x_init(struct dvb_frontend *fe) diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c index 623355fc26661..3208b866d1cb9 100644 --- a/drivers/media/dvb-frontends/zl10039.c +++ b/drivers/media/dvb-frontends/zl10039.c @@ -134,7 +134,9 @@ static inline int zl10039_writereg(struct zl10039_state *state, const enum zl10039_reg_addr reg, const u8 val) { - return zl10039_write(state, reg, &val, 1); + const u8 tmp = val; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */ + + return zl10039_write(state, reg, &tmp, 1); } static int zl10039_init(struct dvb_frontend *fe) -- GitLab From bf3cfaa712e5c396f5fe3b2b2a2ca5dd901de23d Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:39 -0500 Subject: [PATCH 0234/1190] media: staging/imx: get CSI bus type from nearest upstream entity The imx-media driver currently supports a device tree graph of limited complexity. This patch is a first step in allowing imx-media to work with more general OF graphs. The CSI subdevice assumes the originating upstream subdevice (the "sensor") is connected directly to either the CSI mux or the MIPI CSI-2 receiver. But for more complex graphs, the sensor can be distant, with possible bridge entities in between. Thus the sensor's bus type could be quite different from what is entering the CSI. For example a distant sensor could have a parallel interface, but the stream entering the i.MX is MIPI CSI-2. To remove this assumption, get the entering bus config from the entity that is directly upstream from either the CSI mux, or the CSI-2 receiver. If the CSI-2 receiver is not in the enabled pipeline, the bus type to the CSI is parallel, otherwise the CSI is receiving MIPI CSI-2. Note that we can't use the direct upstream source connected to CSI (which is either the CSI mux or the CSI-2 receiver) to determine bus type. The bus entering the CSI from the CSI-2 receiver is a 32-bit parallel bus containing the demultiplexed MIPI CSI-2 virtual channels. But the CSI and its IDMAC channels must be configured based on whether it is receiving data from the CSI-2 receiver or from the CSI mux's parallel interface pins. The function csi_get_upstream_endpoint() is used to find this endpoint. It makes use of a new utility function imx_media_find_upstream_pad(), that if given a grp_id of 0, will return the closest upstream pad from start_entity. With these changes, imx_media_find_sensor() is no longer used and is removed. As a result there is also no longer a need to identify any sensor or set the sensor subdev's group id as a method to search for it. So IMX_MEDIA_GRP_ID_SENSOR is removed. Also the video-mux group id IMX_MEDIA_GRP_ID_VIDMUX was never used so that is removed as well. The remaining IMX_MEDIA_GRP_ID_* definitions are entities internal to the i.MX. Another use of imx_media_find_sensor() in the CSI was to call the sensor's g_skip_frames op to determine if a delay was needed before enabling the CSI at stream on. If necessary this will have to be re-addressed at a later time. Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-csi.c | 188 +++++++++++--------- drivers/staging/media/imx/imx-media-dev.c | 12 -- drivers/staging/media/imx/imx-media-of.c | 21 --- drivers/staging/media/imx/imx-media-utils.c | 63 +++---- drivers/staging/media/imx/imx-media.h | 27 ++- 5 files changed, 150 insertions(+), 161 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index d90cfda1529c9..d7a4b7cd5833b 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -99,8 +100,8 @@ struct csi_priv { /* the mipi virtual channel number at link validate */ int vc_num; - /* the attached sensor at stream on */ - struct imx_media_subdev *sensor; + /* the upstream endpoint CSI is receiving from */ + struct v4l2_fwnode_endpoint upstream_ep; spinlock_t irqlock; /* protect eof_irq handler */ struct timer_list eof_timeout_timer; @@ -120,6 +121,71 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi_priv, sd); } +static inline bool is_parallel_16bit_bus(struct v4l2_fwnode_endpoint *ep) +{ + return ep->bus_type != V4L2_MBUS_CSI2 && + ep->bus.parallel.bus_width >= 16; +} + +/* + * Parses the fwnode endpoint from the source pad of the entity + * connected to this CSI. This will either be the entity directly + * upstream from the CSI-2 receiver, or directly upstream from the + * video mux. The endpoint is needed to determine the bus type and + * bus config coming into the CSI. + */ +static int csi_get_upstream_endpoint(struct csi_priv *priv, + struct v4l2_fwnode_endpoint *ep) +{ + struct device_node *endpoint, *port; + struct imx_media_subdev *imxsd; + struct media_entity *src; + struct v4l2_subdev *sd; + struct media_pad *pad; + + if (!priv->src_sd) + return -EPIPE; + + src = &priv->src_sd->entity; + + if (src->function == MEDIA_ENT_F_VID_MUX) { + /* + * CSI is connected directly to video mux, skip up to + * CSI-2 receiver if it is in the path, otherwise stay + * with video mux. + */ + imxsd = imx_media_find_upstream_subdev(priv->md, src, + IMX_MEDIA_GRP_ID_CSI2); + if (!IS_ERR(imxsd)) + src = &imxsd->sd->entity; + } + + /* get source pad of entity directly upstream from src */ + pad = imx_media_find_upstream_pad(priv->md, src, 0); + if (IS_ERR(pad)) + return PTR_ERR(pad); + + sd = media_entity_to_v4l2_subdev(pad->entity); + + /* + * NOTE: this assumes an OF-graph port id is the same as a + * media pad index. + */ + port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); + if (!port) + return -ENODEV; + + endpoint = of_get_next_child(port, NULL); + of_node_put(port); + if (!endpoint) + return -ENODEV; + + v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); + of_node_put(endpoint); + + return 0; +} + static void csi_idmac_put_ipu_resources(struct csi_priv *priv) { if (priv->idmac_ch) @@ -302,7 +368,6 @@ static void csi_idmac_unsetup_vb2_buf(struct csi_priv *priv, static int csi_idmac_setup_channel(struct csi_priv *priv) { struct imx_media_video_dev *vdev = priv->vdev; - struct v4l2_fwnode_endpoint *sensor_ep; struct v4l2_mbus_framefmt *infmt; struct ipu_image image; u32 passthrough_bits; @@ -312,7 +377,6 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) int ret; infmt = &priv->format_mbus[CSI_SINK_PAD]; - sensor_ep = &priv->sensor->sensor_ep; ipu_cpmem_zero(priv->idmac_ch); @@ -330,7 +394,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) * Check for conditions that require the IPU to handle the * data internally as generic data, aka passthrough mode: * - raw bayer formats - * - the sensor bus is 16-bit parallel + * - the CSI is receiving from a 16-bit parallel bus */ switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: @@ -354,8 +418,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) burst_size = (image.pix.width & 0x3f) ? ((image.pix.width & 0x1f) ? ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64; - passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >= 16); + passthrough = is_parallel_16bit_bus(&priv->upstream_ep); passthrough_bits = 16; /* Skip writing U and V components to odd rows */ ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch); @@ -364,14 +427,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) case V4L2_PIX_FMT_UYVY: burst_size = (image.pix.width & 0x1f) ? ((image.pix.width & 0xf) ? 8 : 16) : 32; - passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >= 16); + passthrough = is_parallel_16bit_bus(&priv->upstream_ep); passthrough_bits = 16; break; default: burst_size = (image.pix.width & 0xf) ? 8 : 16; - passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >= 16); + passthrough = is_parallel_16bit_bus(&priv->upstream_ep); passthrough_bits = 16; break; } @@ -568,22 +629,20 @@ static void csi_idmac_stop(struct csi_priv *priv) static int csi_setup(struct csi_priv *priv) { struct v4l2_mbus_framefmt *infmt, *outfmt; - struct v4l2_mbus_config sensor_mbus_cfg; - struct v4l2_fwnode_endpoint *sensor_ep; + struct v4l2_mbus_config mbus_cfg; struct v4l2_mbus_framefmt if_fmt; infmt = &priv->format_mbus[CSI_SINK_PAD]; outfmt = &priv->format_mbus[priv->active_output_pad]; - sensor_ep = &priv->sensor->sensor_ep; - /* compose mbus_config from sensor endpoint */ - sensor_mbus_cfg.type = sensor_ep->bus_type; - sensor_mbus_cfg.flags = (sensor_ep->bus_type == V4L2_MBUS_CSI2) ? - sensor_ep->bus.mipi_csi2.flags : - sensor_ep->bus.parallel.flags; + /* compose mbus_config from the upstream endpoint */ + mbus_cfg.type = priv->upstream_ep.bus_type; + mbus_cfg.flags = (priv->upstream_ep.bus_type == V4L2_MBUS_CSI2) ? + priv->upstream_ep.bus.mipi_csi2.flags : + priv->upstream_ep.bus.parallel.flags; /* - * we need to pass input sensor frame to CSI interface, but + * we need to pass input frame to CSI interface, but * with translated field type from output format */ if_fmt = *infmt; @@ -595,7 +654,7 @@ static int csi_setup(struct csi_priv *priv) priv->crop.width == 2 * priv->compose.width, priv->crop.height == 2 * priv->compose.height); - ipu_csi_init_interface(priv->csi, &sensor_mbus_cfg, &if_fmt); + ipu_csi_init_interface(priv->csi, &mbus_cfg, &if_fmt); ipu_csi_set_dest(priv->csi, priv->dest); @@ -611,35 +670,11 @@ static int csi_setup(struct csi_priv *priv) static int csi_start(struct csi_priv *priv) { struct v4l2_fract *output_fi, *input_fi; - u32 bad_frames = 0; int ret; - if (!priv->sensor) { - v4l2_err(&priv->sd, "no sensor attached\n"); - return -EINVAL; - } - output_fi = &priv->frame_interval[priv->active_output_pad]; input_fi = &priv->frame_interval[CSI_SINK_PAD]; - ret = v4l2_subdev_call(priv->sensor->sd, sensor, - g_skip_frames, &bad_frames); - if (!ret && bad_frames) { - u32 delay_usec; - - /* - * This sensor has bad frames when it is turned on, - * add a delay to avoid them before enabling the CSI - * hardware. Especially for sensors with a bt.656 interface, - * any shifts in the SAV/EAV sync codes will cause the CSI - * to lose vert/horiz sync. - */ - delay_usec = DIV_ROUND_UP_ULL( - (u64)USEC_PER_SEC * input_fi->numerator * bad_frames, - input_fi->denominator); - usleep_range(delay_usec, delay_usec + 1000); - } - if (priv->dest == IPU_CSI_DEST_IDMAC) { ret = csi_idmac_start(priv); if (ret) @@ -971,9 +1006,8 @@ static int csi_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct csi_priv *priv = v4l2_get_subdevdata(sd); - struct v4l2_fwnode_endpoint *sensor_ep; + struct v4l2_fwnode_endpoint upstream_ep; const struct imx_media_pixfmt *incc; - struct imx_media_subdev *sensor; bool is_csi2; int ret; @@ -982,22 +1016,20 @@ static int csi_link_validate(struct v4l2_subdev *sd, if (ret) return ret; - sensor = __imx_media_find_sensor(priv->md, &priv->sd.entity); - if (IS_ERR(sensor)) { - v4l2_err(&priv->sd, "no sensor attached\n"); - return PTR_ERR(sensor); + ret = csi_get_upstream_endpoint(priv, &upstream_ep); + if (ret) { + v4l2_err(&priv->sd, "failed to find upstream endpoint\n"); + return ret; } mutex_lock(&priv->lock); - priv->sensor = sensor; - sensor_ep = &priv->sensor->sensor_ep; - is_csi2 = (sensor_ep->bus_type == V4L2_MBUS_CSI2); + priv->upstream_ep = upstream_ep; + is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2); incc = priv->cc[CSI_SINK_PAD]; if (priv->dest != IPU_CSI_DEST_IDMAC && - (incc->bayer || (!is_csi2 && - sensor_ep->bus.parallel.bus_width >= 16))) { + (incc->bayer || is_parallel_16bit_bus(&upstream_ep))) { v4l2_err(&priv->sd, "bayer/16-bit parallel buses must go to IDMAC pad\n"); ret = -EINVAL; @@ -1067,12 +1099,8 @@ static void csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, struct v4l2_subdev_pad_config *cfg, struct v4l2_mbus_framefmt *infmt, - struct imx_media_subdev *sensor) + struct v4l2_fwnode_endpoint *upstream_ep) { - struct v4l2_fwnode_endpoint *sensor_ep; - - sensor_ep = &sensor->sensor_ep; - crop->width = min_t(__u32, infmt->width, crop->width); if (crop->left + crop->width > infmt->width) crop->left = infmt->width - crop->width; @@ -1086,7 +1114,7 @@ static void csi_try_crop(struct csi_priv *priv, * sync, so fix it to NTSC/PAL active lines. NTSC contains * 2 extra lines of active video that need to be cropped. */ - if (sensor_ep->bus_type == V4L2_MBUS_BT656 && + if (upstream_ep->bus_type == V4L2_MBUS_BT656 && (V4L2_FIELD_HAS_BOTH(infmt->field) || infmt->field == V4L2_FIELD_ALTERNATE)) { crop->height = infmt->height; @@ -1236,7 +1264,7 @@ static int csi_get_fmt(struct v4l2_subdev *sd, } static void csi_try_fmt(struct csi_priv *priv, - struct imx_media_subdev *sensor, + struct v4l2_fwnode_endpoint *upstream_ep, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *sdformat, struct v4l2_rect *crop, @@ -1304,7 +1332,7 @@ static void csi_try_fmt(struct csi_priv *priv, crop->top = 0; crop->width = sdformat->format.width; crop->height = sdformat->format.height; - csi_try_crop(priv, crop, cfg, &sdformat->format, sensor); + csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); compose->left = 0; compose->top = 0; compose->width = crop->width; @@ -1333,20 +1361,20 @@ static int csi_set_fmt(struct v4l2_subdev *sd, { struct csi_priv *priv = v4l2_get_subdevdata(sd); struct imx_media_video_dev *vdev = priv->vdev; + struct v4l2_fwnode_endpoint upstream_ep; const struct imx_media_pixfmt *cc; - struct imx_media_subdev *sensor; struct v4l2_pix_format vdev_fmt; struct v4l2_mbus_framefmt *fmt; struct v4l2_rect *crop, *compose; - int ret = 0; + int ret; if (sdformat->pad >= CSI_NUM_PADS) return -EINVAL; - sensor = imx_media_find_sensor(priv->md, &priv->sd.entity); - if (IS_ERR(sensor)) { - v4l2_err(&priv->sd, "no sensor attached\n"); - return PTR_ERR(sensor); + ret = csi_get_upstream_endpoint(priv, &upstream_ep); + if (ret) { + v4l2_err(&priv->sd, "failed to find upstream endpoint\n"); + return ret; } mutex_lock(&priv->lock); @@ -1359,7 +1387,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd, crop = __csi_get_crop(priv, cfg, sdformat->which); compose = __csi_get_compose(priv, cfg, sdformat->which); - csi_try_fmt(priv, sensor, cfg, sdformat, crop, compose, &cc); + csi_try_fmt(priv, &upstream_ep, cfg, sdformat, crop, compose, &cc); fmt = __csi_get_fmt(priv, cfg, sdformat->pad, sdformat->which); *fmt = sdformat->format; @@ -1376,8 +1404,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd, format.pad = pad; format.which = sdformat->which; format.format = sdformat->format; - csi_try_fmt(priv, sensor, cfg, &format, NULL, compose, - &outcc); + csi_try_fmt(priv, &upstream_ep, cfg, &format, + NULL, compose, &outcc); outfmt = __csi_get_fmt(priv, cfg, pad, sdformat->which); *outfmt = format.format; @@ -1472,18 +1500,18 @@ static int csi_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct v4l2_fwnode_endpoint upstream_ep; struct v4l2_mbus_framefmt *infmt; struct v4l2_rect *crop, *compose; - struct imx_media_subdev *sensor; - int pad, ret = 0; + int pad, ret; if (sel->pad != CSI_SINK_PAD) return -EINVAL; - sensor = imx_media_find_sensor(priv->md, &priv->sd.entity); - if (IS_ERR(sensor)) { - v4l2_err(&priv->sd, "no sensor attached\n"); - return PTR_ERR(sensor); + ret = csi_get_upstream_endpoint(priv, &upstream_ep); + if (ret) { + v4l2_err(&priv->sd, "failed to find upstream endpoint\n"); + return ret; } mutex_lock(&priv->lock); @@ -1511,7 +1539,7 @@ static int csi_set_selection(struct v4l2_subdev *sd, goto out; } - csi_try_crop(priv, &sel->r, cfg, infmt, sensor); + csi_try_crop(priv, &sel->r, cfg, infmt, &upstream_ep); *crop = sel->r; diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 6a773c76cd9e6..c483b1dfc12e4 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -222,18 +222,6 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, ret = imx_media_get_ipu(imxmd, sd); if (ret) goto out_unlock; - } else if (sd->entity.function == MEDIA_ENT_F_VID_MUX) { - /* this is a video mux */ - sd->grp_id = IMX_MEDIA_GRP_ID_VIDMUX; - } else if (imxsd->num_sink_pads == 0) { - /* - * this is an original source of video frames, it - * could be a camera sensor, an analog decoder, or - * a bridge device (HDMI -> MIPI CSI-2 for example). - * This group ID is used to locate the entity that - * is the original source of video in a pipeline. - */ - sd->grp_id = IMX_MEDIA_GRP_ID_SENSOR; } /* attach the subdev */ diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 12df09f524901..883ad8595c853 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -34,20 +34,6 @@ static int of_add_pad_link(struct imx_media_dev *imxmd, local_pad, remote_pad); } -static void of_parse_sensor(struct imx_media_dev *imxmd, - struct imx_media_subdev *sensor, - struct device_node *sensor_np) -{ - struct device_node *endpoint; - - endpoint = of_graph_get_next_endpoint(sensor_np, NULL); - if (endpoint) { - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), - &sensor->sensor_ep); - of_node_put(endpoint); - } -} - static int of_get_port_count(const struct device_node *np) { struct device_node *ports, *child; @@ -172,13 +158,6 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np, __func__, sd_np->name, num_pads, imxsd->num_sink_pads, imxsd->num_src_pads); - /* - * With no sink, this subdev node is the original source - * of video, parse it's media bus for use by the pipeline. - */ - if (imxsd->num_sink_pads == 0) - of_parse_sensor(imxmd, imxsd, sd_np); - for (i = 0; i < num_pads; i++) { struct device_node *epnode = NULL, *port, *remote_np; struct imx_media_subdev *remote_imxsd; diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 59523872a8866..51d7e184e8d7c 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -730,10 +730,11 @@ int imx_media_add_video_device(struct imx_media_dev *imxmd, EXPORT_SYMBOL_GPL(imx_media_add_video_device); /* - * Search upstream or downstream for a subdevice in the current pipeline + * Search upstream/downstream for a subdevice in the current pipeline * with given grp_id, starting from start_entity. Returns the subdev's - * source/sink pad that it was reached from. Must be called with - * mdev->graph_mutex held. + * source/sink pad that it was reached from. If grp_id is zero, just + * returns the nearest source/sink pad to start_entity. Must be called + * with mdev->graph_mutex held. */ static struct media_pad * find_pipeline_pad(struct imx_media_dev *imxmd, @@ -756,11 +757,16 @@ find_pipeline_pad(struct imx_media_dev *imxmd, if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) continue; - sd = media_entity_to_v4l2_subdev(pad->entity); - if (sd->grp_id & grp_id) - return pad; + if (grp_id != 0) { + sd = media_entity_to_v4l2_subdev(pad->entity); + if (sd->grp_id & grp_id) + return pad; - return find_pipeline_pad(imxmd, pad->entity, grp_id, upstream); + return find_pipeline_pad(imxmd, pad->entity, + grp_id, upstream); + } else { + return pad; + } } return NULL; @@ -789,7 +795,6 @@ find_upstream_subdev(struct imx_media_dev *imxmd, return pad ? media_entity_to_v4l2_subdev(pad->entity) : NULL; } - /* * Find the upstream mipi-csi2 virtual channel reached from the given * start entity in the current pipeline. @@ -813,6 +818,25 @@ int imx_media_find_mipi_csi2_channel(struct imx_media_dev *imxmd, } EXPORT_SYMBOL_GPL(imx_media_find_mipi_csi2_channel); +/* + * Find a source pad reached upstream from the given start entity in + * the current pipeline. Must be called with mdev->graph_mutex held. + */ +struct media_pad * +imx_media_find_upstream_pad(struct imx_media_dev *imxmd, + struct media_entity *start_entity, + u32 grp_id) +{ + struct media_pad *pad; + + pad = find_pipeline_pad(imxmd, start_entity, grp_id, true); + if (!pad) + return ERR_PTR(-ENODEV); + + return pad; +} +EXPORT_SYMBOL_GPL(imx_media_find_upstream_pad); + /* * Find a subdev reached upstream from the given start entity in * the current pipeline. @@ -833,29 +857,6 @@ imx_media_find_upstream_subdev(struct imx_media_dev *imxmd, } EXPORT_SYMBOL_GPL(imx_media_find_upstream_subdev); -struct imx_media_subdev * -__imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity) -{ - return imx_media_find_upstream_subdev(imxmd, start_entity, - IMX_MEDIA_GRP_ID_SENSOR); -} -EXPORT_SYMBOL_GPL(__imx_media_find_sensor); - -struct imx_media_subdev * -imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity) -{ - struct imx_media_subdev *sensor; - - mutex_lock(&imxmd->md.graph_mutex); - sensor = __imx_media_find_sensor(imxmd, start_entity); - mutex_unlock(&imxmd->md.graph_mutex); - - return sensor; -} -EXPORT_SYMBOL_GPL(imx_media_find_sensor); - /* * Turn current pipeline streaming on/off starting from entity. */ diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index a5ae0baa5e19c..2cc19da2f1e16 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -158,9 +158,6 @@ struct imx_media_subdev { struct platform_device *pdev; /* the devname is needed for async devname match */ char devname[32]; - - /* if this is a sensor */ - struct v4l2_fwnode_endpoint sensor_ep; }; struct imx_media_dev { @@ -251,16 +248,14 @@ int imx_media_add_video_device(struct imx_media_dev *imxmd, struct imx_media_video_dev *vdev); int imx_media_find_mipi_csi2_channel(struct imx_media_dev *imxmd, struct media_entity *start_entity); +struct media_pad * +imx_media_find_upstream_pad(struct imx_media_dev *imxmd, + struct media_entity *start_entity, + u32 grp_id); struct imx_media_subdev * imx_media_find_upstream_subdev(struct imx_media_dev *imxmd, struct media_entity *start_entity, u32 grp_id); -struct imx_media_subdev * -__imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity); -struct imx_media_subdev * -imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity); struct imx_media_dma_buf { void *virt; @@ -310,16 +305,14 @@ void imx_media_capture_device_set_format(struct imx_media_video_dev *vdev, void imx_media_capture_device_error(struct imx_media_video_dev *vdev); /* subdev group ids */ -#define IMX_MEDIA_GRP_ID_SENSOR BIT(8) -#define IMX_MEDIA_GRP_ID_VIDMUX BIT(9) -#define IMX_MEDIA_GRP_ID_CSI2 BIT(10) -#define IMX_MEDIA_GRP_ID_CSI_BIT 11 +#define IMX_MEDIA_GRP_ID_CSI2 BIT(8) +#define IMX_MEDIA_GRP_ID_CSI_BIT 9 #define IMX_MEDIA_GRP_ID_CSI (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI0 BIT(IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI1 (2 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_VDIC BIT(13) -#define IMX_MEDIA_GRP_ID_IC_PRP BIT(14) -#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15) -#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(16) +#define IMX_MEDIA_GRP_ID_VDIC BIT(11) +#define IMX_MEDIA_GRP_ID_IC_PRP BIT(12) +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(13) +#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(14) #endif -- GitLab From 621b08eabcddb7a4ed6076dc91324c607be7e6b4 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:40 -0500 Subject: [PATCH 0235/1190] media: staging/imx: remove static media link arrays Remove the static list of media links that were formed at probe time. These links can instead be created after all registered async subdevices have been bound in imx_media_probe_complete(). The media links between subdevices that exist in the device tree, can be created post-async completion by using v4l2_fwnode_parse_link() for each endpoint node of that subdevice. Note this approach assumes device-tree ports are equivalent to media pads (pad index equals port id), and that device-tree endpoints are equivalent to media links between pads. Because links are no longer parsed by imx_media_of_parse(), its sole function is now only to add subdevices that it encounters by walking the OF graph to the async list, so the function has been renamed imx_media_add_of_subdevs(). Similarly, the media links between the IPU-internal subdevice pads (the CSI source pads, and all pads between the vdic, ic-prp, ic-prpenc, and ic-prpvf subdevices), can be created post-async completion by looping through the subdevice's media pads and using the const internal_subdev table. Because links are no longer parsed by imx_media_add_internal_subdevs(), this function no longer needs an array of CSI subdevs to form links from. In summary, the following functions, which were used to form a list of media links at probe time, are removed: imx_media_add_pad_link() add_internal_links() of_add_pad_link() replaced by these functions, called at probe time, which only populate the async subdev list: imx_media_add_of_subdevs() imx_media_add_internal_subdevs() and these functions, called at async completion, which create the media links: imx_media_create_of_links() imx_media_create_csi_of_links() imx_media_create_internal_links() Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media-dev.c | 130 ++--------- .../staging/media/imx/imx-media-internal-sd.c | 219 ++++++++++-------- drivers/staging/media/imx/imx-media-of.c | 189 +++++++++------ drivers/staging/media/imx/imx-media.h | 39 +--- 4 files changed, 281 insertions(+), 296 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index c483b1dfc12e4..09d2deb3734a8 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -127,50 +128,6 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd, return imxsd; } -/* - * Adds an imx-media link to a subdev pad's link list. This is called - * during driver load when forming the links between subdevs. - * - * @pad: the local pad - * @remote_node: the device node of the remote subdev - * @remote_devname: the device name of the remote subdev - * @local_pad: local pad index - * @remote_pad: remote pad index - */ -int imx_media_add_pad_link(struct imx_media_dev *imxmd, - struct imx_media_pad *pad, - struct device_node *remote_node, - const char *remote_devname, - int local_pad, int remote_pad) -{ - struct imx_media_link *link; - int link_idx, ret = 0; - - mutex_lock(&imxmd->mutex); - - link_idx = pad->num_links; - if (link_idx >= IMX_MEDIA_MAX_LINKS) { - dev_err(imxmd->md.dev, "%s: too many links!\n", __func__); - ret = -ENOSPC; - goto out; - } - - link = &pad->link[link_idx]; - - link->remote_sd_node = remote_node; - if (remote_devname) - strncpy(link->remote_devname, remote_devname, - sizeof(link->remote_devname)); - - link->local_pad = local_pad; - link->remote_pad = remote_pad; - - pad->num_links++; -out: - mutex_unlock(&imxmd->mutex); - return ret; -} - /* * get IPU from this CSI and add it to the list of IPUs * the media driver will control. @@ -240,76 +197,38 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, } /* - * Create a single source->sink media link given a subdev and a single - * link from one of its source pads. Called after all subdevs have - * registered. - */ -static int imx_media_create_link(struct imx_media_dev *imxmd, - struct imx_media_subdev *src, - struct imx_media_link *link) -{ - struct imx_media_subdev *sink; - u16 source_pad, sink_pad; - int ret; - - sink = imx_media_find_async_subdev(imxmd, link->remote_sd_node, - link->remote_devname); - if (!sink) { - v4l2_warn(&imxmd->v4l2_dev, "%s: no sink for %s:%d\n", - __func__, src->sd->name, link->local_pad); - return 0; - } - - source_pad = link->local_pad; - sink_pad = link->remote_pad; - - v4l2_info(&imxmd->v4l2_dev, "%s: %s:%d -> %s:%d\n", __func__, - src->sd->name, source_pad, sink->sd->name, sink_pad); - - ret = media_create_pad_link(&src->sd->entity, source_pad, - &sink->sd->entity, sink_pad, 0); - if (ret) - v4l2_err(&imxmd->v4l2_dev, - "create_pad_link failed: %d\n", ret); - - return ret; -} - -/* - * create the media links from all imx-media pads and their links. + * create the media links from all pads and their links. * Called after all subdevs have registered. */ static int imx_media_create_links(struct imx_media_dev *imxmd) { struct imx_media_subdev *imxsd; - struct imx_media_link *link; - struct imx_media_pad *pad; - int num_pads, i, j, k; - int ret = 0; + struct v4l2_subdev *sd; + int i, ret; for (i = 0; i < imxmd->num_subdevs; i++) { imxsd = &imxmd->subdev[i]; - num_pads = imxsd->num_sink_pads + imxsd->num_src_pads; - - for (j = 0; j < num_pads; j++) { - pad = &imxsd->pad[j]; - - /* only create the source->sink links */ - if (!(pad->pad.flags & MEDIA_PAD_FL_SOURCE)) - continue; - - for (k = 0; k < pad->num_links; k++) { - link = &pad->link[k]; + sd = imxsd->sd; - ret = imx_media_create_link(imxmd, imxsd, link); - if (ret) - goto out; - } + if (((sd->grp_id & IMX_MEDIA_GRP_ID_CSI) || imxsd->pdev)) { + /* this is an internal subdev or a CSI */ + ret = imx_media_create_internal_links(imxmd, imxsd); + if (ret) + return ret; + /* + * the CSIs straddle between the external and the IPU + * internal entities, so create the external links + * to the CSI sink pads. + */ + if (sd->grp_id & IMX_MEDIA_GRP_ID_CSI) + imx_media_create_csi_of_links(imxmd, imxsd); + } else { + /* this is an external fwnode subdev */ + imx_media_create_of_links(imxmd, imxsd); } } -out: - return ret; + return 0; } /* @@ -550,7 +469,6 @@ static int imx_media_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; - struct imx_media_subdev *csi[4] = {0}; struct imx_media_dev *imxmd; int ret; @@ -581,14 +499,14 @@ static int imx_media_probe(struct platform_device *pdev) dev_set_drvdata(imxmd->v4l2_dev.dev, imxmd); - ret = imx_media_of_parse(imxmd, &csi, node); + ret = imx_media_add_of_subdevs(imxmd, node); if (ret) { v4l2_err(&imxmd->v4l2_dev, - "imx_media_of_parse failed with %d\n", ret); + "add_of_subdevs failed with %d\n", ret); goto unreg_dev; } - ret = imx_media_add_internal_subdevs(imxmd, csi); + ret = imx_media_add_internal_subdevs(imxmd); if (ret) { v4l2_err(&imxmd->v4l2_dev, "add_internal_subdevs failed with %d\n", ret); diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c b/drivers/staging/media/imx/imx-media-internal-sd.c index cdfbf40dfcbeb..3e60df5f12d67 100644 --- a/drivers/staging/media/imx/imx-media-internal-sd.c +++ b/drivers/staging/media/imx/imx-media-internal-sd.c @@ -60,14 +60,19 @@ static const struct internal_subdev_id { }, }; +struct internal_subdev; + struct internal_link { - const struct internal_subdev_id *remote_id; + const struct internal_subdev *remote; + int local_pad; int remote_pad; }; +/* max links per internal-sd pad */ +#define MAX_INTERNAL_LINKS 8 + struct internal_pad { - bool devnode; /* does this pad link to a device node */ - struct internal_link link[IMX_MEDIA_MAX_LINKS]; + struct internal_link link[MAX_INTERNAL_LINKS]; }; static const struct internal_subdev { @@ -75,7 +80,7 @@ static const struct internal_subdev { struct internal_pad pad[IMX_MEDIA_MAX_PADS]; int num_sink_pads; int num_src_pads; -} internal_subdev[num_isd] = { +} int_subdev[num_isd] = { [isd_csi0] = { .id = &isd_id[isd_csi0], .num_sink_pads = CSI_NUM_SINK_PADS, @@ -83,17 +88,16 @@ static const struct internal_subdev { .pad[CSI_SRC_PAD_DIRECT] = { .link = { { - .remote_id = &isd_id[isd_ic_prp], + .local_pad = CSI_SRC_PAD_DIRECT, + .remote = &int_subdev[isd_ic_prp], .remote_pad = PRP_SINK_PAD, }, { - .remote_id = &isd_id[isd_vdic], + .local_pad = CSI_SRC_PAD_DIRECT, + .remote = &int_subdev[isd_vdic], .remote_pad = VDIC_SINK_PAD_DIRECT, }, }, }, - .pad[CSI_SRC_PAD_IDMAC] = { - .devnode = true, - }, }, [isd_csi1] = { @@ -103,30 +107,27 @@ static const struct internal_subdev { .pad[CSI_SRC_PAD_DIRECT] = { .link = { { - .remote_id = &isd_id[isd_ic_prp], + .local_pad = CSI_SRC_PAD_DIRECT, + .remote = &int_subdev[isd_ic_prp], .remote_pad = PRP_SINK_PAD, }, { - .remote_id = &isd_id[isd_vdic], + .local_pad = CSI_SRC_PAD_DIRECT, + .remote = &int_subdev[isd_vdic], .remote_pad = VDIC_SINK_PAD_DIRECT, }, }, }, - .pad[CSI_SRC_PAD_IDMAC] = { - .devnode = true, - }, }, [isd_vdic] = { .id = &isd_id[isd_vdic], .num_sink_pads = VDIC_NUM_SINK_PADS, .num_src_pads = VDIC_NUM_SRC_PADS, - .pad[VDIC_SINK_PAD_IDMAC] = { - .devnode = true, - }, .pad[VDIC_SRC_PAD_DIRECT] = { .link = { { - .remote_id = &isd_id[isd_ic_prp], + .local_pad = VDIC_SRC_PAD_DIRECT, + .remote = &int_subdev[isd_ic_prp], .remote_pad = PRP_SINK_PAD, }, }, @@ -140,7 +141,8 @@ static const struct internal_subdev { .pad[PRP_SRC_PAD_PRPENC] = { .link = { { - .remote_id = &isd_id[isd_ic_prpenc], + .local_pad = PRP_SRC_PAD_PRPENC, + .remote = &int_subdev[isd_ic_prpenc], .remote_pad = 0, }, }, @@ -148,7 +150,8 @@ static const struct internal_subdev { .pad[PRP_SRC_PAD_PRPVF] = { .link = { { - .remote_id = &isd_id[isd_ic_prpvf], + .local_pad = PRP_SRC_PAD_PRPVF, + .remote = &int_subdev[isd_ic_prpvf], .remote_pad = 0, }, }, @@ -159,68 +162,114 @@ static const struct internal_subdev { .id = &isd_id[isd_ic_prpenc], .num_sink_pads = PRPENCVF_NUM_SINK_PADS, .num_src_pads = PRPENCVF_NUM_SRC_PADS, - .pad[PRPENCVF_SRC_PAD] = { - .devnode = true, - }, }, [isd_ic_prpvf] = { .id = &isd_id[isd_ic_prpvf], .num_sink_pads = PRPENCVF_NUM_SINK_PADS, .num_src_pads = PRPENCVF_NUM_SRC_PADS, - .pad[PRPENCVF_SRC_PAD] = { - .devnode = true, - }, }, }; -/* form a device name given a group id and ipu id */ -static inline void isd_id_to_devname(char *devname, int sz, - const struct internal_subdev_id *id, - int ipu_id) +/* form a device name given an internal subdev and ipu id */ +static inline void isd_to_devname(char *devname, int sz, + const struct internal_subdev *isd, + int ipu_id) { - int pdev_id = ipu_id * num_isd + id->index; + int pdev_id = ipu_id * num_isd + isd->id->index; - snprintf(devname, sz, "%s.%d", id->name, pdev_id); + snprintf(devname, sz, "%s.%d", isd->id->name, pdev_id); } -/* adds the links from given internal subdev */ -static int add_internal_links(struct imx_media_dev *imxmd, - const struct internal_subdev *isd, - struct imx_media_subdev *imxsd, - int ipu_id) +static const struct internal_subdev *find_intsd_by_grp_id(u32 grp_id) { - int i, num_pads, ret; + enum isd_enum i; + + for (i = 0; i < num_isd; i++) { + const struct internal_subdev *isd = &int_subdev[i]; - num_pads = isd->num_sink_pads + isd->num_src_pads; + if (isd->id->grp_id == grp_id) + return isd; + } - for (i = 0; i < num_pads; i++) { - const struct internal_pad *intpad = &isd->pad[i]; - struct imx_media_pad *pad = &imxsd->pad[i]; - int j; + return NULL; +} - /* init the pad flags for this internal subdev */ - pad->pad.flags = (i < isd->num_sink_pads) ? - MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - /* export devnode pad flag to the subdevs */ - pad->devnode = intpad->devnode; +static struct imx_media_subdev *find_sink(struct imx_media_dev *imxmd, + struct imx_media_subdev *src, + const struct internal_link *link) +{ + char sink_devname[32]; + int ipu_id; + + /* + * retrieve IPU id from subdev name, note: can't get this from + * struct imx_media_internal_sd_platformdata because if src is + * a CSI, it has different struct ipu_client_platformdata which + * does not contain IPU id. + */ + if (sscanf(src->sd->name, "ipu%d", &ipu_id) != 1) + return NULL; + + isd_to_devname(sink_devname, sizeof(sink_devname), + link->remote, ipu_id - 1); + + return imx_media_find_async_subdev(imxmd, NULL, sink_devname); +} - for (j = 0; ; j++) { - const struct internal_link *link; - char remote_devname[32]; +static int create_ipu_internal_link(struct imx_media_dev *imxmd, + struct imx_media_subdev *src, + const struct internal_link *link) +{ + struct imx_media_subdev *sink; + int ret; + + sink = find_sink(imxmd, src, link); + if (!sink) + return -ENODEV; + v4l2_info(&imxmd->v4l2_dev, "%s:%d -> %s:%d\n", + src->sd->name, link->local_pad, + sink->sd->name, link->remote_pad); + + ret = media_create_pad_link(&src->sd->entity, link->local_pad, + &sink->sd->entity, link->remote_pad, 0); + if (ret) + v4l2_err(&imxmd->v4l2_dev, + "create_pad_link failed: %d\n", ret); + + return ret; +} + +int imx_media_create_internal_links(struct imx_media_dev *imxmd, + struct imx_media_subdev *imxsd) +{ + struct v4l2_subdev *sd = imxsd->sd; + const struct internal_subdev *intsd; + const struct internal_pad *intpad; + const struct internal_link *link; + struct media_pad *pad; + int i, j, ret; + + intsd = find_intsd_by_grp_id(imxsd->sd->grp_id); + if (!intsd) + return -ENODEV; + + /* create the source->sink links */ + for (i = 0; i < sd->entity.num_pads; i++) { + intpad = &intsd->pad[i]; + pad = &sd->entity.pads[i]; + + if (!(pad->flags & MEDIA_PAD_FL_SOURCE)) + continue; + + for (j = 0; ; j++) { link = &intpad->link[j]; - if (!link->remote_id) + if (!link->remote) break; - isd_id_to_devname(remote_devname, - sizeof(remote_devname), - link->remote_id, ipu_id); - - ret = imx_media_add_pad_link(imxmd, pad, - NULL, remote_devname, - i, link->remote_pad); + ret = create_ipu_internal_link(imxmd, imxsd, link); if (ret) return ret; } @@ -230,10 +279,9 @@ static int add_internal_links(struct imx_media_dev *imxmd, } /* register an internal subdev as a platform device */ -static struct imx_media_subdev * -add_internal_subdev(struct imx_media_dev *imxmd, - const struct internal_subdev *isd, - int ipu_id) +static int add_internal_subdev(struct imx_media_dev *imxmd, + const struct internal_subdev *isd, + int ipu_id) { struct imx_media_internal_sd_platformdata pdata; struct platform_device_info pdevinfo = {0}; @@ -258,73 +306,58 @@ add_internal_subdev(struct imx_media_dev *imxmd, pdev = platform_device_register_full(&pdevinfo); if (IS_ERR(pdev)) - return ERR_CAST(pdev); + return PTR_ERR(pdev); imxsd = imx_media_add_async_subdev(imxmd, NULL, pdev); if (IS_ERR(imxsd)) - return imxsd; + return PTR_ERR(imxsd); imxsd->num_sink_pads = isd->num_sink_pads; imxsd->num_src_pads = isd->num_src_pads; - return imxsd; + return 0; } /* adds the internal subdevs in one ipu */ -static int add_ipu_internal_subdevs(struct imx_media_dev *imxmd, - struct imx_media_subdev *csi0, - struct imx_media_subdev *csi1, - int ipu_id) +static int add_ipu_internal_subdevs(struct imx_media_dev *imxmd, int ipu_id) { enum isd_enum i; - int ret; for (i = 0; i < num_isd; i++) { - const struct internal_subdev *isd = &internal_subdev[i]; - struct imx_media_subdev *imxsd; + const struct internal_subdev *isd = &int_subdev[i]; + int ret; /* * the CSIs are represented in the device-tree, so those - * devices are added already, and are added to the async - * subdev list by of_parse_subdev(), so we are given those - * subdevs as csi0 and csi1. + * devices are already added to the async subdev list by + * of_parse_subdev(). */ switch (isd->id->grp_id) { case IMX_MEDIA_GRP_ID_CSI0: - imxsd = csi0; - break; case IMX_MEDIA_GRP_ID_CSI1: - imxsd = csi1; + ret = 0; break; default: - imxsd = add_internal_subdev(imxmd, isd, ipu_id); + ret = add_internal_subdev(imxmd, isd, ipu_id); break; } - if (IS_ERR(imxsd)) - return PTR_ERR(imxsd); - - /* add the links from this subdev */ - if (imxsd) { - ret = add_internal_links(imxmd, isd, imxsd, ipu_id); - if (ret) - return ret; - } + if (ret) + return ret; } return 0; } -int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd, - struct imx_media_subdev *csi[4]) +int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd) { int ret; - ret = add_ipu_internal_subdevs(imxmd, csi[0], csi[1], 0); + ret = add_ipu_internal_subdevs(imxmd, 0); if (ret) goto remove; - ret = add_ipu_internal_subdevs(imxmd, csi[2], csi[3], 1); + ret = add_ipu_internal_subdevs(imxmd, 1); if (ret) goto remove; diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 883ad8595c853..d35c99e9f0494 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -20,20 +20,6 @@ #include