From a49d25364dfb9f8a64037488a39ab1f56c5fa419 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 17 Feb 2017 16:55:17 +0000 Subject: staging/atomisp: Add support for the Intel IPU v2 This patch adds support for the Intel IPU v2 as found on Android and IoT Baytrail-T and Baytrail-CR platforms (those with the IPU PCI mapped). You will also need the firmware files from your device (Android usually puts them into /etc) - or you can find them in the downloadable restore/upgrade kits if you blew them away for some reason. It may be possible to extend the driver to handle the BYT/T windows platforms such as the ASUS T100TA. These platforms don't expose the IPU via the PCI interface but via ACPI buried in the GPU description and with the camera information somewhere unknown so would need a platform driver interface adding to the codebase *IFF* the firmware works on such devices. To get good results you also need a suitable support library such as libxcam. The camera is intended to be driven from Android so it has a lot of features that many desktop apps don't fully spport. In theory all the pieces are there to build it with -DISP2401 and some differing files to get CherryTrail/T support, but unifying the drivers properlly is a work in progress. The IPU driver represents the work of a lot of people within Intel over many years. It's historical goal was portability rather than Linux upstream. Any queries about the upstream aimed driver should be sent to me not to the original authors. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- .../media/atomisp/pci/atomisp2/atomisp_drvfs.c | 218 +++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c (limited to 'drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c') diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c new file mode 100644 index 0000000..327a5c5 --- /dev/null +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c @@ -0,0 +1,218 @@ +/* + * Support for atomisp driver sysfs interface + * + * Copyright (c) 2014 Intel Corporation. All Rights Reserved. + * + * 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. + * + * 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. + * + */ + +#include +#include +#include + +#include "atomisp_compat.h" +#include "atomisp_internal.h" +#include "atomisp_ioctl.h" +#include "hmm/hmm.h" + +/* + * _iunit_debug: + * dbglvl: iunit css driver trace level + * dbgopt: iunit debug option: + * bit 0: binary list + * bit 1: running binary + * bit 2: memory statistic +*/ +struct _iunit_debug { + struct pci_driver *drv; + struct atomisp_device *isp; + unsigned int dbglvl; + unsigned int dbgfun; + unsigned int dbgopt; +}; + +#define OPTION_BIN_LIST (1<<0) +#define OPTION_BIN_RUN (1<<1) +#define OPTION_MEM_STAT (1<<2) +#define OPTION_VALID (OPTION_BIN_LIST \ + | OPTION_BIN_RUN \ + | OPTION_MEM_STAT) + +static struct _iunit_debug iunit_debug = { + .dbglvl = 0, + .dbgopt = OPTION_BIN_LIST, +}; + +static inline int iunit_dump_dbgopt(struct atomisp_device *isp, + unsigned int opt) +{ + int ret = 0; + + if (opt & OPTION_VALID) { + if (opt & OPTION_BIN_LIST) { + ret = atomisp_css_dump_blob_infor(); + if (ret) { + dev_err(atomisp_dev, "%s dump blob infor err[ret:%d]\n", + __func__, ret); + goto opt_err; + } + } + + if (opt & OPTION_BIN_RUN) { + if (atomisp_streaming_count(isp)) { + atomisp_css_dump_sp_raw_copy_linecount(true); + atomisp_css_debug_dump_isp_binary(); + } else { + ret = -EPERM; + dev_err(atomisp_dev, "%s dump running bin err[ret:%d]\n", + __func__, ret); + goto opt_err; + } + } + + if (opt & OPTION_MEM_STAT) + hmm_show_mem_stat(__func__, __LINE__); + } else { + ret = -EINVAL; + dev_err(atomisp_dev, "%s dump nothing[ret=%d]\n", __func__, + ret); + } + +opt_err: + return ret; +} + +static ssize_t iunit_dbglvl_show(struct device_driver *drv, char *buf) +{ + iunit_debug.dbglvl = atomisp_css_debug_get_dtrace_level(); + return sprintf(buf, "dtrace level:%u\n", iunit_debug.dbglvl); +} + +static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf, + size_t size) +{ + if (kstrtouint(buf, 10, &iunit_debug.dbglvl) + || iunit_debug.dbglvl < 1 + || iunit_debug.dbglvl > 9) { + dev_err(atomisp_dev, "%s setting %d value invalid, should be [1,9]\n", + __func__, iunit_debug.dbglvl); + return -EINVAL; + } + atomisp_css_debug_set_dtrace_level(iunit_debug.dbglvl); + + return size; +} + +static ssize_t iunit_dbgfun_show(struct device_driver *drv, char *buf) +{ + iunit_debug.dbgfun = atomisp_get_css_dbgfunc(); + return sprintf(buf, "dbgfun opt:%u\n", iunit_debug.dbgfun); +} + +static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf, + size_t size) +{ + unsigned int opt; + int ret; + + if (kstrtouint(buf, 10, &opt)) { + dev_err(atomisp_dev, "%s setting %d value invalid\n", + __func__, opt); + return -EINVAL; + } + + ret = atomisp_set_css_dbgfunc(iunit_debug.isp, opt); + if (ret) + return ret; + + iunit_debug.dbgfun = opt; + + return size; +} + +static ssize_t iunit_dbgopt_show(struct device_driver *drv, char *buf) +{ + return sprintf(buf, "option:0x%x\n", iunit_debug.dbgopt); +} + +static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf, + size_t size) +{ + unsigned int opt; + int ret; + + if (kstrtouint(buf, 10, &opt)) { + dev_err(atomisp_dev, "%s setting %d value invalid\n", + __func__, opt); + return -EINVAL; + } + + iunit_debug.dbgopt = opt; + ret = iunit_dump_dbgopt(iunit_debug.isp, iunit_debug.dbgopt); + if (ret) + return ret; + + return size; +} + +static struct driver_attribute iunit_drvfs_attrs[] = { + __ATTR(dbglvl, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbglvl_show, + iunit_dbglvl_store), + __ATTR(dbgfun, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgfun_show, + iunit_dbgfun_store), + __ATTR(dbgopt, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgopt_show, + iunit_dbgopt_store), +}; + +static int iunit_drvfs_create_files(struct pci_driver *drv) +{ + int i, ret = 0; + + for (i = 0; i < ARRAY_SIZE(iunit_drvfs_attrs); i++) + ret |= driver_create_file(&(drv->driver), + &iunit_drvfs_attrs[i]); + + return ret; +} + +static void iunit_drvfs_remove_files(struct pci_driver *drv) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(iunit_drvfs_attrs); i++) + driver_remove_file(&(drv->driver), &iunit_drvfs_attrs[i]); +} + +int atomisp_drvfs_init(struct pci_driver *drv, struct atomisp_device *isp) +{ + int ret; + + iunit_debug.isp = isp; + iunit_debug.drv = drv; + + ret = iunit_drvfs_create_files(iunit_debug.drv); + if (ret) { + dev_err(atomisp_dev, "drvfs_create_files error: %d\n", ret); + iunit_drvfs_remove_files(drv); + } + + return ret; +} + +void atomisp_drvfs_exit(void) +{ + iunit_drvfs_remove_files(iunit_debug.drv); +} -- cgit v1.1 From 2bbe97830ae623a519291eece719ee74108571ff Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 14 Mar 2017 10:51:50 +0300 Subject: staging/atomisp: silence uninitialized variable warnings These print an uninitialized value for "opt". Let's just remove the printk. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c') diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c index 327a5c5..7f7c6d5 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c @@ -128,11 +128,9 @@ static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf, unsigned int opt; int ret; - if (kstrtouint(buf, 10, &opt)) { - dev_err(atomisp_dev, "%s setting %d value invalid\n", - __func__, opt); - return -EINVAL; - } + ret = kstrtouint(buf, 10, &opt); + if (ret) + return ret; ret = atomisp_set_css_dbgfunc(iunit_debug.isp, opt); if (ret) @@ -154,11 +152,9 @@ static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf, unsigned int opt; int ret; - if (kstrtouint(buf, 10, &opt)) { - dev_err(atomisp_dev, "%s setting %d value invalid\n", - __func__, opt); - return -EINVAL; - } + ret = kstrtouint(buf, 10, &opt); + if (ret) + return ret; iunit_debug.dbgopt = opt; ret = iunit_dump_dbgopt(iunit_debug.isp, iunit_debug.dbgopt); -- cgit v1.1 From 3797616eaa3000f5526aab8ef02000a92fbc5415 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 20 Mar 2017 14:42:41 +0000 Subject: atomisp: remove a sysfs error message that can be used to log spam Instead of logging this just report ERANGE as an error, which will give something close to the right user space report. The others of these were already removed by Dan Carpenter's patch. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c') diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c index 7f7c6d5..fcfe8d7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c @@ -107,9 +107,7 @@ static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf, if (kstrtouint(buf, 10, &iunit_debug.dbglvl) || iunit_debug.dbglvl < 1 || iunit_debug.dbglvl > 9) { - dev_err(atomisp_dev, "%s setting %d value invalid, should be [1,9]\n", - __func__, iunit_debug.dbglvl); - return -EINVAL; + return -ERANGE; } atomisp_css_debug_set_dtrace_level(iunit_debug.dbglvl); -- cgit v1.1 From 976b7c8a05fdaacfea700cc99a46c87bac7c0712 Mon Sep 17 00:00:00 2001 From: Derek Robson Date: Mon, 27 Mar 2017 16:14:23 +0100 Subject: Staging: atomisp - octal permissions, style fix Changed permissions to octal style Found using checkpatch Signed-off-by: Derek Robson Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c') diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c index fcfe8d7..1ae2358 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c @@ -163,12 +163,9 @@ static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf, } static struct driver_attribute iunit_drvfs_attrs[] = { - __ATTR(dbglvl, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbglvl_show, - iunit_dbglvl_store), - __ATTR(dbgfun, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgfun_show, - iunit_dbgfun_store), - __ATTR(dbgopt, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgopt_show, - iunit_dbgopt_store), + __ATTR(dbglvl, 0644, iunit_dbglvl_show, iunit_dbglvl_store), + __ATTR(dbgfun, 0644, iunit_dbgfun_show, iunit_dbgfun_store), + __ATTR(dbgopt, 0644, iunit_dbgopt_show, iunit_dbgopt_store), }; static int iunit_drvfs_create_files(struct pci_driver *drv) -- cgit v1.1