media: v4l: Add luma 16-bit interlaced pixel format
Subsystems (7)
Sasha Levin
maintainerPATCH 1/9 media: v4l: Add luma 16-bit interlaced pixel format
From: Dmitry Perchanov <[email protected]>
[ Upstream commit a8f2cdd27d114ed6c3354a0e39502e6d56215804 ]
The formats added by this patch are:
V4L2_PIX_FMT_Y16I
Interlaced lumina format primary use in RealSense Depth cameras with stereo stream for left and right image sensors.
--- .../userspace-api/media/v4l/pixfmt-y16i.rst | 73 +++++++++++++++++++ .../userspace-api/media/v4l/yuv-formats.rst | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 4 files changed, 76 insertions(+) create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-y16i.rst
Documentation/userspace-api/media/v4l/pixfmt-y16i.rst new file +73 -0
@@ -0,0 +1,73 @@ +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later + +.. _V4L2-PIX-FMT-Y16I: + +************************** +V4L2_PIX_FMT_Y16I ('Y16I') +************************** + +Interleaved grey-scale image, e.g. from a stereo-pair + + +Description +=========== + +This is a grey-scale image with a depth of 16 bits per pixel, but with pixels +from 2 sources interleaved and unpacked. Each pixel is stored in a 16-bit word +in the little-endian order. The first pixel is from the left source. + +**Pixel unpacked representation.** +Left/Right pixels 16-bit unpacked - 16-bit for each interleaved pixel. + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - Y'\ :sub:`0L[7:0]` + - Y'\ :sub:`0L[15:8]` + - Y'\ :sub:`0R[7:0]` + - Y'\ :sub:`0R[15:8]` + +**Byte Order.** +Each cell is one byte. + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - start + 0: + - Y'\ :sub:`00Llow` + - Y'\ :sub:`00Lhigh` + - Y'\ :sub:`00Rlow` + - Y'\ :sub:`00Rhigh` + - Y'\ :sub:`01Llow` + - Y'\ :sub:`01Lhigh` + - Y'\ :sub:`01Rlow` + - Y'\ :sub:`01Rhigh` + * - start + 8: + - Y'\ :sub:`10Llow` + - Y'\ :sub:`10Lhigh` + - Y'\ :sub:`10Rlow` + - Y'\ :sub:`10Rhigh` + - Y'\ :sub:`11Llow` + - Y'\ :sub:`11Lhigh` + - Y'\ :sub:`11Rlow` + - Y'\ :sub:`11Rhigh` + * - start + 16: + - Y'\ :sub:`20Llow` + - Y'\ :sub:`20Lhigh` + - Y'\ :sub:`20Rlow` + - Y'\ :sub:`20Rhigh` + - Y'\ :sub:`21Llow` + - Y'\ :sub:`21Lhigh` + - Y'\ :sub:`21Rlow` + - Y'\ :sub:`21Rhigh` + * - start + 24: + - Y'\ :sub:`30Llow` + - Y'\ :sub:`30Lhigh` + - Y'\ :sub:`30Rlow` + - Y'\ :sub:`30Rhigh` + - Y'\ :sub:`31Llow` + - Y'\ :sub:`31Lhigh` + - Y'\ :sub:`31Rlow` + - Y'\ :sub:`31Rhigh`
Documentation/userspace-api/media/v4l/yuv-formats.rst +1 -0
@@ -269,5 +269,6 @@ image. pixfmt-yuv-luma pixfmt-y8i pixfmt-y12i + pixfmt-y16i pixfmt-uv8 pixfmt-m420
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1317,6 +1317,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_IPU3_Y10 : descr ="10-bit greyscale (IPU3 Packed)" ;break ;case V4L2_PIX_FMT_Y8I : descr ="Interleaved 8-bit Greyscale" ;break ;case V4L2_PIX_FMT_Y12I : descr ="Interleaved 12-bit Greyscale" ;break ; +case V4L2_PIX_FMT_Y16I : descr ="Interleaved 16-bit Greyscale" ;break ;case V4L2_PIX_FMT_Z16 : descr ="16-bit Depth" ;break ;case V4L2_PIX_FMT_INZI : descr ="Planar 10:16 Greyscale Depth" ;break ;case V4L2_PIX_FMT_CNF4 : descr ="4-bit Depth Confidence (Packed)" ;break ;
include/uapi/linux/videodev2.h +1 -0
@@ -767,6 +767,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I')/* S5C73M3 interleaved UYVY/JPEG */ #define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ')/* Greyscale 8-bit L/R interleaved */ #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I')/* Greyscale 12-bit L/R interleaved */ +#define V4L2_PIX_FMT_Y16I v4l2_fourcc('Y', '1', '6', 'I')/* Greyscale 16-bit L/R interleaved */ #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')/* Depth data 16-bit */ #define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1')/* Mediatek compressed block mode */ #define V4L2_PIX_FMT_MM21 v4l2_fourcc('M', 'M', '2', '1')/* Mediatek 8-bit block mode, two non-contiguous planes */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/9 media: uvcvideo: Add a quirk for the Kaiweets KTI-W02 infrared camera
From: David Given <[email protected]>
[ Upstream commit b2ec92bb5605452d539a7aa1e42345b95acd8583 ]
Adds a quirk to make the NXP Semiconductors 1fc9:009b chipset work.
lsusb for the device reports:
Bus 003 Device 011: ID 1fc9:009b NXP Semiconductors IR VIDEO Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x1fc9 NXP Semiconductors
idProduct 0x009b IR VIDEO
bcdDevice 1.01
iManufacturer 1 Guide sensmart iProduct 2 IR VIDEO iSerial 0 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x00c2
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 100mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 3 IR Camera
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 0
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.00
wTotalLength 0x0033
dwClockFrequency 6.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 1
iTerminal 0
VideoControl Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
Warning: Descriptor too short
bUnitID 3
bSourceID 1
wMaxMultiplier 0
bControlSize 2
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x62
NTSC - 525/60
PAL - 525/60
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
VideoStreaming Interface Descriptor:
bLength 14
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 1
wTotalLength 0x0055
bEndpointAddress 0x82 EP 2 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 2
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 0
VideoStreaming Interface Descriptor:
bLength 27
bDescriptorType 36
bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)
bFormatIndex 1
bNumFrameDescriptors 1
guidFormat {e436eb7b-524f-11ce-9f53-0020af0ba770}
bBitsPerPixel 16
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 0
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 1
bmCapabilities 0x00
Still image unsupported
wWidth 240
wHeight 322
dwMinBitRate 12364800
dwMaxBitRate 30912000
dwMaxVideoFrameBufferSize 154560
dwDefaultFrameInterval 400000
bFrameIntervalType 2
dwFrameInterval( 0) 400000
dwFrameInterval( 1) 1000000
VideoStreaming Interface Descriptor:
bLength 10
bDescriptorType 36
bDescriptorSubtype 3 (STILL_IMAGE_FRAME)
bEndpointAddress 0x00 EP 0 OUT
bNumImageSizePatterns 1
wWidth( 0) 240
wHeight( 0) 322
bNumCompressionPatterns 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 1
Device Status: 0x0001
Self Powered
--- drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
@@ -2395,6 +2395,8 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {* The Logitech cameras listed below have their interface class set to * VENDOR_SPEC because they don't announce themselves as UVC devices, even * though they are compliant. +* +* Sort these by vendor/product ID. */ static const struct usb_device_id uvc_ids[] = {/* Quanta USB2.0 HD UVC Webcam */
@@ -2937,6 +2939,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX | UVC_QUIRK_IGNORE_SELECTOR_UNIT) }, +/* NXP Semiconductors IR VIDEO */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x1fc9, + .idProduct = 0x009b, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },/* Oculus VR Positional Tracker DK2 */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/9 media: vb2: use lock if wait_prepare/finish are NULL
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 88785982a19daa765e30ab3a605680202cfaee4e ]
If the wait_prepare or wait_finish callback is set, then call it. If it is NULL and the queue lock pointer is not NULL, then just unlock/lock that mutex.
This allows simplifying drivers by dropping the wait_prepare and wait_finish ops (and eventually the vb2_ops_wait_prepare/finish helpers).
--- drivers/media/common/videobuf2/videobuf2-core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/media/common/videobuf2/videobuf2-core.c +10 -3
@@ -1860,7 +1860,10 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)* become ready or for streamoff. Driver's lock is released to * allow streamoff or qbuf to be called while waiting. */ -call_void_qop (q, wait_prepare, q); +if (q->ops->wait_prepare) +call_void_qop (q, wait_prepare, q); +else if (q->lock) +mutex_unlock (q->lock);/* * All locks have been released, it is safe to sleep now.
@@ -1870,12 +1873,16 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) !list_empty (&q->done_list) || !q->streaming || q->error); +if (q->ops->wait_finish) +call_void_qop (q, wait_finish, q); +else if (q->lock) +mutex_lock (q->lock); + + q->waiting_in_dqbuf =0 ;/* * We need to reevaluate both conditions again after reacquiring * the locks or return an error if one occurred. */ -call_void_qop (q, wait_finish, q); - q->waiting_in_dqbuf =0 ;if (ret) {dprintk (q,1 ,"sleep was interrupted\n" );return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/9 media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108
In reply to Sasha LevinFrom: Rohan Barar <[email protected]>
[ Upstream commit 61a830bc0ea69a05d8a4534f825c6aa618263649 ]
Add Dexatek Technology Ltd USB Video Grabber 1d19:6108 to the cx231xx driver. This device is sold under the name "BAUHN DVD Maker (DK8723)" by ALDI in Australia.
This device is similar to 1d19:6109, which is already included in cx231xx.
Both video and audio capture function correctly after installing the patched cx231xx driver.
Patch Changelog
v1:
- Initial submission.
v2:
- Fix SoB + Improve subject.
v3:
- Rephrase message to not exceed 75 characters per line.
- Removed reference to external GitHub URL.
--- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/cx231xx/cx231xx-cards.c +2 -0
@@ -994,6 +994,8 @@ const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards);/* table of devices that work with this driver */ struct usb_device_id cx231xx_id_table[] = { + {USB_DEVICE (0x1D19 ,0x6108 ), + .driver_info =CX231XX_BOARD_PV_XCAPTURE_USB }, {USB_DEVICE (0x1D19 ,0x6109 ), .driver_info =CX231XX_BOARD_PV_XCAPTURE_USB }, {USB_DEVICE (0x0572 ,0x5A3C ),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/9 mmc: core: Add SD card quirk for broken poweroff notification
In reply to Sasha LevinFrom: Keita Aihara <[email protected]>
[ Upstream commit cd068d51594d9635bf6688fc78717572b78bce6a ]
GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 report that they support poweroff notification and cache, but they are not working correctly.
Flush Cache bit never gets cleared in sd_flush_cache() and Poweroff Notification Ready bit also never gets set to 1 within 1 second from the end of busy of CMD49 in sd_poweroff_notify().
This leads to I/O error and runtime PM error state.
I observed that the same card manufactured on 01/2024 works as expected.
This problem seems similar to the Kingston cards fixed with commit c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019") and should be handled using quirks.
CID for the problematic card is here.
12345641535443002000000145016200
Manufacturer ID is 0x12 and defined as CID_MANFID_GIGASTONE as of now, but would like comments on what naming is appropriate because MID list is not public and not sure it's right.
--- drivers/mmc/core/card.h | 7 +++++++ drivers/mmc/core/quirks.h | 9 +++++++++ drivers/mmc/core/sd.c | 2 +- include/linux/mmc/card.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-)
drivers/mmc/core/card.h +7 -0
@@ -82,6 +82,7 @@ struct mmc_fixup {#define CID_MANFID_SANDISK_SD 0x3#define CID_MANFID_ATP 0x9#define CID_MANFID_TOSHIBA 0x11 +#define CID_MANFID_GIGASTONE 0x12#define CID_MANFID_MICRON 0x13#define CID_MANFID_SAMSUNG 0x15#define CID_MANFID_APACER 0x27
@@ -284,4 +285,10 @@ static inline int mmc_card_broken_cache_flush(const struct mmc_card *c) {return c->quirks &MMC_QUIRK_BROKEN_CACHE_FLUSH ; } + +static inline int mmc_card_broken_sd_poweroff_notify (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY ; +} +#endif
drivers/mmc/core/quirks.h +9 -0
@@ -25,6 +25,15 @@ static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = { 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY), +/* +* GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 never +* clear Flush Cache bit and set Poweroff Notification Ready bit. +*/ +_FIXUP_EXT ("ASTC" ,CID_MANFID_GIGASTONE ,0x3456 ,2022 ,2 , +0 ,-1ull ,SDIO_ANY_ID ,SDIO_ANY_ID , add_quirk_sd, +MMC_QUIRK_BROKEN_SD_CACHE |MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY , +EXT_CSD_REV_ANY ), + END_FIXUP };
drivers/mmc/core/sd.c +1 -1
@@ -1118,7 +1118,7 @@ static int sd_parse_ext_reg_power(struct mmc_card *card, u8 fno, u8 page, card->ext_power.rev = reg_buf[0 ] &0xf ;/* Power Off Notification support at bit 4. */ -if (reg_buf[1 ] &BIT (4 )) +if ((reg_buf[1 ] &BIT (4 )) && !mmc_card_broken_sd_poweroff_notify (card)) card->ext_power.feature_support |=SD_EXT_POWER_OFF_NOTIFY ;/* Power Sustenance support at bit 5. */
include/linux/mmc/card.h +1 -0
@@ -296,6 +296,7 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14)/* Disable broken SD discard support */ #define MMC_QUIRK_BROKEN_SD_CACHE (1<<15)/* Disable broken SD cache support */ #define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16)/* Don't flush cache until the write has occurred */ +#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17)/* Disable broken SD poweroff notify support */ bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/9 soc: imx8m: Probe the SoC driver as platform driver
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 9cc832d37799dbea950c4c8a34721b02b8b5a8ff ]
With driver_async_probe=* on kernel command line, the following trace is produced because on i.MX8M Plus hardware because the soc-imx8m.c driver calls of_clk_get_by_name() which returns -EPROBE_DEFER because the clock driver is not yet probed. This was not detected during regular testing without driver_async_probe.
Convert the SoC code to platform driver and instantiate a platform device in its current device_initcall() to probe the platform driver. Rework .soc_revision callback to always return valid error code and return SoC revision via parameter. This way, if anything in the .soc_revision callback return -EPROBE_DEFER, it gets propagated to .probe and the .probe will get retried later.
"
------------[ cut here ]------------ WARNING: CPU: 1 PID: 1 at drivers/soc/imx/soc-imx8m.c:115 imx8mm_soc_revision+0xdc/0x180 CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.11.0-next-20240924-00002-g2062bb554dea #603 Hardware name: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3) (DT) pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : imx8mm_soc_revision+0xdc/0x180 lr : imx8mm_soc_revision+0xd0/0x180
sp : ffff8000821fbcc0
x29: ffff8000821fbce0 x28: 0000000000000000 x27: ffff800081810120
x26: ffff8000818a9970 x25: 0000000000000006 x24: 0000000000824311
x23: ffff8000817f42c8 x22: ffff0000df8be210 x21: fffffffffffffdfb
x20: ffff800082780000 x19: 0000000000000001 x18: ffffffffffffffff
x17: ffff800081fff418 x16: ffff8000823e1000 x15: ffff0000c03b65e8
x14: ffff0000c00051b0 x13: ffff800082790000 x12: 0000000000000801
x11: ffff80008278ffff x10: ffff80008209d3a6 x9 : ffff80008062e95c x8 : ffff8000821fb9a0 x7 : 0000000000000000 x6 : 00000000000080e3 x5 : ffff0000df8c03d8 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : fffffffffffffdfb x0 : fffffffffffffdfb
Call trace: imx8mm_soc_revision+0xdc/0x180 imx8_soc_init+0xb0/0x1e0 do_one_initcall+0x94/0x1a8 kernel_init_freeable+0x240/0x2a8 kernel_init+0x28/0x140 ret_from_fork+0x10/0x20 ---[ end trace 0000000000000000 ]---
SoC: i.MX8MP revision 1.1
"
--- drivers/soc/imx/soc-imx8m.c | 107 ++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 22 deletions(-)
drivers/soc/imx/soc-imx8m.c +85 -22
@@ -30,7 +30,7 @@struct imx8_soc_data {char *name; -u32 (*soc_revision)(void ); +int (*soc_revision)(u32 *socrev); };static u64 soc_uid;
@@ -51,24 +51,29 @@ static u32 imx8mq_soc_revision_from_atf(void)static inline u32 imx8mq_soc_revision_from_atf (void ) {return 0 ; };#endif -static u32 __init imx8mq_soc_revision (void ) +static int imx8mq_soc_revision (u32 *socrev) {struct device_node *np;void __iomem *ocotp_base;u32 magic;u32 rev;struct clk *clk; +int ret; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mq-ocotp" );if (!np) -return 0 ; +return -EINVAL ; ocotp_base =of_iomap (np,0 ); -WARN_ON (!ocotp_base); +if (!ocotp_base) { + ret = -EINVAL ; + goto err_iomap; + } + clk =of_clk_get_by_name (np,NULL );if (IS_ERR (clk)) { -WARN_ON (IS_ERR (clk)); -return 0 ; + ret =PTR_ERR (clk); + goto err_clk; }clk_prepare_enable (clk);
@@ -88,32 +93,45 @@ static u32 __init imx8mq_soc_revision(void) soc_uid <<=32 ; soc_uid |=readl_relaxed (ocotp_base +OCOTP_UID_LOW ); + *socrev = rev; +clk_disable_unprepare (clk);clk_put (clk);iounmap (ocotp_base);of_node_put (np); -return rev; +return 0 ; + +err_clk: +iounmap (ocotp_base); +err_iomap: +of_node_put (np); +return ret; } -static void __init imx8mm_soc_uid (void ) +static int imx8mm_soc_uid (void ) {void __iomem *ocotp_base;struct device_node *np;struct clk *clk; +int ret =0 ;u32 offset =of_machine_is_compatible ("fsl,imx8mp" ) ?IMX8MP_OCOTP_UID_OFFSET :0 ; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mm-ocotp" );if (!np) -return ; +return -EINVAL ; ocotp_base =of_iomap (np,0 ); -WARN_ON (!ocotp_base); +if (!ocotp_base) { + ret = -EINVAL ; + goto err_iomap; + } + clk =of_clk_get_by_name (np,NULL );if (IS_ERR (clk)) { -WARN_ON (IS_ERR (clk)); -return ; + ret =PTR_ERR (clk); + goto err_clk; }clk_prepare_enable (clk);
@@ -124,31 +142,41 @@ static void __init imx8mm_soc_uid(void)clk_disable_unprepare (clk);clk_put (clk); + +err_clk:iounmap (ocotp_base); +err_iomap:of_node_put (np); + +return ret; } -static u32 __init imx8mm_soc_revision (void ) +static int imx8mm_soc_revision (u32 *socrev) {struct device_node *np;void __iomem *anatop_base; -u32 rev; +int ret; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mm-anatop" );if (!np) -return 0 ; +return -EINVAL ; anatop_base =of_iomap (np,0 ); -WARN_ON (!anatop_base); +if (!anatop_base) { + ret = -EINVAL ; + goto err_iomap; + } - rev =readl_relaxed (anatop_base +ANADIG_DIGPROG_IMX8MM ); + *socrev =readl_relaxed (anatop_base +ANADIG_DIGPROG_IMX8MM );iounmap (anatop_base);of_node_put (np); -imx8mm_soc_uid (); +return imx8mm_soc_uid (); -return rev; +err_iomap: +of_node_put (np); +return ret; }static const struct imx8_soc_data imx8mq_soc_data = {
@@ -184,7 +212,7 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = { kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \ "unknown" -static int __init imx8_soc_init(void) +static int imx8m_soc_probe(struct platform_device *pdev) {struct soc_device_attribute *soc_dev_attr;struct soc_device *soc_dev;
@@ -212,8 +240,11 @@ static int __init imx8_soc_init(void) data = id->data;if (data) { soc_dev_attr->soc_id = data->name; -if (data->soc_revision) - soc_rev = data->soc_revision (); +if (data->soc_revision) { + ret = data->soc_revision (&soc_rev); +if (ret) + goto free_soc; + } } soc_dev_attr->revision =imx8_revision (soc_rev);
@@ -251,4 +282,36 @@ static int __init imx8_soc_init(void)kfree (soc_dev_attr);return ret; } + +static struct platform_driver imx8m_soc_driver = { + .probe = imx8m_soc_probe, + .driver = { + .name ="imx8m-soc" , + }, +}; + +static int __init imx8_soc_init (void ) +{ +struct platform_device *pdev; +int ret; + +/* No match means this is non-i.MX8M hardware, do nothing. */ +if (!of_match_node (imx8_soc_match, of_root)) +return 0 ; + + ret =platform_driver_register (&imx8m_soc_driver); +if (ret) { +pr_err ("Failed to register imx8m-soc platform driver: %d\n" , ret); +return ret; + } + + pdev =platform_device_register_simple ("imx8m-soc" ,-1 ,NULL ,0 ); +if (IS_ERR (pdev)) { +pr_err ("Failed to register imx8m-soc platform device: %ld\n" ,PTR_ERR (pdev)); +platform_driver_unregister (&imx8m_soc_driver); +return PTR_ERR (pdev); + } + +return 0 ; +}device_initcall (imx8_soc_init);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/9 HID: bpf: Fix NKRO on Mistel MD770
In reply to Sasha LevinFrom: Benjamin Tissoires <[email protected]>
[ Upstream commit 9bc089307e8dff7797233308372b4a90ce8f79be ]
Mistel MD770 keyboard (using Holtek Semiconductor, Inc. controller) has a quirk in report descriptor in one of its interfaces (more detail in the source file). Fix up the descriptor to allow NKRO to work again.
Tested by loading the BPF program and confirming that 8 simultaneous keypresses work.
--- drivers/hid/bpf/progs/Mistel__MD770.bpf.c | 154 ++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 drivers/hid/bpf/progs/Mistel__MD770.bpf.c
drivers/hid/bpf/progs/Mistel__MD770.bpf.c new file +154 -0
@@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024 Tatsuyuki Ishi +*/ + +#include "vmlinux.h" +#include "hid_bpf.h" +#include "hid_bpf_helpers.h" +#include <bpf/bpf_tracing.h> + +#define VID_HOLTEK 0x04D9 +#define PID_MD770 0x0339 +#define RDESC_SIZE 203 + +HID_BPF_CONFIG ( +HID_DEVICE (BUS_USB ,HID_GROUP_GENERIC ,VID_HOLTEK ,PID_MD770 ) +); + +/* +* The Mistel MD770 keyboard reports the first 6 simultaneous key presses +* through the first interface, and anything beyond that through a second +* interface. Unfortunately, the second interface's report descriptor has an +* error, causing events to be malformed and ignored. This HID-BPF driver +* fixes the descriptor to allow NKRO to work again. +* +* For reference, this is the original report descriptor: +* +* 0x05, 0x01, // Usage Page (Generic Desktop) 0 +* 0x09, 0x80, // Usage (System Control) 2 +* 0xa1, 0x01, // Collection (Application) 4 +* 0x85, 0x01, // Report ID (1) 6 +* 0x19, 0x81, // Usage Minimum (129) 8 +* 0x29, 0x83, // Usage Maximum (131) 10 +* 0x15, 0x00, // Logical Minimum (0) 12 +* 0x25, 0x01, // Logical Maximum (1) 14 +* 0x95, 0x03, // Report Count (3) 16 +* 0x75, 0x01, // Report Size (1) 18 +* 0x81, 0x02, // Input (Data,Var,Abs) 20 +* 0x95, 0x01, // Report Count (1) 22 +* 0x75, 0x05, // Report Size (5) 24 +* 0x81, 0x01, // Input (Cnst,Arr,Abs) 26 +* 0xc0, // End Collection 28 +* 0x05, 0x0c, // Usage Page (Consumer Devices) 29 +* 0x09, 0x01, // Usage (Consumer Control) 31 +* 0xa1, 0x01, // Collection (Application) 33 +* 0x85, 0x02, // Report ID (2) 35 +* 0x15, 0x00, // Logical Minimum (0) 37 +* 0x25, 0x01, // Logical Maximum (1) 39 +* 0x95, 0x12, // Report Count (18) 41 +* 0x75, 0x01, // Report Size (1) 43 +* 0x0a, 0x83, 0x01, // Usage (AL Consumer Control Config) 45 +* 0x0a, 0x8a, 0x01, // Usage (AL Email Reader) 48 +* 0x0a, 0x92, 0x01, // Usage (AL Calculator) 51 +* 0x0a, 0x94, 0x01, // Usage (AL Local Machine Browser) 54 +* 0x09, 0xcd, // Usage (Play/Pause) 57 +* 0x09, 0xb7, // Usage (Stop) 59 +* 0x09, 0xb6, // Usage (Scan Previous Track) 61 +* 0x09, 0xb5, // Usage (Scan Next Track) 63 +* 0x09, 0xe2, // Usage (Mute) 65 +* 0x09, 0xea, // Usage (Volume Down) 67 +* 0x09, 0xe9, // Usage (Volume Up) 69 +* 0x0a, 0x21, 0x02, // Usage (AC Search) 71 +* 0x0a, 0x23, 0x02, // Usage (AC Home) 74 +* 0x0a, 0x24, 0x02, // Usage (AC Back) 77 +* 0x0a, 0x25, 0x02, // Usage (AC Forward) 80 +* 0x0a, 0x26, 0x02, // Usage (AC Stop) 83 +* 0x0a, 0x27, 0x02, // Usage (AC Refresh) 86 +* 0x0a, 0x2a, 0x02, // Usage (AC Bookmarks) 89 +* 0x81, 0x02, // Input (Data,Var,Abs) 92 +* 0x95, 0x01, // Report Count (1) 94 +* 0x75, 0x0e, // Report Size (14) 96 +* 0x81, 0x01, // Input (Cnst,Arr,Abs) 98 +* 0xc0, // End Collection 100 +* 0x05, 0x01, // Usage Page (Generic Desktop) 101 +* 0x09, 0x02, // Usage (Mouse) 103 +* 0xa1, 0x01, // Collection (Application) 105 +* 0x09, 0x01, // Usage (Pointer) 107 +* 0xa1, 0x00, // Collection (Physical) 109 +* 0x85, 0x03, // Report ID (3) 111 +* 0x05, 0x09, // Usage Page (Button) 113 +* 0x19, 0x01, // Usage Minimum (1) 115 +* 0x29, 0x08, // Usage Maximum (8) 117 +* 0x15, 0x00, // Logical Minimum (0) 119 +* 0x25, 0x01, // Logical Maximum (1) 121 +* 0x75, 0x01, // Report Size (1) 123 +* 0x95, 0x08, // Report Count (8) 125 +* 0x81, 0x02, // Input (Data,Var,Abs) 127 +* 0x05, 0x01, // Usage Page (Generic Desktop) 129 +* 0x09, 0x30, // Usage (X) 131 +* 0x09, 0x31, // Usage (Y) 133 +* 0x16, 0x01, 0x80, // Logical Minimum (-32767) 135 +* 0x26, 0xff, 0x7f, // Logical Maximum (32767) 138 +* 0x75, 0x10, // Report Size (16) 141 +* 0x95, 0x02, // Report Count (2) 143 +* 0x81, 0x06, // Input (Data,Var,Rel) 145 +* 0x09, 0x38, // Usage (Wheel) 147 +* 0x15, 0x81, // Logical Minimum (-127) 149 +* 0x25, 0x7f, // Logical Maximum (127) 151 +* 0x75, 0x08, // Report Size (8) 153 +* 0x95, 0x01, // Report Count (1) 155 +* 0x81, 0x06, // Input (Data,Var,Rel) 157 +* 0x05, 0x0c, // Usage Page (Consumer Devices) 159 +* 0x0a, 0x38, 0x02, // Usage (AC Pan) 161 +* 0x95, 0x01, // Report Count (1) 164 +* 0x81, 0x06, // Input (Data,Var,Rel) 166 +* 0xc0, // End Collection 168 +* 0xc0, // End Collection 169 +* 0x05, 0x01, // Usage Page (Generic Desktop) 170 +* 0x09, 0x06, // Usage (Keyboard) 172 +* 0xa1, 0x01, // Collection (Application) 174 +* 0x85, 0x04, // Report ID (4) 176 +* 0x05, 0x07, // Usage Page (Keyboard) 178 +* 0x95, 0x01, // Report Count (1) 180 +* 0x75, 0x08, // Report Size (8) 182 +* 0x81, 0x03, // Input (Cnst,Var,Abs) 184 +* 0x95, 0xe8, // Report Count (232) 186 +* 0x75, 0x01, // Report Size (1) 188 +* 0x15, 0x00, // Logical Minimum (0) 190 +* 0x25, 0x01, // Logical Maximum (1) 192 +* 0x05, 0x07, // Usage Page (Keyboard) 194 +* 0x19, 0x00, // Usage Minimum (0) 196 +* 0x29, 0xe7, // Usage Maximum (231) 198 +* 0x81, 0x00, // Input (Data,Arr,Abs) 200 <- change to 0x81, 0x02 (Data,Var,Abs) +* 0xc0, // End Collection 202 +*/ + +SEC (HID_BPF_RDESC_FIXUP) +int BPF_PROG(hid_rdesc_fixup_mistel_md770, struct hid_bpf_ctx *hctx) +{ +__u8 *data =hid_bpf_get_data (hctx,0 ,HID_MAX_DESCRIPTOR_SIZE ); + +if (!data) +return 0 ;/* EPERM check */ + +if (data[201 ] ==0x00 ) + data[201 ] =0x02 ; + +return 0 ; +} + +HID_BPF_OPS (mistel_md770) = { + .hid_rdesc_fixup = (void *)hid_rdesc_fixup_mistel_md770, +}; + +SEC("syscall") +int probe (struct hid_bpf_probe_args *ctx) +{ + ctx->retval = ctx->rdesc_size !=RDESC_SIZE ; +if (ctx->retval) + ctx->retval = -EINVAL ; + +return 0 ; +} + +char _license[] SEC("license") = "GPL";
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/9 USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 62d2a940f29e6aa5a1d844a90820ca6240a99b34 ]
Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/usb/gadget/udc/pxa27x_udc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/pxa27x_udc.c +4 -3
@@ -2356,18 +2356,19 @@ static int pxa_udc_probe(struct platform_device *pdev)struct pxa_udc *udc = &memory;int retval =0 , gpio;struct pxa2xx_udc_mach_info *mach =dev_get_platdata (&pdev->dev); -unsigned long gpio_flags;if (mach) { - gpio_flags = mach->gpio_pullup_inverted ?GPIOF_ACTIVE_LOW :0 ; gpio = mach->gpio_pullup;if (gpio_is_valid (gpio)) { retval =devm_gpio_request_one (&pdev->dev, gpio, - gpio_flags, +GPIOF_OUT_INIT_LOW ,"USB D+ pullup" );if (retval)return retval; udc->gpiod =gpio_to_desc (mach->gpio_pullup); + +if (mach->gpio_pullup_inverted ^gpiod_is_active_low (udc->gpiod)) +gpiod_toggle_active_low (udc->gpiod); } udc->udc_command = mach->udc_command; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/9 HID: magicmouse: Apple Magic Trackpad 2 USB-C driver support
In reply to Sasha LevinFrom: Callahan Kovacs <[email protected]>
[ Upstream commit 87a2f10395c82c2b4687bb8611a6c5663a12f9e7 ]
Adds driver support for the USB-C model of Apple's Magic Trackpad 2.
The 2024 USB-C model is compatible with the existing Magic Trackpad 2 driver but has a different hardware ID.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-magicmouse.c | 56 ++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 15 deletions(-)
drivers/hid/hid-ids.h +1 -0
@@ -94,6 +94,7 @@#define USB_DEVICE_ID_APPLE_MAGICMOUSE2 0x0269#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265 +#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC 0x0324#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
drivers/hid/hid-magicmouse.c +41 -15
146 lines not on this page · raw message
Signature · 1 line
2.43.0