From e1ac35b39ac13814146559f80fe003977383d933 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 20 Apr 2020 09:19:56 +0200 Subject: [PATCH] media: atomisp: add a way for the driver to know the chipset version The atomisp supports two different chipsets: ISP2400 and ISP2401. Right now, this is controlled by ugly #defines inside the driver. Add a global bolean to identify the type of hardware. While this is hacky, it would be a quick way to start removing the ugly ifdefs. Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/include/linux/atomisp.h | 3 ++ .../media/atomisp/pci/atomisp2/atomisp_v4l2.c | 36 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index 47153e3b7755..e9670749bae0 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -69,6 +69,9 @@ #define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW 0x800b #endif +/* FIXME: for now, let's use a boolean to identify the type of atomisp chipset */ +extern bool atomisp_hw_is_isp2401; + /* Configuration used by Bayer noise reduction and YCC noise reduction */ struct atomisp_nr_config { /* [gain] Strength of noise reduction for Bayer NR (Used by Bayer NR) */ diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c index 5a624a5ae56b..8e3d2df74eaa 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c @@ -105,6 +105,21 @@ int pad_h = 16; module_param(pad_h, int, 0644); MODULE_PARM_DESC(pad_h, "extra data for ISP processing"); +/* + * FIXME: this is a hack to make easier to support ISP2401 variant. + * As a given system will either be ISP2401 or not, we can just use + * a boolean, in order to replace existing #ifdef ISP2401 everywhere. + * + * Once this driver gets into a better shape, however, the best would + * be to replace this to something stored inside atomisp allocated + * structures. + */ +bool atomisp_hw_is_isp2401; + +/* Types of atomisp hardware */ +#define HW_IS_ISP2400 0 +#define HW_IS_ISP2401 1 + struct device *atomisp_dev; void __iomem *atomisp_io_base; @@ -1169,6 +1184,11 @@ static int atomisp_pci_probe(struct pci_dev *dev, /* Pointer to struct device. */ atomisp_dev = &dev->dev; + if (id->driver_data == HW_IS_ISP2401) + atomisp_hw_is_isp2401 = true; + else + atomisp_hw_is_isp2401 = false; + pdata = atomisp_get_platform_data(); if (!pdata) dev_warn(&dev->dev, "no platform data available\n"); @@ -1514,18 +1534,22 @@ static void atomisp_pci_remove(struct pci_dev *dev) } static const struct pci_device_id atomisp_pci_tbl[] = { +/* + * FIXME: + * remove the ifs once we get rid of the ifs on other parts of the driver + */ #if defined(ISP2400) || defined(ISP2400B0) /* Merrifield */ - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1178)}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1179)}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x117a)}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1178), .driver_data = HW_IS_ISP2400}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1179), .driver_data = HW_IS_ISP2400}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x117a), .driver_data = HW_IS_ISP2400}, /* Baytrail */ - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f38)}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f38), .driver_data = HW_IS_ISP2400}, #elif defined(ISP2401) /* Anniedale (Merrifield+ / Moorefield) */ - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1478)}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1478), .driver_data = HW_IS_ISP2401}, /* Cherrytrail */ - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x22b8)}, + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x22b8), .driver_data = HW_IS_ISP2401}, #endif {0,} }; -- 2.11.0