(1) sdr2hdr_tf use software config instead of hardware init;
(2) sdr2hdr_bt1886eotf dst range use 500 nit;
(3) sdr2hdr_bt1886eotf y0-y43 must multiply by 2 due to some special IC designs.
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Change-Id: I58afff82c49f6ebbedad350bccc383e9fad11c2f
Notify linux userspace hdmi has been plugged in or out and
audio needs to be reset.
Fixes: b84c5d0c81 ("drm/bridge: synopsys: dw-hdmi-qp: Only set extcon status when hdmi plug/unplug")
Change-Id: I7e7f3da2849ae4bb70d838281001a4ead2b7c03a
Signed-off-by: Algea Cao <algea.cao@rock-chips.com>
Signed-off-by: XiaoTan Luo <lxt@rock-chips.com>
1\ fix rmii_pins for rxer is not used in rmii
2\ regulators for serdes should be always on
3\ add rk3358m-automotive-ddr3-v11-linux-tb
Change-Id: Ic12c214a51ad023738ee98b4d202742640de1ab9
Signed-off-by: Jianlong Wang <jianlong.wang@rock-chips.com>
According to sii902x datasheet, the TClkSel (Bit[7:6] of reg 0x08,
that is SII902X_TPI_PIXEL_REPETITION) selects the factor by which
the input clock must be multiplied to give output clock frequency.
Some interlace mode may not set DRM_MODE_FLAG_DBLCLK flag like 1080i,
these mode should not enable CLK_RATIO_2X.
This patch make sure we only set CLK_RATIO_2X when the mode has
DRM_MODE_FLAG_DBLCLK flag.
Change-Id: I1cc98693c9c8348667fabddc13d8f5ac4e689e09
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
rockchip_drm_bind() may be delayed for others driver delay probe,
this maybe cause rockchip_drm_show_logo() be called after
rockchip_clocks_loader_unprotect() and lead to display error,
so move clk unprotect to the end of drm_bind.
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Change-Id: I6eeae1c1307f91777fec23c66c5d5413443335d0
The RV1126B introduce force RDN feature in MCU interface, which allow
to output high voltage level on the MCU_RDN line when MCU is sending
data, especially for data in the write direction. This feature helps
avoid unintended level flips on the RDN line.
Change-Id: I47d46e720e4ec44439570b216bddd694482851c7
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
Here we need to restore the volume and ioswitch status.
Otherwise, there will be no sound if you restore from
the xrun state.
Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
Change-Id: I96e4bbcde035a700e2e18ee8782d75cdac2b18be
The error returns wrong mode but it doesn't result in a wrong set.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I078db470e3c7230b12f55685f021f01f4aa39157
For RK3588, dclk_out is designed for DP, MIPI in both DSC and non-DSC
mode and HDMI in DSC mode.
In addditon, the dclk_out division factor should be the same as the
dclk_core division factor in HDMI DSC mode.
Change-Id: I08107a340036ff9984f52dd34044d8c634df14c1
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
However, the hdmi 2.0 spec requires that some flags are
set in the sink scdc regs, and those flags are very likely
to be reset when the cable has been disconnected. This will
thus result in a blank display, even if the display pipeline
configuration hasn't been modified or is in the exact
same state.
The solution we've had so far is to enable the scrambling
and high ratio related bits again on reconnection, but the
hdmi 2.0 spec (Section 6.1.3.1 - Scrambling Control) requires
that the scdc bit is set before sending any scrambled video
signal. Using that solution thus breaks that expectation.
So we need disable hdmi signal output when hdmi plug out.
writing scdc scrambling and high ratio regs when hdmi
plug in then enable hdmi signal output finally.
Change-Id: I422455e1d5b60c3fd4a3ef35ccb46de9fb0f28f8
Signed-off-by: Algea Cao <algea.cao@rock-chips.com>
This reverts commit ec6ce7075ef879b91a8710829016005dc8170f17.
Fix installation of WinUSB driver using OS descriptors. Without the
fix the drivers are not installed correctly and the property
'DeviceInterfaceGUID' is missing on host side.
The original change was based on the assumption that the interface
number is in the high byte of wValue but it is in the low byte,
instead. Unfortunately, the fix is based on MS documentation which is
also wrong.
The actual USB request for OS descriptors (using USB analyzer) looks
like:
Offset 0 1 2 3 4 5 6 7
0x000 C1 A1 02 00 05 00 0A 00
C1: bmRequestType (device to host, vendor, interface)
A1: nas magic number
0002: wValue (2: nas interface)
0005: wIndex (5: get extended property i.e. nas interface GUID)
008E: wLength (142)
The fix was tested on Windows 10 and Windows 11.
Change-Id: Ic5535fb6f0dff1dc337b99bafb8500966538bcb5
Cc: stable@vger.kernel.org
Fixes: ec6ce7075ef8 ("usb: gadget: composite: fix OS descriptors w_value logic")
Signed-off-by: Michal Vrastil <michal.vrastil@hidglobal.com>
Signed-off-by: Elson Roy Serrao <quic_eserrao@quicinc.com>
Acked-by: Peter korsgaard <peter@korsgaard.com>
Link: https://lore.kernel.org/r/20241113235433.20244-1-quic_eserrao@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
The commit e219a712bc ("usb: gadget: uvc: add v4l2
try_format api call") has introduced a bug that limit
the max frame size of framebase format (H264/H265) to
dw_max_video_frame_buffer_size which is a fixed value
460800 bytes.
This patch calculates the bytesperline value based on
the actual bBitsPerPixel and frame.w_width of framebase
format.
Fixes: e219a712bc ("usb: gadget: uvc: add v4l2 try_format api call")
Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I40c5b72a9c3707bdcc13244d5ae912339626071b
If the streamoff call was triggered by some previous disconnect
or userspace application shutdown the uvc_function_setup_continue
should not be called and the state should not be overwritten.
For this situation the set_alt(0) was never called and the streaming ep
has no USB_GADGET_DELAYED_STATUS pending.
Since the state then was already updated before we also omit the state
update.
Change-Id: I65382e0ed663138ea694c27276fe813c30863f89
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v7-9-e224bb1035f0@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit e723ebc3a9aa172ab8042382afcae310c953104d)
Since the req_free list will updated if enqueuing one request was not
possible it will be added back to the free list. With every available
free request in the queue it is a valid case for the pump worker to use
it and continue the pending bufferdata into requests for the req_ready
list.
Change-Id: Ib52f29e23a938b469782f4b25221e127c01cc8a3
Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v7-1-e224bb1035f0@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit adc292d54de9db2e6b8ecb7f81f278bbbaf713e9)
Add support for frame-based frame format, which can be used to support
multiple formats like H264 or H265, in addition to MJPEG and YUV frames.
The frame-based format is set to H264 by default, but it can be updated
to other formats by modifying the GUID through the guid configfs
attribute. Different structures are used for all three formats, as
H264 has a different structure compared to MJPEG and uncompressed
formats. These structures will be passed to the frame make function
based on the active format, using a common frame structure with
additional parameters needed only for frame-based formats. These
parameters are handled at runtime in the UVC driver.
Signed-off-by: Akash Kumar <quic_akakum@quicinc.com>
Link: https://lore.kernel.org/r/20240927152138.31416-1-quic_akakum@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I8be496e30e2f3f0e5756c0789c73f5c1746c9303
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 7b5a58952fc3b51905c2963647485565df1e5e26)
Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump
isoc usb requests", pump work could only be queued in uvc_video_complete()
and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON,
we can only depend on uvc_video_complete() to queue pump work. However,
this requires some free requests in req_ready list. If req_ready list is
empty all the time, pump work will never be queued and video datas will
never be pumped to usb controller. Actually, this situation could happen
when run uvc-gadget with static image:
$ ./uvc-gadget -i 1080p.jpg uvc.0
When capture image from this device, the user app will always block there.
The issue is uvc driver has queued video buffer before streamon, but the
req_ready list is empty all the time after streamon. This will queue pump
work in uvcg_video_enable() to fill some request to req_ready list so the
uvc device could work properly.
Change-Id: Iedfba9335ea5f1a61dc1157f8d20c647803c84cd
Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20240814112537.2608949-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit b52a07e07dead777517af3cbda851bb2cc157c9d)
When handling error status from uvcg_video_usb_req_queue,
uvc_video_complete currently calls uvcg_queue_cancel with
video->req_lock held. uvcg_queue_cancel internally locks
queue->irqlock, which nests queue->irqlock inside
video->req_lock. This isn't a functional bug at the
moment, but does open up possibilities for ABBA
deadlocks in the future.
This patch fixes the accidental nesting by dropping
video->req_lock before calling uvcg_queue_cancel.
Change-Id: Ic96546cff545b397fdf52b4f361bca42702cb940
Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20240104215009.2252452-2-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 9866dc4314c6c858e451933f965d64532aec00a9)
There is a path that may lead to freed memory being referenced,
causing kernel panics.
The kernel panic has the following stack trace:
Workqueue: uvcgadget uvcg_video_pump.c51fb85fece46625450f86adbf92c56c.cfi_jt
pstate: 60c00085 (nZCv daIf +PAN +UAO -TCO BTYPE=--)
pc : __list_del_entry_valid+0xc0/0xd4
lr : __list_del_entry_valid+0xc0/0xd4
Call trace:
__list_del_entry_valid+0xc0/0xd4
uvc_video_free_request+0x60/0x98
uvcg_video_pump+0x1cc/0x204
process_one_work+0x21c/0x4b8
worker_thread+0x29c/0x574
kthread+0x158/0x1b0
ret_from_fork+0x10/0x30
The root cause is that uvcg_video_usb_req_queue frees the uvc_request
if is_enabled is false and returns an error status. video_pump also
frees the associated request if uvcg_video_usb_req_queue returns an
error status, leading to double free and accessing garbage memory.
To fix the issue, this patch removes freeing logic from
uvcg_video_usb_req_queue, and lets the callers to the function handle
queueing errors as they see fit.
Change-Id: I8d8e644de5b5f26601e7764fd675f775535f63d3
Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Tested-by: Avichal Rakesh <arakesh@google.com>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20240104215009.2252452-1-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit fe814b5b0f3042f1a583734497e726ee53783cc1)
This reverts commit 3c5b006f3e.
gadget_is_{super|dual}speed() API check UDC controller capitblity. It
should pass down highest speed endpoint descriptor to UDC controller. So
UDC controller driver can reserve enough resource at check_config(),
especially mult and maxburst. So UDC driver (such as cdns3) can know need
at least (mult + 1) * (maxburst + 1) * wMaxPacketSize internal memory for
this uvc functions.
Change-Id: Iae006b68943aac4ec9958e08a11f19dec270f954
Cc: <stable@vger.kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231224153816.1664687-5-Frank.Li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 895ee5aefb7e24203de5dffae7ce9a02d78fa3d1)
When we use an async work queue to perform the function of pumping
usb requests to the usb controller, it is possible that amongst other
factors, thread scheduling affects at what cadence we're able to pump
requests. This could mean isoc usb requests miss their uframes - resulting
in video stream flickers on the host device.
To avoid this, we make the async_wq thread only produce isoc usb_requests
with uvc buffers encoded into them. The process of queueing to the
endpoint is done by the uvc_video_complete() handler. In case no
usb_requests are ready with encoded information, we just queue a zero
length request to the endpoint from the complete handler.
For bulk endpoints the async_wq thread still queues usb requests to the
endpoint.
Change-Id: Idc1000fbd32f46455f3084101c15f00b05c20f80
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
Suggested-by: Avichal Rakesh <arakesh@google.com>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20231120062026.3759463-1-jchowdhary@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 6acba0345b68772830582ca1ca369a2f45631275)
Currently, the uvc gadget driver allocates all uvc_requests as one array
and deallocates them all when the video stream stops. This includes
de-allocating all the usb_requests associated with those uvc_requests.
This can lead to use-after-free issues if any of those de-allocated
usb_requests were still owned by the usb controller.
This is patch 2 of 2 in fixing the use-after-free issue. It adds a new
flag to uvc_video to track when frames and requests should be flowing.
When disabling the video stream, the flag is tripped and, instead
of de-allocating all uvc_requests and usb_requests, the gadget
driver only de-allocates those usb_requests that are currently
owned by it (as present in req_free). Other usb_requests are left
untouched until their completion handler is called which takes care
of freeing the usb_request and its corresponding uvc_request.
Now that uvc_video does not depends on uvc->state, this patch removes
unnecessary upates to uvc->state that were made to accommodate uvc_video
logic. This should ensure that uvc gadget driver never accidentally
de-allocates a usb_request that it doesn't own.
Change-Id: Ie1cc134c191e087bcca114832ad99f5d3119e682
Link: https://lore.kernel.org/7cd81649-2795-45b6-8c10-b7df1055020d@google.com
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-4-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit da324ffce34c521b239f319d4051260444a3eb4a)
Currently, the uvc gadget driver allocates all uvc_requests as one array
and deallocates them all when the video stream stops. This includes
de-allocating all the usb_requests associated with those uvc_requests.
This can lead to use-after-free issues if any of those de-allocated
usb_requests were still owned by the usb controller.
This patch is 1 of 2 patches addressing the use-after-free issue.
Instead of bulk allocating all uvc_requests as an array, this patch
allocates uvc_requests one at a time, which should allows for similar
granularity when deallocating the uvc_requests. This patch has no
functional changes other than allocating each uvc_request separately,
and similarly freeing each of them separately.
Change-Id: Ifc4c21cb46d5c947b6be03c5423ddfcbd5d9f23f
Link: https://lore.kernel.org/7cd81649-2795-45b6-8c10-b7df1055020d@google.com
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-2-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit aeb686a98a9e9743c4c0338957e59643a2708146)