Re: [git pull] uaccess comedi compat

2020-06-03 Thread pr-tracker-bot
The pull request you sent on Wed, 3 Jun 2020 20:31:27 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git uaccess.comedi

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2e63f6ce7ed2c4ff83ba30ad9ccad422289a6c63

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-03 Thread Jim Quinlan
The new field in struct device 'dma_pfn_offset_map' is used to facilitate
the use of multiple pfn offsets between cpu addrs and dma addrs.  It
subsumes the role of dev->dma_pfn_offset -- a uniform offset -- and
designates the single offset a special case.

of_dma_configure() is the typical manner to set pfn offsets but there
are a number of ad hoc assignments to dev->dma_pfn_offset in the
kernel code.  These cases now invoke the function
attach_uniform_dma_pfn_offset(dev, pfn_offset).

Signed-off-by: Jim Quinlan 
---
 arch/arm/include/asm/dma-mapping.h|  9 +-
 arch/arm/mach-keystone/keystone.c |  9 +-
 arch/sh/drivers/pci/pcie-sh7786.c |  3 +-
 arch/sh/kernel/dma-coherent.c | 17 ++--
 arch/x86/pci/sta2x11-fixup.c  |  7 +-
 drivers/acpi/arm64/iort.c |  5 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c |  7 +-
 drivers/iommu/io-pgtable-arm.c|  2 +-
 .../platform/sunxi/sun4i-csi/sun4i_csi.c  |  5 +-
 .../platform/sunxi/sun6i-csi/sun6i_csi.c  |  5 +-
 drivers/of/address.c  | 93 +--
 drivers/of/device.c   |  8 +-
 drivers/remoteproc/remoteproc_core.c  |  2 +-
 .../staging/media/sunxi/cedrus/cedrus_hw.c|  7 +-
 drivers/usb/core/message.c|  4 +-
 drivers/usb/core/usb.c|  2 +-
 include/linux/device.h|  4 +-
 include/linux/dma-direct.h| 16 +++-
 include/linux/dma-mapping.h   | 45 +
 kernel/dma/coherent.c | 11 ++-
 20 files changed, 210 insertions(+), 51 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h 
b/arch/arm/include/asm/dma-mapping.h
index bdd80ddbca34..f1e72f99468b 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -35,8 +35,9 @@ static inline const struct dma_map_ops 
*get_arch_dma_ops(struct bus_type *bus)
 #ifndef __arch_pfn_to_dma
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
-   if (dev)
-   pfn -= dev->dma_pfn_offset;
+   if (dev && dev->dma_pfn_offset_map)
+   pfn -= dma_pfn_offset_from_phys_addr(dev, PFN_PHYS(pfn));
+
return (dma_addr_t)__pfn_to_bus(pfn);
 }
 
@@ -44,8 +45,8 @@ static inline unsigned long dma_to_pfn(struct device *dev, 
dma_addr_t addr)
 {
unsigned long pfn = __bus_to_pfn(addr);
 
-   if (dev)
-   pfn += dev->dma_pfn_offset;
+   if (dev && dev->dma_pfn_offset_map)
+   pfn += dma_pfn_offset_from_dma_addr(dev, addr);
 
return pfn;
 }
diff --git a/arch/arm/mach-keystone/keystone.c 
b/arch/arm/mach-keystone/keystone.c
index 638808c4e122..e7d3ee6e9cb5 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -8,6 +8,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,9 +39,11 @@ static int keystone_platform_notifier(struct notifier_block 
*nb,
return NOTIFY_BAD;
 
if (!dev->of_node) {
-   dev->dma_pfn_offset = keystone_dma_pfn_offset;
-   dev_err(dev, "set dma_pfn_offset%08lx\n",
-   dev->dma_pfn_offset);
+   int ret = attach_uniform_dma_pfn_offset
+   (dev, keystone_dma_pfn_offset);
+
+   dev_err(dev, "set dma_pfn_offset%08lx%s\n",
+   dev->dma_pfn_offset, ret ? " failed" : "");
}
return NOTIFY_OK;
 }
diff --git a/arch/sh/drivers/pci/pcie-sh7786.c 
b/arch/sh/drivers/pci/pcie-sh7786.c
index e0b568aaa701..2e832a5c58c1 100644
--- a/arch/sh/drivers/pci/pcie-sh7786.c
+++ b/arch/sh/drivers/pci/pcie-sh7786.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -487,7 +488,7 @@ int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 
slot, u8 pin)
 
 void pcibios_bus_add_device(struct pci_dev *pdev)
 {
-   pdev->dev.dma_pfn_offset = dma_pfn_offset;
+   attach_uniform_dma_pfn_offset(>dev, dma_pfn_offset);
 }
 
 static int __init sh7786_pcie_core_init(void)
diff --git a/arch/sh/kernel/dma-coherent.c b/arch/sh/kernel/dma-coherent.c
index d4811691b93c..5fc9e358b6c7 100644
--- a/arch/sh/kernel/dma-coherent.c
+++ b/arch/sh/kernel/dma-coherent.c
@@ -14,6 +14,8 @@ void *arch_dma_alloc(struct device *dev, size_t size, 
dma_addr_t *dma_handle,
 {
void *ret, *ret_nocache;
int order = get_order(size);
+   unsigned long pfn;
+   phys_addr_t phys;
 
gfp |= __GFP_ZERO;
 
@@ -34,11 +36,14 @@ void *arch_dma_alloc(struct device *dev, size_t size, 
dma_addr_t *dma_handle,
return NULL;
}
 
-   split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order);
+   phys = virt_to_phys(ret);
+   pfn =  phys >> PAGE_SHIFT;
+   split_page(pfn_to_page(pfn), order);
 
-   *dma_handle = 

[PATCH v3 00/13] PCI: brcmstb: enable PCIe for STB chips

2020-06-03 Thread Jim Quinlan
v3:
  Commit "device core: Introduce multiple dma pfn offsets"
  Commit "arm: dma-mapping: Invoke dma offset func if needed"
  -- The above two commits have been squashed.  More importantly,
 the code has been modified so that the functionality for
 multiple pfn offsets subsumes the use of dev->dma_pfn_offset.
 In fact, dma_pfn_offset is removed and supplanted by
 dma_pfn_offset_map, which is a pointer to an array.  The
 more common case of a uniform offset is now handled as
 a map with a single entry, while cases requiring multiple
 pfn offsets use a map with multiple entries.  Code paths
 that used to do this:

 dev->dma_pfn_offset = mydrivers_pfn_offset;

 have been changed to do this:

 attach_uniform_dma_pfn_offset(dev, pfn_offset);

  Commit "dt-bindings: PCI: Add bindings for more Brcmstb chips"
  -- Add if/then clause for required props: resets, reset-names (RobH)
  -- Change compatible list from const to enum (RobH)
  -- Change list of u32-tuples to u64 (RobH)

  Commit "of: Include a dev param in of_dma_get_range()"
  -- modify of/unittests.c to add NULL param in of_dma_get_range() call.

  Commit "device core: Add ability to handle multiple dma offsets"
  -- align comment in device.h (AndyS).
  -- s/cpu_beg/cpu_start/ and s/dma_beg/dma_start/ in struct
 dma_pfn_offset_region (AndyS).

v2:
Commit: "device core: Add ability to handle multiple dma offsets"
  o Added helper func attach_dma_pfn_offset_map() in address.c (Chistoph)
  o Helpers funcs added to __phys_to_dma() & __dma_to_phys() (Christoph)
  o Added warning when multiple offsets are needed and !DMA_PFN_OFFSET_MAP
  o dev->dma_pfn_map => dev->dma_pfn_offset_map
  o s/frm/from/ for dma_pfn_offset_frm_{phys,dma}_addr() (Christoph)
  o In device.h: s/const void */const struct dma_pfn_offset_region */
  o removed 'unlikely' from unlikely(dev->dma_pfn_offset_map) since
guarded by CONFIG_DMA_PFN_OFFSET_MAP (Christoph)
  o Since dev->dma_pfn_offset is copied in usb/core/{usb,message}.c, now
dev->dma_pfn_offset_map is copied as well.
  o Merged two of the DMA commits into one (Christoph).

Commit "arm: dma-mapping: Invoke dma offset func if needed":
  o Use helper functions instead of #if CONFIG_DMA_PFN_OFFSET

Other commits' changes:
  o Removed need for carrying of_id var in priv (Nicolas)
  o Commit message rewordings (Bjorn)
  o Commit log messages filled to 75 chars (Bjorn)
  o devm_reset_control_get_shared())
=> devm_reset_control_get_optional_shared (Philipp)
  o Add call to reset_control_assert() in PCIe remove routines (Philipp)

v1:
This patchset expands the usefulness of the Broadcom Settop Box PCIe
controller by building upon the PCIe driver used currently by the
Raspbery Pi.  Other forms of this patchset were submitted by me years
ago and not accepted; the major sticking point was the code required
for the DMA remapping needed for the PCIe driver to work [1].

There have been many changes to the DMA and OF subsystems since that
time, making a cleaner and less intrusive patchset possible.  This
patchset implements a generalization of "dev->dma_pfn_offset", except
that instead of a single scalar offset it provides for multiple
offsets via a function which depends upon the "dma-ranges" property of
the PCIe host controller.  This is required for proper functionality
of the BrcmSTB PCIe controller and possibly some other devices.

[1] 
https://lore.kernel.org/linux-arm-kernel/1516058925-46522-5-git-send-email-jim2101...@gmail.com/

Jim Quinlan (13):
  PCI: brcmstb: PCIE_BRCMSTB depends on ARCH_BRCMSTB
  ata: ahci_brcm: Fix use of BCM7216 reset controller
  dt-bindings: PCI: Add bindings for more Brcmstb chips
  PCI: brcmstb: Add bcm7278 reigister info
  PCI: brcmstb: Add suspend and resume pm_ops
  PCI: brcmstb: Add bcm7278 PERST support
  PCI: brcmstb: Add control of rescal reset
  of: Include a dev param in of_dma_get_range()
  device core: Introduce multiple dma pfn offsets
  PCI: brcmstb: Set internal memory viewport sizes
  PCI: brcmstb: Accommodate MSI for older chips
  PCI: brcmstb: Set bus max burst size by chip type
  PCI: brcmstb: Add bcm7211, bcm7216, bcm7445, bcm7278 to match list

 .../bindings/pci/brcm,stb-pcie.yaml   |  58 ++-
 arch/arm/include/asm/dma-mapping.h|   9 +-
 arch/arm/mach-keystone/keystone.c |   9 +-
 arch/sh/drivers/pci/pcie-sh7786.c |   3 +-
 arch/sh/kernel/dma-coherent.c |  17 +-
 arch/x86/pci/sta2x11-fixup.c  |   7 +-
 drivers/acpi/arm64/iort.c |   5 +-
 drivers/ata/ahci_brcm.c   |  14 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c |   7 +-
 drivers/iommu/io-pgtable-arm.c|   2 +-
 .../platform/sunxi/sun4i-csi/sun4i_csi.c  |   5 +-
 .../platform/sunxi/sun6i-csi/sun6i_csi.c  |   5 +-
 drivers/of/address.c  |  97 -
 drivers/of/device.c   |  10 +-
 

[git pull] uaccess comedi compat

2020-06-03 Thread Al Viro
comedi compat ioctls done saner (killing the single biggest pile
of __get_user/__put_user outside of arch/* in process).

The following changes since commit 8f3d9f354286745c751374f5f1fcafee6b3f3136:

  Linux 5.7-rc1 (2020-04-12 12:35:55 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git uaccess.comedi

for you to fetch changes up to bac42fb21259783cb748ae54227a5e755340a396:

  comedi: get rid of compat_alloc_user_space() mess in COMEDI_CMD{,TEST} compat 
(2020-05-29 10:06:01 -0400)


Al Viro (10):
  comedi: move compat ioctl handling to native fops
  comedi: get rid of indirection via translated_ioctl()
  comedi: get rid of compat_alloc_user_space() mess in COMEDI_CHANINFO 
compat
  comedi: get rid of compat_alloc_user_space() mess in COMEDI_RANGEINFO 
compat
  comedi: get rid of compat_alloc_user_space() mess in COMEDI_INSN compat
  comedi: get rid of compat_alloc_user_space() mess in COMEDI_INSNLIST 
compat
  comedi: lift copy_from_user() into callers of __comedi_get_user_cmd()
  comedi: do_cmdtest_ioctl(): lift copyin/copyout into the caller
  comedi: do_cmd_ioctl(): lift copyin/copyout into the caller
  comedi: get rid of compat_alloc_user_space() mess in COMEDI_CMD{,TEST} 
compat

 drivers/staging/comedi/Makefile  |   1 -
 drivers/staging/comedi/comedi_compat32.c | 455 -
 drivers/staging/comedi/comedi_compat32.h |  28 --
 drivers/staging/comedi/comedi_fops.c | 564 +--
 drivers/staging/comedi/comedi_internal.h |   2 +-
 drivers/staging/comedi/range.c   |  17 +-
 6 files changed, 467 insertions(+), 600 deletions(-)
 delete mode 100644 drivers/staging/comedi/comedi_compat32.c
 delete mode 100644 drivers/staging/comedi/comedi_compat32.h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH v1 6/6] staging: greybus: audio: Enable GB codec, audio module compilation.

2020-06-03 Thread Vaibhav Agarwal
On Tue, Jun 02, 2020 at 03:57:15PM +0300, Dan Carpenter wrote:
> On Tue, Jun 02, 2020 at 10:51:15AM +0530, Vaibhav Agarwal wrote:
> > Currently, GB codec and audio module is conditionally compiled based on
> > GREYBUS_AUDIO_MSM8994. However, audio module is not dependent on MSM8994
> > platform and can be used generically with any platform that follows
> > GB Audio class specification.
> > 
> > Also, GB codec driver corresponds to dummy codec represented by I2S port
> > available on Toshiba AP Bridge. Added config option for the same in
> > kconfig file and accordingly updated Makefile.
> > 
> 
> This commit message was a bit confusing to me.  Just say:
> 
> "Currently you can't enable the Grey Bus Audio Codec because there is no
> entry for it in the Kconfig file.  Originally the config name was going
> to be AUDIO_MSM8994 but that's not correct because other types of
> hardware are supported now.  I have chosen the name AUDIO_APB_CODEC
> instead.  Also I had to update the dependencies for GREYBUS_AUDIO to
> make the compile work."
> 
> Otherwise this looks fine.

Thanks Dan for sharing your valuable feedback. I'll make the suggested 
changes for the complete series in v2 patchset.

regards,
vaibhav

> 
> regards,
> dan carpenter
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


HELLO: I AM MRS SUSAN JONES

2020-06-03 Thread Mrs.Susan Jones
-- 
OUR GOLDEN OPPORTUNITY

Hello Dear Friend,

Complement of the day, i hope you are doing great today. However, I am
Mrs.Susan Jones, an auditor with one of the new generation banks here
in Burkina Faso.

I am writing you this letter based on the latest development at my
Department. i discovered some abandoned huge amount of money, Ten
Million, Five hundred thousand  United States Dollars.($10.500.000).
Now I am only contacting you as a foreigner because this money cannot
be approved to a local bank account here, but can only be approved to
any foreign account and foreign beneficiary because the money is in US
dollars

This will be  a legitimate transaction once you accept to build trust
with me and follow simple instruction doing the transfer process,
until the total sum transfer out of the bank here to your own bank
account any where in the world, and I agreed to share the total money
50/50 with you once you successful confirmed it in your bank account.
But any expenses doing the transfer process will be deduct from the
amount before sharing, If you are interested to work with me and
provide a good receiving bank account, get back to me as soon as
possible with the following details below.

Your full name
Your Profession
Your direct mobile phone number
Your Scanned International passport or any of your identity

NOTE: PLEASE IT YOU ARE NOT INTERESTED DON'T BORDER TO RESPOND BACK TO
AVOID TIME WASTED.

As soon as I receive these data's, I will forward to you the
application form which you will send to the bank for the claim and
transfer of the fund into your bank account as the  new beneficial.

I am waiting to hear from you soon

Yours
Mrs.Susan Jones
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


HELLO: I AM MRS SUSAN JONES

2020-06-03 Thread Mrs.Susan Jones
-- 
OUR GOLDEN OPPORTUNITY

Hello Dear Friend,

Complement of the day, i hope you are doing great today. However, I am
Mrs.Susan Jones, an auditor with one of the new generation banks here
in Burkina Faso.

I am writing you this letter based on the latest development at my
Department. i discovered some abandoned huge amount of money, Ten
Million, Five hundred thousand  United States Dollars.($10.500.000).
Now I am only contacting you as a foreigner because this money cannot
be approved to a local bank account here, but can only be approved to
any foreign account and foreign beneficiary because the money is in US
dollars

This will be  a legitimate transaction once you accept to build trust
with me and follow simple instruction doing the transfer process,
until the total sum transfer out of the bank here to your own bank
account any where in the world, and I agreed to share the total money
50/50 with you once you successful confirmed it in your bank account.
But any expenses doing the transfer process will be deduct from the
amount before sharing, If you are interested to work with me and
provide a good receiving bank account, get back to me as soon as
possible with the following details below.

Your full name
Your Profession
Your direct mobile phone number
Your Scanned International passport or any of your identity

NOTE: PLEASE IT YOU ARE NOT INTERESTED DON'T BORDER TO RESPOND BACK TO
AVOID TIME WASTED.

As soon as I receive these data's, I will forward to you the
application form which you will send to the bank for the claim and
transfer of the fund into your bank account as the  new beneficial.

I am waiting to hear from you soon

Yours
Mrs.Susan Jones
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: rtl8723bs: prevent buffer overflow in update_sta_support_rate()

2020-06-03 Thread Dan Carpenter
The "ie_len" variable is in the 0-255 range and it comes from the
network.  If it's over NDIS_802_11_LENGTH_RATES_EX (16) then that will
lead to memory corruption.

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Signed-off-by: Dan Carpenter 
---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 69bcd172b2987..a3ea7ce3e12e9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1824,12 +1824,14 @@ int update_sta_support_rate(struct adapter *padapter, 
u8 *pvar_ie, uint var_ie_l
pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, 
_SUPPORTEDRATES_IE_, _len, var_ie_len);
if (!pIE)
return _FAIL;
+   if (ie_len > sizeof(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates))
+   return _FAIL;
 
memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, 
ie_len);
supportRateNum = ie_len;
 
pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, 
_EXT_SUPPORTEDRATES_IE_, _len, var_ie_len);
-   if (pIE)
+   if (pIE && (ie_len <= 
sizeof(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates) - supportRateNum))
memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + 
supportRateNum), pIE->data, ie_len);
 
return _SUCCESS;
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/15] media: atomisp: get rid of a detection hack for a BYT Andorid-based tablet

2020-06-03 Thread Mauro Carvalho Chehab
There's a hack at the driver that selects a different table
for a BYT tablet, which sets the maximum frequency to 320 MHz,
instead of 400 MHz.

After looking at the Intel Aero Yocto's version from:

https://download.01.org/aero/deb/pool/main/l/linux-4.4.76-aero-1.3/

It was noticed that this depends on an Android-specific modprobe parameter,
which uses a macro (INTEL_MID_BOARD) from this file:

arch/x86/include/asm/spid.h

>From the comments there, it looks like this macro parses a
variable passed at boot time:

cmdline : androidboot.spid=vend:cust:manu:plat:prod:hard

The devices in question are identified there as:

INTEL_BYT_TABLET_BLK_PRO = 0x
INTEL_BYT_TABLET_BLK_ENG = 0x8000

Well, this is something that we don't have upstream. So,
without further details about that, we can't really parse it.

If we ever end supporting those devices with the upstream driver,
this patch can be reverted and the device can be detected
via DMI (or maybe via PCI ID?).

Signed-off-by: Mauro Carvalho Chehab 
---
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 83 ---
 1 file changed, 18 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 5ac63c77570a..c7f6b621ef3f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -354,60 +354,6 @@ static const struct atomisp_dfs_config dfs_config_byt = {
.dfs_table_size = ARRAY_SIZE(dfs_rules_byt),
 };
 
-static const struct atomisp_freq_scaling_rule dfs_rules_byt_cr[] = {
-   {
-   .width = ISP_FREQ_RULE_ANY,
-   .height = ISP_FREQ_RULE_ANY,
-   .fps = ISP_FREQ_RULE_ANY,
-   .isp_freq = ISP_FREQ_320MHZ,
-   .run_mode = ATOMISP_RUN_MODE_VIDEO,
-   },
-   {
-   .width = ISP_FREQ_RULE_ANY,
-   .height = ISP_FREQ_RULE_ANY,
-   .fps = ISP_FREQ_RULE_ANY,
-   .isp_freq = ISP_FREQ_320MHZ,
-   .run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-   },
-   {
-   .width = ISP_FREQ_RULE_ANY,
-   .height = ISP_FREQ_RULE_ANY,
-   .fps = ISP_FREQ_RULE_ANY,
-   .isp_freq = ISP_FREQ_320MHZ,
-   .run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-   },
-   {
-   .width = ISP_FREQ_RULE_ANY,
-   .height = ISP_FREQ_RULE_ANY,
-   .fps = ISP_FREQ_RULE_ANY,
-   .isp_freq = ISP_FREQ_320MHZ,
-   .run_mode = ATOMISP_RUN_MODE_PREVIEW,
-   },
-   {
-   .width = ISP_FREQ_RULE_ANY,
-   .height = ISP_FREQ_RULE_ANY,
-   .fps = ISP_FREQ_RULE_ANY,
-   .isp_freq = ISP_FREQ_320MHZ,
-   .run_mode = ATOMISP_RUN_MODE_SDV,
-   },
-};
-
-#ifdef FIXME
-/*
- * Disable this, as it is used only when this is true:
- * INTEL_MID_BOARD(3, TABLET, BYT, BLK, PRO, CRV2) ||
- * INTEL_MID_BOARD(3, TABLET, BYT, BLK, ENG, CRV2))
- * However, the original code is commented
- */
-static const struct atomisp_dfs_config dfs_config_byt_cr = {
-   .lowest_freq = ISP_FREQ_200MHZ,
-   .max_freq_at_vmin = ISP_FREQ_320MHZ,
-   .highest_freq = ISP_FREQ_320MHZ,
-   .dfs_table = dfs_rules_byt_cr,
-   .dfs_table_size = ARRAY_SIZE(dfs_rules_byt_cr),
-};
-#endif
-
 static const struct atomisp_freq_scaling_rule dfs_rules_cht[] = {
{
.width = ISP_FREQ_RULE_ANY,
@@ -1696,17 +1642,24 @@ static int atomisp_pci_probe(struct pci_dev *dev,
(ATOMISP_HW_REVISION_ISP2400
 << ATOMISP_HW_REVISION_SHIFT) |
ATOMISP_HW_STEPPING_B0;
-#ifdef FIXME
-   if (INTEL_MID_BOARD(3, TABLET, BYT, BLK, PRO, CRV2) ||
-   INTEL_MID_BOARD(3, TABLET, BYT, BLK, ENG, CRV2)) {
-   isp->dfs = _config_byt_cr;
-   isp->hpll_freq = HPLL_FREQ_2000MHZ;
-   } else
-#endif
-   {
-   isp->dfs = _config_byt;
-   isp->hpll_freq = HPLL_FREQ_1600MHZ;
-   }
+
+   /*
+* Note: some Intel-based tablets with Android use a different
+* DFS table. Based on the comments at the Yocto Aero meta
+* version of this driver (at the ssid.h header), they're
+* identified via a "spid" var:
+*
+*  androidboot.spid=vend:cust:manu:plat:prod:hard
+*
+* As we don't have this upstream, nor we know enough details
+* to use a DMI or PCI match table, the old code was just
+* removed, but let's keep a note here as a reminder that,
+* for certain devices, we may need to limit the max DFS
+* frequency to be below certain 

[PATCH 12/15] media: atomisp: use different dfs failed messages

2020-06-03 Thread Mauro Carvalho Chehab
There are several parts of the driver that could produce
a "dfs failed!" message. Change the texts, in order to help
identifying from where they're coming.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c   | 4 ++--
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 4252d3d37649..6c324815c0f6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -1407,10 +1407,10 @@ static void __atomisp_css_recover(struct atomisp_device 
*isp, bool isp_timeout)
   atomisp_css_valid_sof(isp));
 
if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_AUTO, true) < 0)
-   dev_dbg(isp->dev, "dfs failed!\n");
+   dev_dbg(isp->dev, "DFS auto failed while 
recovering!\n");
} else {
if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, true) < 0)
-   dev_dbg(isp->dev, "dfs failed!\n");
+   dev_dbg(isp->dev, "DFS max failed while recovering!\n");
}
 
for (i = 0; i < isp->num_of_streams; i++) {
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 0a76f388b38b..15567623b51b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -1810,15 +1810,15 @@ static int atomisp_streamon(struct file *file, void *fh,
if (atomisp_streaming_count(isp) > 1) {
if (atomisp_freq_scaling(isp,
 ATOMISP_DFS_MODE_MAX, false) < 
0)
-   dev_dbg(isp->dev, "dfs failed!\n");
+   dev_dbg(isp->dev, "DFS max mode failed!\n");
} else {
if (atomisp_freq_scaling(isp,
 ATOMISP_DFS_MODE_AUTO, false) 
< 0)
-   dev_dbg(isp->dev, "dfs failed!\n");
+   dev_dbg(isp->dev, "DFS auto mode failed!\n");
}
} else {
if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, false) < 0)
-   dev_dbg(isp->dev, "dfs failed!\n");
+   dev_dbg(isp->dev, "DFS max mode failed!\n");
}
 
if (asd->depth_mode->val && atomisp_streaming_count(isp) ==
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/15] media: atomisp: get rid of a duplicated file

2020-06-03 Thread Mauro Carvalho Chehab
The contents of hive_isp_css_2401_irq_types_hrt.h and
hive_isp_css_common/irq_global.h are identical, except for
one unused enum:

On isp2401, this IRQ line has this name:

hrt_isp_css_irq_is2401 = HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID,

While the same bit is named as:
hrt_isp_css_irq_isp_pmem_error = HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID,

At the isp2400 version.

Remove one of them, in order to reduce the code differences
between those two versions.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_2401_irq_types_hrt.h | 69 ---
 .../pci/hive_isp_css_common/irq_global.h  | 10 +--
 ...sp_css_irq_types_hrt.h => irq_types_hrt.h} |  0
 3 files changed, 1 insertion(+), 78 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_2401_irq_types_hrt.h
 rename 
drivers/staging/media/atomisp/pci/{css_2400_system/hrt/hive_isp_css_irq_types_hrt.h
 => irq_types_hrt.h} (100%)

diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_2401_irq_types_hrt.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_2401_irq_types_hrt.h
deleted file mode 100644
index 69fefe634a6a..
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_2401_irq_types_hrt.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _HIVE_ISP_CSS_2401_IRQ_TYPES_HRT_H_
-#define _HIVE_ISP_CSS_2401_IRQ_TYPES_HRT_H_
-
-/*
- * These are the indices of each interrupt in the interrupt
- * controller's registers. these can be used as the irq_id
- * argument to the hrt functions irq_controller.h.
- *
- * The definitions are taken from _defs.h
- */
-typedef enum hrt_isp_css_irq {
-   hrt_isp_css_irq_gpio_pin_0   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_0_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_1   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_1_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_2   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_2_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_3   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_3_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_4   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_4_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_5   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_5_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_6   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_6_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_7   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_7_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_8   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_8_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_9   = 
HIVE_GP_DEV_IRQ_GPIO_PIN_9_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_10  = 
HIVE_GP_DEV_IRQ_GPIO_PIN_10_BIT_ID,
-   hrt_isp_css_irq_gpio_pin_11  = 
HIVE_GP_DEV_IRQ_GPIO_PIN_11_BIT_ID,
-   hrt_isp_css_irq_sp   = HIVE_GP_DEV_IRQ_SP_BIT_ID,
-   hrt_isp_css_irq_isp  = HIVE_GP_DEV_IRQ_ISP_BIT_ID,
-   hrt_isp_css_irq_isys = HIVE_GP_DEV_IRQ_ISYS_BIT_ID,
-   hrt_isp_css_irq_isel = HIVE_GP_DEV_IRQ_ISEL_BIT_ID,
-   hrt_isp_css_irq_ifmt = HIVE_GP_DEV_IRQ_IFMT_BIT_ID,
-   hrt_isp_css_irq_sp_stream_mon= 
HIVE_GP_DEV_IRQ_SP_STREAM_MON_BIT_ID,
-   hrt_isp_css_irq_isp_stream_mon   = 
HIVE_GP_DEV_IRQ_ISP_STREAM_MON_BIT_ID,
-   hrt_isp_css_irq_mod_stream_mon   = 
HIVE_GP_DEV_IRQ_MOD_STREAM_MON_BIT_ID,
-   hrt_isp_css_irq_is2401   = 
HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_isp_bamem_error  = 
HIVE_GP_DEV_IRQ_ISP_BAMEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_isp_dmem_error   = 
HIVE_GP_DEV_IRQ_ISP_DMEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_sp_icache_mem_error  = 
HIVE_GP_DEV_IRQ_SP_ICACHE_MEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_sp_dmem_error= 
HIVE_GP_DEV_IRQ_SP_DMEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_mmu_cache_mem_error  = 
HIVE_GP_DEV_IRQ_MMU_CACHE_MEM_ERROR_BIT_ID,
-   hrt_isp_css_irq_gp_timer_0   = 
HIVE_GP_DEV_IRQ_GP_TIMER_0_BIT_ID,
-   hrt_isp_css_irq_gp_timer_1   = 
HIVE_GP_DEV_IRQ_GP_TIMER_1_BIT_ID,
-   hrt_isp_css_irq_sw_pin_0 = HIVE_GP_DEV_IRQ_SW_PIN_0_BIT_ID,
-   hrt_isp_css_irq_sw_pin_1 = HIVE_GP_DEV_IRQ_SW_PIN_1_BIT_ID,
-   hrt_isp_css_irq_dma  = HIVE_GP_DEV_IRQ_DMA_BIT_ID,
-   hrt_isp_css_irq_sp_stream_mon_b  = 
HIVE_GP_DEV_IRQ_SP_STREAM_MON_B_BIT_ID,
-   /* this must (obviously) be the last on in the enum */
-   hrt_isp_css_irq_num_irqs
-} 

[PATCH 00/15] More atomisp fixes and cleanups

2020-06-03 Thread Mauro Carvalho Chehab
Most of the code here is meant to make the IRQ handling code clearer,
and the ISP frequency setting (DFS).

There's a fix there at the DFS setting: right now, if the sensor doesn't
provide the number of frames per second, DFS is kept on its minimal
value, with will likely fail. The logic at patch 13 changes it to default
to the maximum value. While this will drain more power, the camera
should be able to work.

Mauro Carvalho Chehab (15):
  media: atomisp: improve IRQ handling debug messages
  media: atomisp: do some cleanup at irq_local.h
  media: atomisp: get rid of a duplicated file
  media: atomisp: get rid of ifdef nonsense
  media: atomisp: simplify IRQ ifdef logic
  media: atomisp: remove some unused defines from *mamoiada_params.h
  media: atomisp: use just one mamoiada_params.h
  media: atomisp: get rid of a detection hack for a BYT Andorid-based
tablet
  media: atomisp: don't set hpll_freq twice with different values
  media: atomisp: use macros from intel-family.h
  media: atomisp: change the detection of ISP2401 at runtime
  media: atomisp: use different dfs failed messages
  media: atomisp: set DFS to MAX if sensor doesn't report fps
  media: atomisp: use strscpy() instead of less secure variants
  media: atomisp: get rid of a string_support.h abstraction layer

 .../media/atomisp/include/linux/atomisp.h |   3 -
 .../atomisp/include/linux/atomisp_platform.h  |  21 +-
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  71 +++---
 .../media/atomisp/pci/atomisp_common.h|   4 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  14 +-
 .../staging/media/atomisp/pci/atomisp_file.c  |   2 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c |   2 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  46 ++--
 .../media/atomisp/pci/atomisp_subdev.c|   2 +-
 .../staging/media/atomisp/pci/atomisp_tpg.c   |   2 +-
 .../media/atomisp/pci/atomisp_trace_event.h   |   6 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 110 +++--
 .../pci/camera/pipe/src/pipe_binarydesc.c |   4 +-
 .../hrt/isp2400_mamoiada_params.h | 229 --
 .../pci/hive_isp_css_2401_irq_types_hrt.h |  69 --
 .../pci/hive_isp_css_common/host/irq.c|  29 +--
 .../pci/hive_isp_css_common/host/irq_local.h  |  17 +-
 .../pci/hive_isp_css_common/irq_global.h  |  10 +-
 .../pci/hive_isp_css_common/isp_global.h  |  12 +-
 .../pci/hive_isp_css_common/sp_global.h   |  10 -
 .../hive_isp_css_include/host/irq_public.h|  16 +-
 .../pci/hive_isp_css_include/string_support.h | 165 -
 ...sp_css_irq_types_hrt.h => irq_types_hrt.h} |   0
 .../ctc/ctc_1.0/ia_css_ctc_table.host.c   |   3 +-
 .../kernels/gc/gc_1.0/ia_css_gc_table.host.c  |   3 +-
 .../kernels/gc/gc_2/ia_css_gc2_table.host.c   |   3 +-
 .../xnr/xnr_1.0/ia_css_xnr_table.host.c   |   3 +-
 .../atomisp/pci/isp2400_input_system_local.h  |  15 +-
 .../media/atomisp/pci/isp2400_system_global.h |  31 ---
 .../media/atomisp/pci/isp2400_system_local.h  |   8 -
 .../media/atomisp/pci/isp2401_system_global.h |  31 ---
 .../media/atomisp/pci/isp2401_system_local.h  |   8 -
 ...01_mamoiada_params.h => mamoiada_params.h} |  20 +-
 .../atomisp/pci/runtime/binary/src/binary.c   |   4 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  65 ++---
 .../pci/runtime/isys/src/virtual_isys.c   |  29 +--
 .../tagger/interface/ia_css_tagger_common.h   |   4 -
 drivers/staging/media/atomisp/pci/sh_css.c|  50 ++--
 .../media/atomisp/pci/sh_css_firmware.c   |   6 +-
 .../media/atomisp/pci/sh_css_internal.h   |  10 -
 .../staging/media/atomisp/pci/sh_css_mipi.c   |   8 +-
 .../staging/media/atomisp/pci/sh_css_params.c |  22 +-
 drivers/staging/media/atomisp/pci/sh_css_sp.c |   5 +-
 .../media/atomisp/pci/sh_css_version.c|   5 +-
 44 files changed, 247 insertions(+), 930 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/css_2400_system/hrt/isp2400_mamoiada_params.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_2401_irq_types_hrt.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h
 rename 
drivers/staging/media/atomisp/pci/{css_2400_system/hrt/hive_isp_css_irq_types_hrt.h
 => irq_types_hrt.h} (100%)
 rename drivers/staging/media/atomisp/pci/{isp2401_mamoiada_params.h => 
mamoiada_params.h} (91%)

-- 
2.26.2


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] media: atomisp: use macros from intel-family.h

2020-06-03 Thread Mauro Carvalho Chehab
Instead of hardcoding the intel family values there, use
the already defined ones from asm/intel-family.h.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/atomisp/include/linux/atomisp_platform.h | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h 
b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
index 4bf76a780b6d..395d7c022ad1 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
@@ -18,6 +18,8 @@
 #ifndef ATOMISP_PLATFORM_H_
 #define ATOMISP_PLATFORM_H_
 
+#include 
+
 #include 
 #include 
 #include 
@@ -240,9 +242,9 @@ const struct atomisp_camera_caps 
*atomisp_get_default_camera_caps(void);
 boot_cpu_data.x86 == 6 &&   \
 boot_cpu_data.x86_model == x)
 
-#define IS_MFLD__IS_SOC(0x27)
-#define IS_BYT __IS_SOC(0x37)
-#define IS_CHT __IS_SOC(0x4C)
-#define IS_MOFD__IS_SOC(0x5A)
+#define IS_MFLD__IS_SOC(INTEL_FAM6_ATOM_SALTWELL_MID)
+#define IS_BYT __IS_SOC(INTEL_FAM6_ATOM_SILVERMONT)
+#define IS_CHT __IS_SOC(INTEL_FAM6_ATOM_AIRMONT)
+#define IS_MOFD__IS_SOC(INTEL_FAM6_ATOM_AIRMONT_MID)
 
 #endif /* ATOMISP_PLATFORM_H_ */
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] media: atomisp: improve IRQ handling debug messages

2020-06-03 Thread Mauro Carvalho Chehab
When an IRQ is not handled, it is nice to know what's the
reason.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index d06173b62b99..875dd3ce6e48 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -566,7 +566,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)
 
if (irq_infos & IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
dev_dbg_ratelimited(isp->dev,
-   "irq:0x%x 
(IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF)\n",
+   "irq:0x%x (SOF)\n",
irq_infos);
irq_infos &= ~IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF;
}
@@ -591,14 +591,14 @@ irqreturn_t atomisp_isr(int irq, void *dev)
/* EOF Event does not have the css_pipe returned */
asd = __get_asd_from_port(isp, eof_event.event.port);
if (!asd) {
-   dev_err(isp->dev, "%s:no subdev.event:%d",
+   dev_err(isp->dev, "%s: ISYS event, but no 
subdev.event:%d",
__func__, eof_event.event.type);
continue;
}
 
atomisp_eof_event(asd, eof_event.event.exp_id);
dev_dbg_ratelimited(isp->dev,
-   "%s EOF exp_id %d, asd %d\n",
+   "%s ISYS event: EOF exp_id %d, asd 
%d\n",
__func__, eof_event.event.exp_id,
asd->index);
}
@@ -610,7 +610,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)
 
spin_unlock_irqrestore(>lock, flags);
 
-   dev_dbg_ratelimited(isp->dev, "irq:0x%x\n", irq_infos);
+   dev_dbg_ratelimited(isp->dev, "irq:0x%x (unhandled)\n", irq_infos);
 
return IRQ_WAKE_THREAD;
 
@@ -618,7 +618,8 @@ irqreturn_t atomisp_isr(int irq, void *dev)
spin_unlock_irqrestore(>lock, flags);
 
if (irq_infos)
-   dev_dbg_ratelimited(isp->dev, "irq:0x%x\n", irq_infos);
+   dev_dbg_ratelimited(isp->dev, "irq:0x%x (ignored, as not 
streaming anymore)\n",
+   irq_infos);
 
return IRQ_HANDLED;
 }
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/15] media: atomisp: set DFS to MAX if sensor doesn't report fps

2020-06-03 Thread Mauro Carvalho Chehab
If the sensor doesn't implement support for g_frame_interval,
it won't return the expected fps rate.

Instead of keeping DFS on its minimal value (which will likely
not work), set it to the max.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 6c324815c0f6..845fa851029a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -243,8 +243,12 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
fps = atomisp_get_sensor_fps(asd);
-   if (fps == 0)
-   return -EINVAL;
+   if (fps == 0) {
+   dev_info(isp->dev,
+"Sensor didn't report FPS. Using DFS max mode.\n");
+   new_freq = dfs->highest_freq;
+   goto done;
+   }
 
curr_rules.width = asd->fmt[asd->capture_pad].fmt.width;
curr_rules.height = asd->fmt[asd->capture_pad].fmt.height;
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/15] media: atomisp: change the detection of ISP2401 at runtime

2020-06-03 Thread Mauro Carvalho Chehab
Instead of having a static var to detect it, let's use the
already-existing arch-specific bytes, as this is how other
parts of the code also checks when it needs to do something
different, depending on an specific chipset version.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/atomisp/include/linux/atomisp.h |  3 --
 .../atomisp/include/linux/atomisp_platform.h  | 11 -
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 48 +--
 .../media/atomisp/pci/atomisp_common.h|  4 --
 .../media/atomisp/pci/atomisp_compat_css20.c  | 14 +++---
 .../staging/media/atomisp/pci/atomisp_ioctl.c | 28 +--
 .../media/atomisp/pci/atomisp_subdev.c|  2 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 17 ++-
 .../pci/camera/pipe/src/pipe_binarydesc.c |  4 +-
 .../atomisp/pci/runtime/binary/src/binary.c   |  4 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  8 ++--
 drivers/staging/media/atomisp/pci/sh_css.c| 40 
 .../media/atomisp/pci/sh_css_firmware.c   |  4 +-
 .../staging/media/atomisp/pci/sh_css_mipi.c   |  8 ++--
 .../staging/media/atomisp/pci/sh_css_params.c | 22 -
 drivers/staging/media/atomisp/pci/sh_css_sp.c |  2 +-
 .../media/atomisp/pci/sh_css_version.c|  3 +-
 17 files changed, 108 insertions(+), 114 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h 
b/drivers/staging/media/atomisp/include/linux/atomisp.h
index 6a6aa45fa550..9803a2b2e132 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp.h
@@ -70,9 +70,6 @@
 #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/include/linux/atomisp_platform.h 
b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
index 395d7c022ad1..873344a02ccf 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h
@@ -19,6 +19,7 @@
 #define ATOMISP_PLATFORM_H_
 
 #include 
+#include 
 
 #include 
 #include 
@@ -240,11 +241,19 @@ const struct atomisp_camera_caps 
*atomisp_get_default_camera_caps(void);
 /* API from old platform_camera.h, new CPUID implementation */
 #define __IS_SOC(x) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
 boot_cpu_data.x86 == 6 &&   \
-boot_cpu_data.x86_model == x)
+boot_cpu_data.x86_model == (x))
+#define __IS_SOCS(x,y) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
+   boot_cpu_data.x86 == 6 &&   \
+   (boot_cpu_data.x86_model == (x) || \
+boot_cpu_data.x86_model == (y)))
 
 #define IS_MFLD__IS_SOC(INTEL_FAM6_ATOM_SALTWELL_MID)
 #define IS_BYT __IS_SOC(INTEL_FAM6_ATOM_SILVERMONT)
 #define IS_CHT __IS_SOC(INTEL_FAM6_ATOM_AIRMONT)
 #define IS_MOFD__IS_SOC(INTEL_FAM6_ATOM_AIRMONT_MID)
 
+/* Both CHT and MOFD come with ISP2401 */
+#define IS_ISP2401 __IS_SOCS(INTEL_FAM6_ATOM_AIRMONT, \
+INTEL_FAM6_ATOM_AIRMONT_MID)
+
 #endif /* ATOMISP_PLATFORM_H_ */
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 875dd3ce6e48..4252d3d37649 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -989,7 +989,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int 
error,
break;
case IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME:
case IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
-   if (atomisp_hw_is_isp2401)
+   if (IS_ISP2401)
reset_wdt_timer = true;
 
pipe->buffers_in_css--;
@@ -1038,18 +1038,18 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
 
asd->pending_capture_request--;
 
-   if (atomisp_hw_is_isp2401)
+   if (IS_ISP2401)
asd->re_trigger_capture = false;
 
dev_dbg(isp->dev, "Trigger capture again for new 
buffer. err=%d\n",
err);
-   } else if (atomisp_hw_is_isp2401) {
+   } else if (IS_ISP2401) {
asd->re_trigger_capture = true;
}
break;
case IA_CSS_BUFFER_TYPE_OUTPUT_FRAME:
case IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
-   if (atomisp_hw_is_isp2401)
+   if (IS_ISP2401)
reset_wdt_timer = true;
 

[PATCH 05/15] media: atomisp: simplify IRQ ifdef logic

2020-06-03 Thread Mauro Carvalho Chehab
There are lots of mess with IRQ ifdef settings. As the
*_global.h will already detect the type of IRQ system at
compile time, we can get rid of them, replacing by just
one ifdef for ISP2401.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_common/isp_global.h  | 10 ++
 .../pci/hive_isp_css_common/sp_global.h   | 10 --
 .../media/atomisp/pci/isp2400_system_global.h | 31 ---
 .../media/atomisp/pci/isp2400_system_local.h  |  8 -
 .../media/atomisp/pci/isp2401_system_global.h | 31 ---
 .../media/atomisp/pci/isp2401_system_local.h  |  8 -
 .../pci/runtime/debug/src/ia_css_debug.c  | 10 --
 .../tagger/interface/ia_css_tagger_common.h   |  4 ---
 .../media/atomisp/pci/sh_css_internal.h   | 10 --
 9 files changed, 2 insertions(+), 120 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
index 5ea3f1938fbd..5212d52198bd 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
@@ -18,16 +18,10 @@
 
 #include 
 
-#if defined(HAS_ISP_2401_MAMOIADA)
-#define IS_ISP_2401_MAMOIADA
-
+#ifdef ISP2401
 #include "isp2401_mamoiada_params.h"
-#elif defined(HAS_ISP_2400_MAMOIADA)
-#define IS_ISP_2400_MAMOIADA
-
+#else
 #include "isp2400_mamoiada_params.h"
-#else
-#error "isp_global_h: ISP_2400_MAMOIDA must be one of {2400, 2401 }"
 #endif
 
 #define ISP_PMEM_WIDTH_LOG2ISP_LOG2_PMEM_WIDTH
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
index 125fe577073f..b8338f9b5c0c 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
@@ -18,17 +18,7 @@
 
 #include 
 
-#if defined(HAS_SP_2401)
-#define IS_SP_2401
-/* 2401 uses 2400 */
 #include 
-#elif defined(HAS_SP_2400)
-#define IS_SP_2400
-
-#include 
-#else
-#error "sp_global.h: SP_2400 must be one of {2400, 2401 }"
-#endif
 
 #define SP_PMEM_WIDTH_LOG2 SP_PMEM_LOG_WIDTH_BITS
 #define SP_PMEM_SIZE   SP_PMEM_DEPTH
diff --git a/drivers/staging/media/atomisp/pci/isp2400_system_global.h 
b/drivers/staging/media/atomisp/pci/isp2400_system_global.h
index ed3c24a77a3c..d87ddf1d2fe9 100644
--- a/drivers/staging/media/atomisp/pci/isp2400_system_global.h
+++ b/drivers/staging/media/atomisp/pci/isp2400_system_global.h
@@ -47,27 +47,6 @@
  * N.B. the 3 input formatters are of 2 different classess
  */
 
-/*
- * Since this file is visible everywhere and the system definition
- * macros are not, detect the separate definitions for {host, SP, ISP}
- *
- * The 2401 system has the nice property that it uses a vanilla 2400 SP
- * so the SP will believe it is a 2400 system rather than 2401...
- */
-//#if defined(SYSTEM_hive_isp_css_2401_system) || defined(__isp2401_mamoiada) 
|| defined(__scalar_processor_2401)
-#if defined(SYSTEM_hive_isp_css_2401_system) || defined(__isp2401_mamoiada)
-#define IS_ISP_2401_MAMOIADA_SYSTEM
-#define HAS_ISP_2401_MAMOIADA
-#define HAS_SP_2400
-//#elif defined(SYSTEM_hive_isp_css_2400_system) || 
defined(__isp2400_mamoiada) || defined(__scalar_processor_2400)
-#elif defined(SYSTEM_hive_isp_css_2400_system) || defined(__isp2400_mamoiada)
-#define IS_ISP_2400_MAMOIADA_SYSTEM
-#define HAS_ISP_2400_MAMOIADA
-#define HAS_SP_2400
-#else
-#error "system_global.h: 2400_SYSTEM must be one of {2400, 2401 }"
-#endif
-
 #define USE_INPUT_SYSTEM_VERSION_2
 
 #define HAS_MMU_VERSION_2
@@ -130,21 +109,11 @@ typedef enum {
N_SP_ID
 } sp_ID_t;
 
-#if defined(IS_ISP_2401_MAMOIADA_SYSTEM)
 typedef enum {
MMU0_ID = 0,
MMU1_ID,
N_MMU_ID
 } mmu_ID_t;
-#elif defined(IS_ISP_2400_MAMOIADA_SYSTEM)
-typedef enum {
-   MMU0_ID = 0,
-   MMU1_ID,
-   N_MMU_ID
-} mmu_ID_t;
-#else
-#error "system_global.h: SYSTEM must be one of {2400, 2401}"
-#endif
 
 typedef enum {
DMA0_ID = 0,
diff --git a/drivers/staging/media/atomisp/pci/isp2400_system_local.h 
b/drivers/staging/media/atomisp/pci/isp2400_system_local.h
index 0574bb9a0a77..da34e3e5f3fb 100644
--- a/drivers/staging/media/atomisp/pci/isp2400_system_local.h
+++ b/drivers/staging/media/atomisp/pci/isp2400_system_local.h
@@ -82,7 +82,6 @@ static const hrt_address SP_PMEM_BASE[N_SP_ID] = {
 };
 
 /* MMU */
-#if defined(IS_ISP_2400_MAMOIADA_SYSTEM) || 
defined(IS_ISP_2401_MAMOIADA_SYSTEM)
 /*
  * MMU0_ID: The data MMU
  * MMU1_ID: The icache MMU
@@ -91,9 +90,6 @@ static const hrt_address MMU_BASE[N_MMU_ID] = {
(hrt_address)0x0007ULL,
(hrt_address)0x000AULL
 };
-#else
-#error "system_local.h: SYSTEM must be one of {2400, 2401 }"
-#endif
 
 /* DMA */
 static const hrt_address DMA_BASE[N_DMA_ID] = {
@@ -225,7 +221,6 @@ static const hrt_address 

[PATCH 14/15] media: atomisp: use strscpy() instead of less secure variants

2020-06-03 Thread Mauro Carvalho Chehab
Replace usages of strcpy(), strlcpy() and strncpy() in favor
of strscpy().

Suggested-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_file.c |  2 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c|  2 +-
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c| 12 ++--
 drivers/staging/media/atomisp/pci/atomisp_tpg.c  |  2 +-
 .../staging/media/atomisp/pci/atomisp_trace_event.h  |  6 +++---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c |  2 +-
 drivers/staging/media/atomisp/pci/sh_css_sp.c|  3 +--
 drivers/staging/media/atomisp/pci/sh_css_version.c   |  2 +-
 8 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_file.c 
b/drivers/staging/media/atomisp/pci/atomisp_file.c
index fa92b5eba740..e568ca99c45a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_file.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_file.c
@@ -219,7 +219,7 @@ int atomisp_file_input_init(struct atomisp_device *isp)
 
v4l2_subdev_init(sd, _input_ops);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-   strcpy(sd->name, "file_input_subdev");
+   strscpy(sd->name, "file_input_subdev", sizeof(sd->name));
v4l2_set_subdevdata(sd, file_dev);
 
pads[0].flags = MEDIA_PAD_FL_SINK;
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c 
b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index e8f835c3bbae..5d2bfe2ea971 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -936,7 +936,7 @@ static int gmin_get_hardcoded_var(struct gmin_cfg_var 
*varlist,
if (vl > *out_len - 1)
return -ENOSPC;
 
-   strcpy(out, gv->val);
+   strscpy(out, gv->val, *out_len);
*out_len = vl;
return 0;
}
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 15567623b51b..9404a678fa6f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -547,8 +547,8 @@ static int atomisp_querycap(struct file *file, void *fh,
struct video_device *vdev = video_devdata(file);
struct atomisp_device *isp = video_get_drvdata(vdev);
 
-   strscpy(cap->driver, DRIVER, sizeof(cap->driver) - 1);
-   strscpy(cap->card, CARD, sizeof(cap->card) - 1);
+   strscpy(cap->driver, DRIVER, sizeof(cap->driver));
+   strscpy(cap->card, CARD, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
 pci_name(isp->pdev));
 
@@ -573,8 +573,8 @@ static int atomisp_enum_input(struct file *file, void *fh,
return -EINVAL;
 
memset(input, 0, sizeof(struct v4l2_input));
-   strncpy(input->name, isp->inputs[index].camera->name,
-   sizeof(input->name) - 1);
+   strscpy(input->name, isp->inputs[index].camera->name,
+   sizeof(input->name));
 
/*
 * HACK: append actuator's name to sensor's
@@ -593,8 +593,8 @@ static int atomisp_enum_input(struct file *file, void *fh,
 
if (max_size > 1) {
input->name[cur_len] = '+';
-   strncpy(>name[cur_len + 1],
-   motor->name, max_size - 1);
+   strscpy(>name[cur_len + 1],
+   motor->name, max_size);
}
}
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp_tpg.c 
b/drivers/staging/media/atomisp/pci/atomisp_tpg.c
index 9477ac5e22b9..1def80bab180 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_tpg.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_tpg.c
@@ -148,7 +148,7 @@ int atomisp_tpg_init(struct atomisp_device *isp)
tpg->isp = isp;
v4l2_subdev_init(sd, _ops);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-   strcpy(sd->name, "tpg_subdev");
+   strscpy(sd->name, "tpg_subdev", sizeof(sd->name));
v4l2_set_subdevdata(sd, tpg);
 
pads[0].flags = MEDIA_PAD_FL_SINK;
diff --git a/drivers/staging/media/atomisp/pci/atomisp_trace_event.h 
b/drivers/staging/media/atomisp/pci/atomisp_trace_event.h
index 61f402a642d4..538d45e008b5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_trace_event.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_trace_event.h
@@ -44,7 +44,7 @@ TRACE_EVENT(camera_meminfo,
),
 
TP_fast_assign(
-   strlcpy(__entry->name, name, 24);
+   strscpy(__entry->name, name, 24);
__entry->uptr_size = uptr_size;
__entry->counter = counter;
__entry->sys_size = sys_size;
@@ -74,8 +74,8 @@ TRACE_EVENT(camera_debug,
),
 
TP_fast_assign(
-   strlcpy(__entry->name, name, 

[PATCH 06/15] media: atomisp: remove some unused defines from *mamoiada_params.h

2020-06-03 Thread Mauro Carvalho Chehab
There are some parameters that are different between
isp2400 and isp2401. None of those are actually used.

So, get rid of them.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../hrt/isp2400_mamoiada_params.h | 20 +--
 .../atomisp/pci/isp2401_mamoiada_params.h | 20 +--
 2 files changed, 2 insertions(+), 38 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/css_2400_system/hrt/isp2400_mamoiada_params.h
 
b/drivers/staging/media/atomisp/pci/css_2400_system/hrt/isp2400_mamoiada_params.h
index 4a2345c38b8c..e18e5f3576df 100644
--- 
a/drivers/staging/media/atomisp/pci/css_2400_system/hrt/isp2400_mamoiada_params.h
+++ 
b/drivers/staging/media/atomisp/pci/css_2400_system/hrt/isp2400_mamoiada_params.h
@@ -16,11 +16,6 @@
 /* Version */
 #define RTL_VERSION
 
-/* Cell name  */
-#define ISP_CELL_TYPE  isp2400_mamoiada
-#define ISP_VMEM   simd_vmem
-#define _HRT_ISP_VMEM  isp2400_mamoiada_simd_vmem
-
 /* instruction pipeline depth */
 #define ISP_BRANCHDELAY5
 
@@ -154,12 +149,6 @@
 
 #define ISP_VEC_ALIGN  ISP_VMEM_ALIGN
 
-/* HRT specific vector support */
-#define isp2400_mamoiada_vector_alignment ISP_VEC_ALIGN
-#define isp2400_mamoiada_vector_elem_bits ISP_VMEM_ELEMBITS
-#define isp2400_mamoiada_vector_elem_precisionISP_VMEM_ELEM_PRECISION
-#define isp2400_mamoiada_vector_num_elems ISP_VEC_NELEMS
-
 /* register file sizes */
 #define ISP_RF0_SIZE64
 #define ISP_RF1_SIZE16
@@ -173,14 +162,7 @@
 #define ISP_RF9_SIZE16
 #define ISP_RF10_SIZE   16
 #define ISP_RF11_SIZE   16
-#define ISP_VRF1_SIZE   24
-#define ISP_VRF2_SIZE   24
-#define ISP_VRF3_SIZE   24
-#define ISP_VRF4_SIZE   24
-#define ISP_VRF5_SIZE   24
-#define ISP_VRF6_SIZE   24
-#define ISP_VRF7_SIZE   24
-#define ISP_VRF8_SIZE   24
+
 #define ISP_SRF1_SIZE   4
 #define ISP_SRF2_SIZE   64
 #define ISP_SRF3_SIZE   64
diff --git a/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h 
b/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
index 03d3329cd228..e18e5f3576df 100644
--- a/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
+++ b/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
@@ -16,11 +16,6 @@
 /* Version */
 #define RTL_VERSION
 
-/* Cell name  */
-#define ISP_CELL_TYPE  isp2401_mamoiada
-#define ISP_VMEM   simd_vmem
-#define _HRT_ISP_VMEM  isp2401_mamoiada_simd_vmem
-
 /* instruction pipeline depth */
 #define ISP_BRANCHDELAY5
 
@@ -154,12 +149,6 @@
 
 #define ISP_VEC_ALIGN  ISP_VMEM_ALIGN
 
-/* HRT specific vector support */
-#define isp2401_mamoiada_vector_alignment ISP_VEC_ALIGN
-#define isp2401_mamoiada_vector_elem_bits ISP_VMEM_ELEMBITS
-#define isp2401_mamoiada_vector_elem_precisionISP_VMEM_ELEM_PRECISION
-#define isp2401_mamoiada_vector_num_elems ISP_VEC_NELEMS
-
 /* register file sizes */
 #define ISP_RF0_SIZE64
 #define ISP_RF1_SIZE16
@@ -173,14 +162,7 @@
 #define ISP_RF9_SIZE16
 #define ISP_RF10_SIZE   16
 #define ISP_RF11_SIZE   16
-#define ISP_VRF1_SIZE   32
-#define ISP_VRF2_SIZE   32
-#define ISP_VRF3_SIZE   32
-#define ISP_VRF4_SIZE   32
-#define ISP_VRF5_SIZE   32
-#define ISP_VRF6_SIZE   32
-#define ISP_VRF7_SIZE   32
-#define ISP_VRF8_SIZE   32
+
 #define ISP_SRF1_SIZE   4
 #define ISP_SRF2_SIZE   64
 #define ISP_SRF3_SIZE   64
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/15] media: atomisp: get rid of a string_support.h abstraction layer

2020-06-03 Thread Mauro Carvalho Chehab
Some parts of the driver have their own implementation of
memcpy() & friends. Replace all of them by strscpy().

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_include/string_support.h | 165 --
 .../ctc/ctc_1.0/ia_css_ctc_table.host.c   |   3 +-
 .../kernels/gc/gc_1.0/ia_css_gc_table.host.c  |   3 +-
 .../kernels/gc/gc_2/ia_css_gc2_table.host.c   |   3 +-
 .../xnr/xnr_1.0/ia_css_xnr_table.host.c   |   3 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  45 +++--
 .../pci/runtime/isys/src/virtual_isys.c   |  29 +--
 .../media/atomisp/pci/sh_css_firmware.c   |   2 +-
 8 files changed, 38 insertions(+), 215 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h

diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h
deleted file mode 100644
index 7805b40a1855..
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 __STRING_SUPPORT_H_INCLUDED__
-#define __STRING_SUPPORT_H_INCLUDED__
-#include 
-#include 
-
-/*
- * For all non microsoft cases, we need the following functions
- */
-
-/* @brief Copy from src_buf to dest_buf.
- *
- * @param[out] dest_buf. Destination buffer to copy to
- * @param[in]  dest_size. The size of the destination buffer in bytes
- * @param[in]  src_buf. The source buffer
- * @param[in]  src_size. The size of the source buffer in bytes
- * @return 0 on success, error code on failure
- * @return -EINVAL on Invalid arguments
- * @return ERANGE on Destination size too small
- */
-static inline int memcpy_s(
-void *dest_buf,
-size_t dest_size,
-const void *src_buf,
-size_t src_size)
-{
-   if ((!src_buf) || (!dest_buf)) {
-   /* Invalid arguments*/
-   return -EINVAL;
-   }
-
-   if ((dest_size < src_size) || (src_size == 0)) {
-   /* Destination too small*/
-   return ERANGE;
-   }
-
-   memcpy(dest_buf, src_buf, src_size);
-   return 0;
-}
-
-/* @brief Get the length of the string, excluding the null terminator
- *
- * @param[in]  src_str. The source string
- * @param[in]  max_len. Look only for max_len bytes in the string
- * @return Return the string length excluding null character
- * @return Return max_len if no null character in the first max_len bytes
- * @return Returns 0 if src_str is NULL
- */
-static size_t strnlen_s(
-const char *src_str,
-size_t max_len)
-{
-   size_t ix;
-
-   if (!src_str) {
-   /* Invalid arguments*/
-   return 0;
-   }
-
-   for (ix = 0; ix < max_len && src_str[ix] != '\0'; ix++)
-   ;
-
-   /* On Error, it will return src_size == max_len*/
-   return ix;
-}
-
-/* @brief Copy string from src_str to dest_str
- *
- * @param[out] dest_str. Destination buffer to copy to
- * @param[in]  dest_size. The size of the destination buffer in bytes
- * @param[in]  src_str. The source buffer
- * @param[in]  src_size. The size of the source buffer in bytes
- * @return Returns 0 on success
- * @return Returns -EINVAL on invalid arguments
- * @return Returns ERANGE on destination size too small
- */
-static inline int strncpy_s(
-char *dest_str,
-size_t dest_size,
-const char *src_str,
-size_t src_size)
-{
-   size_t len;
-
-   if (!dest_str) {
-   /* Invalid arguments*/
-   return -EINVAL;
-   }
-
-   if ((!src_str) || (dest_size == 0)) {
-   /* Invalid arguments*/
-   dest_str[0] = '\0';
-   return -EINVAL;
-   }
-
-   len = strnlen_s(src_str, src_size);
-
-   if (len >= dest_size) {
-   /* Destination too small*/
-   dest_str[0] = '\0';
-   return ERANGE;
-   }
-
-   /* dest_str is big enough for the len */
-   strncpy(dest_str, src_str, len);
-   dest_str[len] = '\0';
-   return 0;
-}
-
-/* @brief Copy string from src_str to dest_str
- *
- * @param[out] dest_str. Destination buffer to copy to
- * @param[in]  dest_size. The size of the destination buffer in bytes
- * @param[in]  src_str. The source buffer
- * @return Returns 0 on success
- * @return 

[PATCH 02/15] media: atomisp: do some cleanup at irq_local.h

2020-06-03 Thread Mauro Carvalho Chehab
- Get rid of typedefs;
- Get rid of a duplicated enum type with different names for
  ISP2400 and ISP2401;
- adjust indentation on the touched code.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_common/host/irq.c| 29 +--
 .../pci/hive_isp_css_common/host/irq_local.h  | 17 +++
 .../hive_isp_css_include/host/irq_public.h| 16 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  2 +-
 drivers/staging/media/atomisp/pci/sh_css.c| 10 +++
 5 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq.c 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq.c
index 8b72a40f9ad1..11448ca00a35 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq.c
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq.c
@@ -29,9 +29,8 @@ static inline void irq_wait_for_write_complete(
 static inline bool any_irq_channel_enabled(
 const irq_ID_t ID);
 
-static inline irq_ID_t virq_get_irq_id(
-const virq_id_tirq_ID,
-unsigned int   *channel_ID);
+static inline irq_ID_t virq_get_irq_id(const enum virq_id irq_ID,
+  unsigned int *channel_ID);
 
 #ifndef __INLINE_IRQ__
 #include "irq_private.h"
@@ -52,7 +51,7 @@ static unsigned short IRQ_N_ID_OFFSET[N_IRQ_ID + 1] = {
IRQ_END_OFFSET
 };
 
-static virq_id_t IRQ_NESTING_ID[N_IRQ_ID] = {
+static enum virq_id IRQ_NESTING_ID[N_IRQ_ID] = {
N_virq_id,
virq_ifmt,
virq_isys,
@@ -228,9 +227,8 @@ void irq_raise(
return;
 }
 
-void irq_controller_get_state(
-const irq_ID_t ID,
-irq_controller_state_t *state)
+void irq_controller_get_state(const irq_ID_t ID,
+ struct irq_controller_state *state)
 {
assert(ID < N_IRQ_ID);
assert(state);
@@ -257,7 +255,7 @@ bool any_virq_signal(void)
 }
 
 void cnd_virq_enable_channel(
-const virq_id_tirq_ID,
+const enum virq_id irq_ID,
 const bool en)
 {
irq_ID_ti;
@@ -297,8 +295,8 @@ void virq_clear_all(void)
return;
 }
 
-enum hrt_isp_css_irq_status virq_get_channel_signals(
-virq_info_t*irq_info)
+enum hrt_isp_css_irq_status
+virq_get_channel_signals(struct virq_info *irq_info)
 {
enum hrt_isp_css_irq_status irq_status = hrt_isp_css_irq_status_error;
irq_ID_t ID;
@@ -327,8 +325,7 @@ enum hrt_isp_css_irq_status virq_get_channel_signals(
return irq_status;
 }
 
-void virq_clear_info(
-virq_info_t*irq_info)
+void virq_clear_info(struct virq_info *irq_info)
 {
irq_ID_t ID;
 
@@ -341,7 +338,7 @@ void virq_clear_info(
 }
 
 enum hrt_isp_css_irq_status virq_get_channel_id(
-virq_id_t  *irq_id)
+enum virq_id   *irq_id)
 {
unsigned int irq_status = irq_reg_load(IRQ0_ID,
   
_HRT_IRQ_CONTROLLER_STATUS_REG_IDX);
@@ -368,7 +365,7 @@ enum hrt_isp_css_irq_status virq_get_channel_id(
 
/* Check whether we have an IRQ on one of the nested devices */
for (ID = N_IRQ_ID - 1 ; ID > (irq_ID_t)0; ID--) {
-   if (IRQ_NESTING_ID[ID] == (virq_id_t)idx) {
+   if (IRQ_NESTING_ID[ID] == (enum virq_id)idx) {
break;
}
}
@@ -405,7 +402,7 @@ enum hrt_isp_css_irq_status virq_get_channel_id(
 
idx += IRQ_N_ID_OFFSET[ID];
if (irq_id)
-   *irq_id = (virq_id_t)idx;
+   *irq_id = (enum virq_id)idx;
 
return status;
 }
@@ -433,7 +430,7 @@ static inline bool any_irq_channel_enabled(
 }
 
 static inline irq_ID_t virq_get_irq_id(
-const virq_id_tirq_ID,
+const enum virq_id irq_ID,
 unsigned int   *channel_ID)
 {
irq_ID_t ID;
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq_local.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq_local.h
index 345d41c1d39f..6a25345ae88e 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq_local.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq_local.h
@@ -43,10 +43,7 @@
 #defineIRQ2_ID_N_CHANNEL   HIVE_ISYS_IRQ_NUM_BITS
 #defineIRQ3_ID_N_CHANNEL   HIVE_ISEL_IRQ_NUM_IRQS
 
-typedef struct virq_info_s virq_info_t;
-typedef struct irq_controller_state_s  irq_controller_state_t;
-
-typedef enum {
+enum virq_id {
virq_gpio_pin_0= IRQ0_ID_OFFSET + 
HIVE_GP_DEV_IRQ_GPIO_PIN_0_BIT_ID,
virq_gpio_pin_1= IRQ0_ID_OFFSET + 

[PATCH 04/15] media: atomisp: get rid of ifdef nonsense

2020-06-03 Thread Mauro Carvalho Chehab
There are some ifdefs there that end doing the same thing.
Get rid of them.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../atomisp/pci/isp2400_input_system_local.h  | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/isp2400_input_system_local.h 
b/drivers/staging/media/atomisp/pci/isp2400_input_system_local.h
index 58ea58ba56e4..4b7034e4adb4 100644
--- a/drivers/staging/media/atomisp/pci/isp2400_input_system_local.h
+++ b/drivers/staging/media/atomisp/pci/isp2400_input_system_local.h
@@ -21,15 +21,14 @@
 #include "input_system_global.h"
 
 #include "input_system_defs.h" /* HIVE_ISYS_GPREG_MULTICAST_A_IDX,... 
*/
-#include "css_receiver_2400_defs.h"/* 
_HRT_CSS_RECEIVER_2400_TWO_PIXEL_EN_REG_IDX, 
_HRT_CSS_RECEIVER_2400_CSI2_FUNC_PROG_REG_IDX,... */
-#if defined(IS_ISP_2400_MAMOIADA_SYSTEM)
+
+/*
+ * _HRT_CSS_RECEIVER_2400_TWO_PIXEL_EN_REG_IDX,
* 
_HRT_CSS_RECEIVER_2400_CSI2_FUNC_PROG_REG_IDX,...
+ */
+#include "css_receiver_2400_defs.h"
+
 #include "isp_capture_defs.h"
-#elif defined(IS_ISP_2401_MAMOIADA_SYSTEM)
-/* Same name, but keep the distinction,it is a different device */
-#include "isp_capture_defs.h"
-#else
-#error "input_system_local.h: 2400_SYSTEM must be one of {2400, 2401 }"
-#endif
+
 #include "isp_acquisition_defs.h"
 #include "input_system_ctrl_defs.h"
 
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/15] media: atomisp: don't set hpll_freq twice with different values

2020-06-03 Thread Mauro Carvalho Chehab
The logic which sets the hpll_freq for BYT sets hpll_freq
to 1600MHz, but ignores it, and sets it again after reading
from-device-specific EFI vars (this time, using a default
of 2000MHz).

Remove the first set, as this will be overriden anyway.

While here, do minor adjustments on comments and on a
printk message.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index c7f6b621ef3f..64e2386f328f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1659,10 +1659,12 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 * resolution accordingly.
 */
isp->dfs = _config_byt;
-   isp->hpll_freq = HPLL_FREQ_1600MHZ;
-   /* HPLL frequency is known to be device-specific, but we don't
+
+   /*
+* HPLL frequency is known to be device-specific, but we don't
 * have specs yet for exactly how it varies.  Default to
-* BYT-CR but let provisioning set it via EFI variable */
+* BYT-CR but let provisioning set it via EFI variable
+*/
isp->hpll_freq = gmin_get_var_int(>dev, false, "HpllFreq",
  HPLL_FREQ_2000MHZ);
 
@@ -1714,7 +1716,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
default:
isp->hpll_freq = HPLL_FREQ_1600MHZ;
dev_warn(isp->dev,
-"read HPLL from cck failed.default 
1600MHz.\n");
+"read HPLL from cck failed. Default to 1600 
MHz.\n");
}
break;
default:
-- 
2.26.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] media: atomisp: use just one mamoiada_params.h

2020-06-03 Thread Mauro Carvalho Chehab
As both isp2400 and isp2401 files are identical, remove one
of them and remove the test for ISP variant.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_common/isp_global.h  |   6 +-
 .../atomisp/pci/isp2401_mamoiada_params.h | 211 --
 ...00_mamoiada_params.h => mamoiada_params.h} |   0
 3 files changed, 1 insertion(+), 216 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
 rename 
drivers/staging/media/atomisp/pci/{css_2400_system/hrt/isp2400_mamoiada_params.h
 => mamoiada_params.h} (100%)

diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
index 5212d52198bd..5c6891c9b451 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
@@ -18,11 +18,7 @@
 
 #include 
 
-#ifdef ISP2401
-#include "isp2401_mamoiada_params.h"
-#else
-#include "isp2400_mamoiada_params.h"
-#endif
+#include "mamoiada_params.h"
 
 #define ISP_PMEM_WIDTH_LOG2ISP_LOG2_PMEM_WIDTH
 #define ISP_PMEM_SIZE  ISP_PMEM_DEPTH
diff --git a/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h 
b/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
deleted file mode 100644
index e18e5f3576df..
--- a/drivers/staging/media/atomisp/pci/isp2401_mamoiada_params.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-/* Version */
-#define RTL_VERSION
-
-/* instruction pipeline depth */
-#define ISP_BRANCHDELAY5
-
-/* bus */
-#define ISP_BUS_WIDTH  32
-#define ISP_BUS_ADDR_WIDTH 32
-#define ISP_BUS_BURST_SIZE 1
-
-/* data-path */
-#define ISP_SCALAR_WIDTH   32
-#define ISP_SLICE_NELEMS   4
-#define ISP_VEC_NELEMS 64
-#define ISP_VEC_ELEMBITS   14
-#define ISP_VEC_ELEM8BITS  16
-#define ISP_CLONE_DATAPATH_IS_16   1
-
-/* memories */
-#define ISP_DMEM_DEPTH 4096
-#define ISP_DMEM_BSEL_DOWNSAMPLE   8
-#define ISP_VMEM_DEPTH 3072
-#define ISP_VMEM_BSEL_DOWNSAMPLE   8
-#define ISP_VMEM_ELEMBITS  14
-#define ISP_VMEM_ELEM_PRECISION14
-#define ISP_PMEM_DEPTH 2048
-#define ISP_PMEM_WIDTH 640
-#define ISP_VAMEM_ADDRESS_BITS 12
-#define ISP_VAMEM_ELEMBITS 12
-#define ISP_VAMEM_DEPTH2048
-#define ISP_VAMEM_ALIGNMENT2
-#define ISP_VA_ADDRESS_WIDTH   896
-#define ISP_VEC_VALSU_LATENCY  ISP_VEC_NELEMS
-#define ISP_HIST_ADDRESS_BITS  12
-#define ISP_HIST_ALIGNMENT 4
-#define ISP_HIST_COMP_IN_PREC  12
-#define ISP_HIST_DEPTH 1024
-#define ISP_HIST_WIDTH 24
-#define ISP_HIST_COMPONENTS4
-
-/* program counter */
-#define ISP_PC_WIDTH   13
-
-/* Template switches */
-#define ISP_SHIELD_INPUT_DMEM  0
-#define ISP_SHIELD_OUTPUT_DMEM 1
-#define ISP_SHIELD_INPUT_VMEM  0
-#define ISP_SHIELD_OUTPUT_VMEM 0
-#define ISP_SHIELD_INPUT_PMEM  1
-#define ISP_SHIELD_OUTPUT_PMEM 1
-#define ISP_SHIELD_INPUT_HIST  1
-#define ISP_SHIELD_OUTPUT_HIST 1
-/* When LUT is select the shielding is always on */
-#define ISP_SHIELD_INPUT_VAMEM 1
-#define ISP_SHIELD_OUTPUT_VAMEM1
-
-#define ISP_HAS_IRQ1
-#define ISP_HAS_SOFT_RESET 1
-#define ISP_HAS_VEC_DIV0
-#define ISP_HAS_VFU_W_2O   1
-#define ISP_HAS_DEINT3 1
-#define ISP_HAS_LUT1
-#define ISP_HAS_HIST   1
-#define ISP_HAS_VALSU  1
-#define ISP_HAS_3rdVALSU   1
-#define ISP_VRF1_HAS_2P1
-
-#define ISP_SRU_GUARDING   1
-#define