Commit graph

63049 commits

Author SHA1 Message Date
Philipp Hortmann
1b22544915 staging: vt6655: Convert macro vt6655_mac_reg_bits_on to function
Convert macro vt6655_mac_reg_bits_on to function.
checkpatch.pl does not accept multiline macros.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/6b23869ec13b35359b135f005a81f3ed50e5801e.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:38 +02:00
Philipp Hortmann
28d4e69287 staging: vt6655: Rename MACvWordRegBitsOff
Fix name of a macro that uses CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/b8d4b72ddfdefb6b8a73fb95f6851e0f365118ba.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:38 +02:00
Philipp Hortmann
5327d71d19 staging: vt6655: Rename MACvRegBitsOff
Fix name of a macro that uses CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/e6bea6707f20a53d0631dd1f477ce72d36cd6f3e.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:38 +02:00
Philipp Hortmann
ee67fe63b4 staging: vt6655: Rename MACvWordRegBitsOn
Fix name of a macro that uses CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/b3873e1103d642a804d42c945dc0c73d94b0c1cf.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:38 +02:00
Philipp Hortmann
67ec557644 staging: vt6655: Rename MACvRegBitsOn
Fix name of a macro that uses CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/7fb9627441ff97897d132c62d59676355b6d14ea.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:38 +02:00
Philipp Hortmann
ee9aded6d3 staging: vt6655: Rename wData to reg_value in two macros
Fix name of a variable in two macros that use CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/8f2e9451a24e380c997fcf7c87249f7ed9b66787.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:37 +02:00
Philipp Hortmann
d57561d960 staging: vt6655: Rename byData to reg_value in two macros
Fix name of a variable in two macros that use CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/159014866cce40913d360a0692fb3c426d4cb840.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:37 +02:00
Philipp Hortmann
5bd643b197 staging: vt6655: Rename wBits to bit_mask in two macros
Fix name of a variable in two macros that use CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/8929407dc7355df515b7f9fdd195b45ff44f6b98.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:37 +02:00
Philipp Hortmann
10ff399bf6 staging: vt6655: Rename byBits to bit_mask in two macros
Fix name of a variable in two macros that use CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/5ac7e8860ecb23232cf5befea024872e7db76d59.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:37 +02:00
Philipp Hortmann
186c46008c staging: vt6655: Rename byRegOfs to reg_offset in four macros
Fix name of a variable in four macros that use CamelCase which is not
accepted by checkpatch.pl

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/82f65d22ac8cd75b2c7790c13be3d0068968925b.1657657918.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:48:37 +02:00
Martin Kaiser
724933e37a staging: r8188eu: fall back to random mac address
Call eth_random_addr to generate a random mac address if we cannot load
the mac address from the efuses.

Do not use a constant mac address as fallback. This may create conflicts
if we have several r8188eu devices on the network.

Suggested-by: Joe Perches <joe@perches.com>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220713075552.140927-1-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:47:36 +02:00
Martin Kaiser
c1da5a7bef staging: r888eu: use dynamic allocation for efuse buffer
Use kmalloc to allocate the efuse buffer in ReadAdapterInfo8188EU and
free it on exit. This is better than using a 512 byte array on the stack.

It's ok to drop the __aligned(4) qualifier. kmalloc aligns to
ARCH_KMALLOC_MINALIGN, this is at least 8 bytes.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Larry Finger <Larry.Finger@lwfinger.net>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220713075804.140986-1-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:47:21 +02:00
Binyi Han
4cdb845db3 staging: qlge: Avoid multiplication while keep the same logic
Avoid the more expensive multiplication while keep the same logic.

Signed-off-by: Binyi Han <dantengknight@gmail.com>
Link: https://lore.kernel.org/r/31fe21bf4a9e8f13cf27bd50073e9d5d197654ea.1657697683.git.dantengknight@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:46:58 +02:00
Binyi Han
f39b6c58d8 staging: qlge: Fix indentation issue under long for loop
Fix indentation issue to adhere to Linux kernel coding style, issue
found by checkpatch. And change the long for loop into 3 lines.

Signed-off-by: Binyi Han <dantengknight@gmail.com>
Link: https://lore.kernel.org/r/4e18dabcce7f589386a33ceed59096aa049779f0.1657697683.git.dantengknight@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-14 15:46:58 +02:00
David S. Miller
736002fb6a A fairly large set of updates for next, highlights:
ath10k
  * ethernet frame format support
 
 rtw89
  * TDLS support
 
 cfg80211/mac80211
  * airtime fairness fixes
  * EHT support continued, especially in AP mode
  * initial (and still major) rework for multi-link
    operation (MLO) from 802.11be/wifi 7
 
 As usual, also many small updates/cleanups/fixes/etc.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEH1e1rEeCd0AIMq6MB8qZga/fl8QFAmLOca8ACgkQB8qZga/f
 l8S2sQ//VyUyfPxKTnos4xLm9cZFYbP4/JAl+e1QwbYpa8TtQFMjyiDq+/mTiowA
 gS5qdiAllS75MyxH5LuVJ1fSWe7DmSQ1A733gO4cQUxPUtaUrtXWZpsinYT+Vk4J
 a20kOic/9KCD6j1JFLEFToaDBHxO6Rbqo1knnTuOpMXIV6H/ou0PNlj6Ys66oFLV
 V5SvsoeIfCXsN3j/8JyGgjIC52LiNLam3VfdalParurY8yAxda0ub9IKvYqL/s3M
 PZyuHUc0kJsL/2094sjmn6SKZobjTzrOQcLgq4nPXgspp+8YQ+CUf97QS8nH5rBV
 AOlv7+WOiC9Ext/rBzxwZvjCmJUZSVn44mDMjafzIfTYDn0sB9m4CpqfQpgK5zvC
 mf+jhvI99VuK3S4Zx/xRhNFZMAZZG65zkJKEACclBL2Bcs9A+z12CPIWvalEb3/k
 Hk38VlUIMWPQlbcJW7oVTNH8HNpKIuOCecxKWZC+8MDDb/ZhIYhFqFNMb5TnbOBI
 GMXIDBlfYZgvBKHgwcj9G24QGgm1P+yKGyDcnVH0KPismZwt0gm9R+VX2B4HyBnD
 neT/7wx8yxsm7ujJIF28CM+BnF9vxZKVPGUS6XhS2aarOKanAalybsm9DKLwlArZ
 Qlr2rwaTM+ZkHS82Yapv6At97IYvfiq+ju3b940aL3YrOmgHoqs=
 =smwk
 -----END PGP SIGNATURE-----

Merge tag 'wireless-next-2022-07-13' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next

Johannes Berg says:

====================
A fairly large set of updates for next, highlights:

ath10k
 * ethernet frame format support

rtw89
 * TDLS support

cfg80211/mac80211
 * airtime fairness fixes
 * EHT support continued, especially in AP mode
 * initial (and still major) rework for multi-link
   operation (MLO) from 802.11be/wifi 7

As usual, also many small updates/cleanups/fixes/etc.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
2022-07-13 14:28:52 +01:00
Michael Straube
042f1a6f43 staging: r8188eu: remove HW_VAR_MLME_SITESURVEY from SetHwReg8188EU()
Remove the HW_VAR_MLME_SITESURVEY case from SetHwReg8188EU() and move
the functionality to two new functions in rtw_mlme_ext.c. This is part
of the ongoing effort to get rid of SetHwReg8188EU().

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220711174417.10721-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-12 12:32:01 +02:00
Martin Kaiser
d4090520cd staging: r8188eu: the bcnhead parameter is always 0
The only caller of efuse_read_phymap_from_txpktbuf sets bcnhead to 0.
Remove this function parameter and simplify the function body.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-15-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
c337bf6256 staging: r8188eu: efuse_utilized is never read
The efuse_utilized variable in function efuse_phymap_to_logical is
written to but never read. Remove it.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-14-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
e2bd5dc33f staging: r8188eu: _offset is always 0 in efuse_phymap_to_logical
The _offset parameter of iol_read_efuse is always 0. Remove the
parameter and use 0 in the function body.

We can now replace the bytewise copy from efuseTbl to pbuf with memcpy.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-13-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
cda94a6b44 staging: r8188eu: offset is always 0 in iol_read_efuse
The offset parameter of iol_read_efuse is always 0. Remove the
parameter and use 0 in the function body.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-12-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
db9895b86b staging: r8188eu: offset is always 0 in rtl8188e_ReadEFuse
The offset parameter of rtl8188e_ReadEFuse is always 0. Remove the
parameter and use 0 in the function body.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-11-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
36442aa73b staging: r8188eu: txpktbuf_bndy is always 0
The only caller of iol_read_efuse sets the txpktbuf_bndy parameter to 0.
Remove the parameter from iol_read_efuse and use 0 in the function body.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-10-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
e1ebb0d6a1 staging: r8188eu: merge ReadEFuseByIC into rtl8188e_ReadEFuse
The rtl8188e_ReadEFuse function is just a wrapper to call ReadEFuseByIC.
Copy ReadEFuseByIC into rtl8188e_ReadEFuse and remove ReadEFuseByIC.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-9-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
3c1178680b staging: r8188eu: use memcpy for fallback mac address
Use memcpy to store the fallback mac address in eeprom->mac_addr. Do not
copy byte by byte.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-8-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
0fcae03da0 staging: r8188eu: always initialise efuse buffer with 0xff
If BOOT_FROM_EEPROM is set, efuse_buf is not initialised before it is
passed to functions that read from it.

The buffer will be filled with 0x00 in this case like all local variables.
However, the parsing functions expect the buffer to be filled with 0xFF if
reading eeprom/efuse data failed. Fill the buffer with 0xFF before we try
to read the data.

Please note that this problem existed before we started using a local
buffer. Adapter->eeprompriv->efuse_eeprom_data was allocated as a part of
struct adapter by a vzalloc call in rtw_usb_if1_init.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-7-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
698bd81fe8 staging: r8188eu: use a local buffer for efuse data
The efuse_eeprom_data array in struct eeprom_priv is used only by
ReadAdapterInfo8188EU. We can remove efuse_eeprom_data and use a local
buffer instead.

Use EFUSE_MAP_LEN_88E as buffer size. Its value is the same as
HWSET_MAX_SIZE_512. The functions that access the buffer use
EFUSE_MAP_LEN_88E for its size.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-6-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
14dbcfc4c9 staging: r8188eu: merge EFUSE_ShadowMapUpdate with its caller
Merge the EFUSE_ShadowMapUpdate function into ReadAdapterInfo8188EU, which
is the only caller.

Merging the two functions makes it clearer that eeprom->efuse_eeprom_data
is in fact a temporary buffer that stores info read from efuses.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-5-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:45 +02:00
Martin Kaiser
1c4d6546c3 staging: r8188eu: remove eeprom function prototypes
Remove prototypes for non-existing eeprom functions. It seems that r8188eu
has efuses but no eeprom.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-4-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:44 +02:00
Martin Kaiser
af4e6efda5 staging: r8188eu: remove EepromOrEfuse from struct eeprom_priv
The EepromOrEfuse flag in struct eeprom_priv is used only in the
ReadAdapterInfo8188EU function. We can remove EepromOrEfuse from struct
eeprom_priv.

As the meaning of EepromOrEfuse isn't obvious, there is a macro
is_boot_from_eeprom that's used for checking the value. We don't need the
macro, writing the check as !(eeValue & BOOT_FROM_EEPROM) makes it clear
what is checked.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-3-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:44 +02:00
Martin Kaiser
ba68103d0f staging: r8188eu: remove unused eeprom defines
Remove some eeprom-related defines which are not used by the r8188eu
driver. This driver uses BOOT_FROM_EEPROM and EEPROM_EN instead of the
defines that this patch removes.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220709171000.180481-2-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:06:44 +02:00
Michael Straube
3782d95998 staging: r8188eu: remove HW_VAR_DM_FUNC_CLR from SetHwReg8188EU()
Remove the HW_VAR_DM_FUNC_CLR case from SetHwReg8188EU() and move its
functionality to a static function. This is part of the ongoing effort
to get rid of SetHwReg8188EU().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220709094458.9578-6-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:57 +02:00
Michael Straube
8ad697c3d7 staging: r8188eu: remove HW_VAR_DM_FUNC_RESET from SetHwReg8188EU()
Remove the HW_VAR_DM_FUNC_RESET case from SetHwReg8188EU() and move
its functionality to a static function. This is part of the ongoing
effort to get rid of SetHwReg8188EU().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220709094458.9578-5-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:57 +02:00
Michael Straube
f18ab26f77 staging: r8188eu: remove HW_VAR_DM_FLAG from SetHwReg8188EU()
Remove the HW_VAR_DM_FLAG case from SetHwReg8188EU() and move its
functionality to a static function. This is part of the ongoing
effort to get rid of SetHwReg8188EU().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220709094458.9578-4-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:57 +02:00
Michael Straube
7644e877ba staging: r8188eu: remove HW_VAR_DM_FUNC_OP from SetHwReg8188EU()
Remove the HW_VAR_DM_FUNC_OP case from SetHwReg8188EU() and move the
functionality to the functions that call SetHwReg8188EU() with
HW_VAR_DM_FUNC_OP. This is part of the ongoing effort to get rid of
SetHwReg8188EU().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220709094458.9578-3-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:57 +02:00
Michael Straube
ae9411408c staging: r8188eu: remove HW_VAR_BASIC_RATE from SetHwReg8188EU()
Remove the HW_VAR_BASIC_RATE case from SetHwReg8188EU() and move the
functionality to a separate function. This is part of the ongoing
effort to get rid of SetHwReg8188EU().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220709094458.9578-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:57 +02:00
Duoming Zhou
6a0c054930 staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback
There are sleep in atomic context bugs when dm_fsync_timer_callback is
executing. The root cause is that the memory allocation functions with
GFP_KERNEL or GFP_NOIO parameters are called in dm_fsync_timer_callback
which is a timer handler. The call paths that could trigger bugs are
shown below:

    (interrupt context)
dm_fsync_timer_callback
  write_nic_byte
    kzalloc(sizeof(data), GFP_KERNEL); //may sleep
    usb_control_msg
      kmalloc(.., GFP_NOIO); //may sleep
  write_nic_dword
    kzalloc(sizeof(data), GFP_KERNEL); //may sleep
    usb_control_msg
      kmalloc(.., GFP_NOIO); //may sleep

This patch uses delayed work to replace timer and moves the operations
that may sleep into the delayed work in order to mitigate bugs.

Fixes: 8fc8598e61 ("Staging: Added Realtek rtl8192u driver to staging")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20220710103002.63283-1-duoming@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 10:05:35 +02:00
Greg Kroah-Hartman
39c1b1af3e Merge 5.19-rc6 into staging-next
We need the staging driver fix in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-11 09:25:23 +02:00
Ezequiel Garcia
177d841fa1 media: hantro: Fix RK3399 H.264 format advertising
Commit 1f82f2df52 ("media: hantro: Enable H.264 on Rockchip VDPU2")
enabled H.264 on some SoCs with VDPU2 cores. This had the side-effect
of exposing H.264 coded format as supported on RK3399.

Fix this and clarify how the codec is explicitly disabled on RK3399 on
this driver.

Fixes: 1f82f2df52 ("media: hantro: Enable H.264 on Rockchip VDPU2")
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:16:37 +01:00
Laurent Pinchart
6f6e8050f7 media: staging: media: imx: imx7-media-csi: Drop usage of shared helpers
None of the shared helpers are used anymore. Make this official by
dropping inclusion of imx-media.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:11 +01:00
Laurent Pinchart
fc9d988a5a media: staging: media: imx: imx7-media-csi: Drop V4L2 events support
The only event that the driver allows subscribing to,
V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR, is never generated. Drop events
support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:10 +01:00
Laurent Pinchart
67c4b3f2e3 media: staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats()
Inline the imx7_csi_enum_pixel_formats() function in its only caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:09 +01:00
Laurent Pinchart
820552fbfc media: staging: media: imx: imx7-media-csi: Drop unneeded pixel format validation
The driver won't accept unsupported pixel formats, there's thus no need
to validate it in imx7_csi_pad_link_validate().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:08 +01:00
Laurent Pinchart
ba9b219f91 media: staging: media: imx: imx7-media-csi: Add V4L2_PIX_FMT_Y14 support
The device supports 14-bit greyscale formats the same way it supports
14-bit Bayer formats.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:07 +01:00
Laurent Pinchart
a4da0cee0d media: staging: media: imx: imx7-media-csi: Fix list of supported formats
The list of supported formats comes from helpers shared with the i.MX6
IPUv3 and is incorrect in multiple regards:

- 10-, 12- and 14-bit Bayer formats are stored in memory as SBGGR10,
  SBGGR12 and SBGGR14 respectively (plus components permutations), not
  SBGGR16. Same thing for greyscale formats.
- 16-bit RAW formats are not supported by the hardware.

Fix the supported formats table.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:06 +01:00
Laurent Pinchart
a1a60e7ac2 media: staging: media: imx: imx7-media-csi: Simplify default format in try_fmt
When trying a format on the video node, if the requested pixel format
isn't supported, fallback to the default with a simpler logic.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:05 +01:00
Laurent Pinchart
5c42cd9dfa media: staging: media: imx: imx7-media-csi: Inline imx7_csi_init_mbus_fmt()
Inline the imx7_csi_init_mbus_fmt() function in its only caller. This
allows simplifying the code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:04 +01:00
Laurent Pinchart
3ee396ed91 media: staging: media: imx: imx7-media-csi: Drop unneeded imx7_csi_pixfmt fields
The imx7_csi_pixfmt cycles field is never used nor set, the bayer field
is never used, and the planar field is never set. Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:04 +01:00
Laurent Pinchart
2d35c1ff83 media: staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors
All the format lookup functions are called with a ANY selector, drop
selector support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:03 +01:00
Laurent Pinchart
539a985976 media: staging: media: imx: imx7-media-csi: Simplify default mbus code in try_fmt
When trying a format on the subdev sink pad, if the requested media bus
code isn't supported, fallback to the default with a simpler logic.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:02 +01:00
Laurent Pinchart
148709ad22 media: staging: media: imx: imx7-media-csi: Define macro for default mbus code
Define a macro for the default media bus code and use it through the
driver to replace a hardcoded value and a dynamic query from the
pixel_formats table.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:01 +01:00
Laurent Pinchart
0eaa3d82d4 media: staging: media: imx: imx7-media-csi: Make default formats consistent
Use the same default image width and height for both the CSI subdev and
the video node to achieve a consistent default through the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:03:00 +01:00
Laurent Pinchart
1de014dc6b media: staging: media: imx: imx7-media-csi: Drop unsupported YUV and RGB formats
A large number of formats defined in the pixel_formats array are not
supported, as shown by the switch-case check in
imx7_csi_pad_link_validate(). Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:59 +01:00
Laurent Pinchart
6ad52b675f media: staging: media: imx: imx7-media-csi: Drop IPU-only formats
The formats specific to the IPUv3 are not supported by the CSI bridge.
Drop them, along with the related code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:58 +01:00
Laurent Pinchart
44737d2ac4 media: staging: media: imx: imx7-media-csi: Drop IC support from imx7_csi_try_colorimetry()
The imx7_csi_try_colorimetry() function supports the unrelated image
converter hardware as it originates from shared helpers. Drop that.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:57 +01:00
Laurent Pinchart
a61bfe6625 media: staging: media: imx: imx7-media-csi: Replace ipu_color_space with bool yuv field
Replace the enum ipu_color_space cs field in struct imx7_csi_pixfmt with
a bool yuv field. This decouples the driver from the unrelated IPUv3
headers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:56 +01:00
Laurent Pinchart
e352833d32 media: staging: media: imx: imx7-media-csi: Import format helpers
To prepare for code refactoring, copy the format helpers used by this
driver from imx-media-utils.c. Rename structures and functions to avoid
name clashes, no functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:55 +01:00
Laurent Pinchart
35b53d44e1 media: staging: media: imx: imx7-media-csi: Drop error message on alloc failure
The kernel memory allocators already complain loudly to the log when
allocation fails. There's no need for an additional message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:54 +01:00
Laurent Pinchart
56ae4cac6d media: staging: media: imx: imx7-media-csi: Decouple from shared macros
Decouple from the IMX7_CSI_VIDEO_DEF_PIX_WIDTH,
IMX7_CSI_VIDEO_DEF_PIX_HEIGHT and IMX_MEDIA_EOF_TIMEOUT macros defined
in shared helpers by duplicating them in the imx7-media-csi driver, with
a rename to avoid name clashes. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:53 +01:00
Laurent Pinchart
57327b0824 media: staging: media: imx: imx7-media-csi: Decouple from imx_media_dma_buf
Decouple from the imx_media_dma_buf structure defined in shared helpers
by duplicating it in the imx7-media-csi driver, along with the two small
alloc and free functions. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:52 +01:00
Laurent Pinchart
0cc432b741 media: staging: media: imx: imx7-media-csi: Store imx7_csi in drv data
Replace the subdev pointer stored in platform drv data with the imx7_csi
pointer. Drop a now redundant dev_set_drvdata() call.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:51 +01:00
Laurent Pinchart
084158200f media: staging: media: imx: imx7-media-csi: Fold imx_media_video_dev into imx7_csi
Now that the driver doesn't use any helper that relies on the
imx_media_video_dev structure anymore, merge its fields directly in the
imx7_csi structure. Update all the users accordingly, and drop the list
field that isn't used by the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:50 +01:00
Laurent Pinchart
1f55211b1b media: staging: media: imx: imx7-media-csi: Decouple from imx_media_buffer
Decouple from the imx_media_buffer structure defined in shared helpers
by duplicating it in the imx7-media-csi driver. No functional change
intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:49 +01:00
Laurent Pinchart
b6ae101900 media: staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi
Now that the driver doesn't use any helper that relies on the
imx_media_dev structure anymore, merge the three fields of the
imx_media_dev structure directly in the imx7_csi structure. Update all
the users accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:48 +01:00
Laurent Pinchart
f5c673428b media: staging: media: imx: imx7-media-csi: Inline pipeline start/stop
The imx7_csi_media_pipeline_set_stream() function has separate branches
for the start and stop paths, surrounded by mutex lock/unlock. That is
very little shared code, inline the locking and corresponding branch in
each of the two callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:48 +01:00
Laurent Pinchart
a3ec6bc1af media: staging: media: imx: imx7-media-csi: Avoid unnecessary casts
Simplify the imx7_csi_media_pipeline_set_stream() function by passing it
the imx7_csi pointer, which avoids going from subdev to entity and back
to subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:47 +01:00
Laurent Pinchart
9d75fc9917 media: staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream()
To prepare for code refactoring, copy the
imx_media_pipeline_set_stream() helper used by this driver from
imx-media-utils.c. Rename the function to avoid name clashes, no
functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:46 +01:00
Laurent Pinchart
7d3bee233c media: staging: media: imx: imx7-media-csi: Inline imx_media_pipeline_pad()
Inline the imx_media_pipeline_pad() helper, dropping all the code unused
by the imx7-media-csi driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:45 +01:00
Laurent Pinchart
3777d61b2b media: staging: media: imx: imx7-media-csi: Don't initialize unused fields
The imx_media_dev structure contains three fields that are not used by
this driver or any helper code that it calls. Don't initialize them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:44 +01:00
Laurent Pinchart
55eb173fe2 media: staging: media: imx: imx7-media-csi: Drop imx_media_add_video_device call
There's no need to call imx_media_add_video_device() anymore, as the
video devices list it manages is only used by the control inheritance
mechanism in the helpers, which this driver doesn't use.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:43 +01:00
Laurent Pinchart
23bcc91082 media: staging: media: imx: imx7-media-csi: Embed imx_media_dev in imx7_csi
There's no need anymore to allocate the imx_media_dev structure
separately from imx7_csi. Embed it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:42 +01:00
Laurent Pinchart
1ab24f2e24 media: staging: media: imx: imx7-media-csi: Import imx_media_dev_init() helper
To prepare for code refactoring, copy the imx_media_dev_init() helper
used by this driver from imx-media-dev-common.c. Rename the function to
avoid name clashes, and leave the v4l2_device notify handler out as it
only serves to implement control inheritance, which this driver doesn't
use. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:41 +01:00
Laurent Pinchart
be3e378b2d media: staging: media: imx: imx7-media-csi: Don't set subdev group id
The subdev group id isn't used by any of the remaining helpers used by
this driver, don't set it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:40 +01:00
Laurent Pinchart
31959b981c media: staging: media: imx: imx7-media-csi: Ensure consistent function prefix
Rename all the functions and macros imported from imx-media-capture.c
with a consistent imx7_csi_video_ prefix. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:40 +01:00
Laurent Pinchart
9f10ecffac media: staging: media: imx: imx7-media-csi: Fold capture_priv into imx7_csi
Merge the capture_priv fields in the imx7_csi structure as there's no
more need to have two separate structures. Update all the users
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:38 +01:00
Laurent Pinchart
356345aaed media: staging: media: imx: imx7-media-csi: Reorganize imx7_csi structure
The struct imx7_csi fields are in a random order, reorganize them
logically to prepare for adding new fields.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:37 +01:00
Laurent Pinchart
42bfdc8249 media: staging: media: imx: imx7-media-csi: Drop unused controls support
Drop the unused control handler from the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:37 +01:00
Laurent Pinchart
49b74aa523 media: staging: media: imx: imx7-media-csi: Drop legacy video device support
Drop all the code related to the unused (by this driver) legacy video
device support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:36 +01:00
Laurent Pinchart
01ac6b7542 media: staging: media: imx: imx7-media-csi: Import video device helpers
To prepare for code refactoring, copy the video device helper code used
by this driver verbatim from imx-media-capture. Rename some functions to
avoid name clashes, and leave the legacy ioctls out as they're not used
by the imx7-media-csi driver. No functional change included.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:35 +01:00
Paul Elder
08b1fedddf media: staging: media: imx: imx7-media-csi: Remove imx_media_of_add_csi
imx_media_of_add_csi() from imx-media-of.c validates that the fwnode for
the CSI bridge is enabled, and adds the fwnode to the async notifier of
the imxmd. The former is redundant, as if the CSI bridge driver probes,
clearly it is enabled in the DT. The latter is not needed as the imxmd
notifier isn't used anymore. The call is thus not needed and can be
dropped. This removes the dependency of imx7-media-csi.c on
imx-media-of.c.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:33 +01:00
Laurent Pinchart
8ace5084d1 media: staging: media: imx: imx7-media-csi: Move format init to probe time
There's no need to wait until the subdev is registered to initialize the
active pad formats. Do so at probe time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:32 +01:00
Laurent Pinchart
85f8673fa1 media: staging: media: imx: imx7-media-csi: Drop unused frame_interval
The frame_interval field of the imx7_csi structure is set but never
used. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:32 +01:00
Laurent Pinchart
46332d14eb media: staging: media: imx: imx7-media-csi: Don't populate vdev lists
The imx_media_dev framework maintains a per-pad list of connected video
devices, created once all subdevs have been bound. This is used for two
purposes, updating V4L2 control inheritance when links change, and
relaying subdev events to video nodes. None of these are used by the
imx7-media-csi driver as it implements the MC-centric approach. Drop
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:31 +01:00
Paul Elder
f9806bd2b4 media: staging: media: imx: imx7-media-csi: Move misc init out of probe()
There is a chunk of miscellaneous initializations related to the CSI
subdev and media pads directly in the probe function. Move them into the
imx7_csi_media_init() function to clean up the probe function.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:30 +01:00
Laurent Pinchart
d79d5e00be media: staging: media: imx: imx7-media-csi: Drop the imx_media notifier
The V4L2 async notifier embedded in the imx_media_dev structure is
triggered when the CSI bridge subdev is registered. We don't need an
async notifier for this, as we can call the .complete() handler directly
from the CSI bridge subdev .registered() handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:29 +01:00
Laurent Pinchart
3c05e2dd4f media: staging: media: imx: imx7-media-csi: Drop duplicate link creation
The imx_media_create_csi2_links() creates a media controller link
between the CSI-2 receiver and the next entity in the pipeline, which
can be either a video mux (handled by the video-mux driver) or the CSI
bridge itself. This isn't needed, as the link is already created either
by the video-mux driver or by the imx7-media-csi driver itself (in
imx7_csi_notify_bound()).

Drop imx_media_create_csi2_links(), which allows dropping the CSI bridge
subdev grp_id.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:28 +01:00
Laurent Pinchart
bdf861aba4 media: staging: media: imx: imx7-media-csi: Import notifier helpers
To prepare for code refactoring, copy the V4L2 async notifier helper
code used by this driver verbatim from imx-media-dev-common.c. Rename
some functions to avoid name clashes. No functional change included.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:27 +01:00
Laurent Pinchart
a314327c9d media: staging: media: imx: imx7-media-csi: Split imx_media_dev from probe()
Prepare for the decoupling of the imx7-media-csi driver from the
IPUv3-based drivers by moving the imx_media_dev handling from probe()
function to separate functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:26 +01:00
Laurent Pinchart
34d868e862 media: staging: media: imx: imx7-media-csi: Initialize locks early on
Group all the direct initialization of imx7_csi fields at the beginning
of the imx7_csi_probe() function instead of spreading them around.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 18:02:25 +01:00
Li zeming
f064f018a8 media: staging/media/atomisp/pci/atomisp: Fix typo in string
Remove the repeated ',' from string

Link: https://lore.kernel.org/linux-media/20220704022807.3215-1-zeming@nfschina.com
Signed-off-by: Li zeming <zeming@nfschina.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:49:47 +01:00
Colin Ian King
71074d3783 media: atomisp: clean up for-loop, remove redundant assignment to variable i
There is a for-loop that initializes variable i but does not use it; the
assignment is redundant and can be removed. The proceeding assignment to
pointer fw can also be moved into the for-loop to clean up the code.

Link: https://lore.kernel.org/linux-media/20220628152451.184416-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:49:27 +01:00
Karthik Alapati
faf5b7971a media: staging: media/atomisp: use max() impl
fix a coccinelle warning by replacing opencoded max()
implementation with max()

WARNING opportunity for max()

Link: https://lore.kernel.org/linux-media/YrNFpF2qvTxpZP8e@karthik-strix-linux.karthek.com
Signed-off-by: Karthik Alapati <mail@karthek.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:47:54 +01:00
Jiang Jian
871f13fe12 media: atomisp: Fix typo in comments
Remove the repeated word 'and' from comments

file: drivers/staging/media/atomisp/pci/hive_isp_css_include/host/debug_public.h
line: 28

* The buffer has a remote and and a local store

changed to:

* The buffer has a remote and a local store

Link: https://lore.kernel.org/linux-media/20220622143442.16942-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:47:31 +01:00
Ard Biesheuvel
0c122ad91f media: atomisp_gmin_platform: stop abusing efivar API
As the code comment already suggests, using the efivar API in this way
is not how it is intended, and so let's switch to the right one, which
is simply to call efi.get_variable() directly after checking whether or
not the GetVariable() runtime service is supported.

Link: https://lore.kernel.org/linux-media/20220620100819.1682995-1-ardb@kernel.org
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:47:11 +01:00
Hans de Goede
1713dceb57 media: atomisp: fix -Wdangling-pointer warning
ia_css_rmgr_acq_vbuf() uses a local on stack
"struct ia_css_rmgr_vbuf_handle v" variable.

When this path using this is hit, either the rmgr_pop_handle() call
will make *handle point to another vbuf-handle, or because
v.count == 0, ia_css_rmgr_refcount_retain_vbuf() will alloc a new
vbuf-handle and make *handle point to it.

So on leaving the function *handle will never point to the on stack
vbuf-handle, but gcc does not know this and emits the following:

drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c: In function ‘ia_css_rmgr_acq_vbuf’:
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:276:33: warning: storing the address of local variable ‘h’ in ‘*handle’ [-Wdangling-pointer=]
  276 |                         *handle = &h;
      |                         ~~~~~~~~^~~~
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: ‘h’ declared here
  257 |         struct ia_css_rmgr_vbuf_handle h;
      |                                        ^
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: ‘handle’ declared here

Rework the code using a new_handle helper to suppress this
false-postive compiler warning.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:46:27 +01:00
Hans de Goede
42ec2f0714 media: atomisp: fix uninitialized stack mem usage in ia_css_rmgr_acq_vbuf()
When ia_css_rmgr_acq_vbuf() enters the code path where it uses the local
"struct ia_css_rmgr_vbuf_handle v" on the stack it relies on v.count==0
so that ia_css_rmgr_refcount_retain_vbuf allocates a new handle.

Explicitly set v.count to 0 rather then it being whatever was on the stack.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-3-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:44:52 +01:00
Hans de Goede
a3b36a8ce3 media: atomisp: revert "don't pass a pointer to a local variable"
The gcc is warning about returning a pointer to a local variable
is a false positive.

The type of handle is "struct ia_css_rmgr_vbuf_handle **" and
"h.vptr" is left to NULL, so the "if ((*handle)->vptr == 0x0)"
check always succeeds when the "*handle = &h;" statement which
gcc warns about executes. Leading to this statement being executed:

	rmgr_pop_handle(pool, handle);

If that succeeds,  then *handle has been set to point to one of
the pre-allocated array of handles, so it no longer points to h.

If that fails the following statement will be executed:

	/* Note that handle will change to an internally maintained one */
	ia_css_rmgr_refcount_retain_vbuf(handle);

Which allocated a new handle from the array of pre-allocated handles
and then makes *handle point to this. So the address of h is actually
never returned.

The fix for the false-postive compiler warning actually breaks the code,
the new:

	**handle = h;

is part of a "if (pool->copy_on_write) { ... }" which means that the
handle where *handle points to should be treated read-only, IOW
**handle must never be set, instead *handle must be set to point to
a new handle (with a copy of the contents of the old handle).

The old code correctly did this and the new fixed code gets this wrong.

Note there is another patch in this series, which fixes the warning
in another way.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-2-hdegoede@redhat.com
Fixes: fa1451374e ("media: atomisp: don't pass a pointer to a local variable")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:44:31 +01:00
Haowen Bai
3823112381 media: atomisp-mt9m114: Fix pointer dereferenced before checking
The info->data is dereferencing before null checking, so move
it after checking.

Link: https://lore.kernel.org/linux-media/1653897481-25681-1-git-send-email-baihaowen@meizu.com
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:38:35 +01:00
Xiaomeng Tong
09b204eb9d media: [PATCH] pci: atomisp_cmd: fix three missing checks on list iterator
The three bugs are here:
	__func__, s3a_buf->s3a_data->exp_id);
	__func__, md_buf->metadata->exp_id);
	__func__, dis_buf->dis_data->exp_id);

The list iterator 's3a_buf/md_buf/dis_buf' will point to a bogus
position containing HEAD if the list is empty or no element is found.
This case must be checked before any use of the iterator, otherwise
it will lead to a invalid memory access.

To fix this bug, add an check. Use a new variable '*_iter' as the
list iterator, while use the old variable '*_buf' as a dedicated
pointer to point to the found element.

Link: https://lore.kernel.org/linux-media/20220414041415.3342-1-xiam0nd.tong@gmail.com
Cc: stable@vger.kernel.org
Fixes: ad85094b29 ("Revert "media: staging: atomisp: Remove driver"")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:38:08 +01:00
Fabio M. De Francesco
ce2203e7d6 media: staging: media: atomisp: Use kmap_local_page() in hmm_store()
The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. The same is true for kmap_atomic().

In file pci/hmm/hmm.c, function hmm_store() test if we are in atomic
context and, if so, it calls kmap_atomic(), if not, it calls kmap().

First of all, in_atomic() shouldn't be used in drivers. This macro
cannot always detect atomic context; in particular, it cannot know
about held spinlocks in non-preemptible kernels.

Notwithstanding what it is said above, this code doesn't need to care
whether or not it is executing in atomic context. It can simply use
kmap_local_page() / kunmap_local() that can instead do the mapping /
unmapping regardless of the context.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_store()() is a function where the use
of kmap_local_page() in place of both kmap() and kmap_atomic() is
correctly suited.

Convert the calls of kmap() / kunmap() and kmap_atomic() /
kunmap_atomic() to kmap_local_page() / kunmap_local() and drop the
unnecessary tests which test if the code is in atomic context.

Link: https://lore.kernel.org/linux-media/20220413225531.9425-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:35:42 +01:00
Fabio M. De Francesco
aab1c42a9d media: staging: media: atomisp: Use kmap_local_page() in hmm_set()
The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. In file pci/hmm/hmm.c, function hmm_set() calls
kmap() / kunmap() where kmap_local_page() can instead do the mapping.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_set()() is a function where the use
of kmap_local_page() in place of kmap() is correctly suited.

Convert the calls of kmap() / kunmap() to kmap_local_page() /
kunmap_local().

Link: https://lore.kernel.org/linux-media/20220413212210.18494-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-07-08 17:34:07 +01:00