Skip to contentSkip to conversation

media: aspeed: Fix signal status not updated immediately

PATCH In review Jammy Huang 2 participants 3 messages Nov 8, 2021 – Nov 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: aspeed: Fix signal status not updated immediately

If res-chg, VE_INTERRUPT_MODE_DETECT_WD irq will be raised. But v4l2_input_status wont't be updated to no-signal immediately until aspeed_video_get_resolution() in aspeed_video_resolution_work().

During the period of time, aspeed_video_start_frame() could be called because it doesn't know signal is unstable now. If it goes with aspeed_video_init_regs() of aspeed_video_irq_res_change() simultaneously , it will mess up hw state.

To fix this problem, v4l2_input_status will be updated to no-signal immediately for VE_INTERRUPT_MODE_DETECT_WD irq.

Fixes d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
---
 drivers/media/platform/aspeed-video.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/aspeed-video.c +3 -3
index 1ade264a8b69..3facd7ecc1a1 100644
@@ -762,6 +762,8 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay)
 	set_bit(VIDEO_RES_CHANGE, &video->flags);
 	clear_bit(VIDEO_FRAME_INPRG, &video->flags);
 
+	video->v4l2_input_status = V4L2_IN_ST_NO_SIGNAL;
+
 	aspeed_video_off(video);
 	aspeed_video_on(video);
 	aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR);
@@ -1889,7 +1891,6 @@ static void aspeed_video_resolution_work(struct work_struct *work)
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct aspeed_video *video = container_of(dwork, struct aspeed_video,
 						  res_work);
-	u32 input_status = video->v4l2_input_status;
 
 	/* Exit early in case no clients remain */
 	if (test_bit(VIDEO_STOPPED, &video->flags))
@@ -1902,8 +1903,7 @@ static void aspeed_video_resolution_work(struct work_struct *work)
 	aspeed_video_get_resolution(video);
 
 	if (video->detected_timings.width != video->active_timings.width ||
-	    video->detected_timings.height != video->active_timings.height ||
-	    input_status != video->v4l2_input_status) {
+	    video->detected_timings.height != video->active_timings.height) {
 		static const struct v4l2_event ev = {
 			.type = V4L2_EVENT_SOURCE_CHANGE,
 			.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw

Dear Jammy,

Am 08.11.21 um 07:11 schrieb Jammy Huang:

Maybe for the commit message summary:

media: aspeed: Update signal status immediately to ensure sane hw state

Quoted 2 lines

If res-chg, VE_INTERRUPT_MODE_DETECT_WD irq will be raised. But v4l2_input_status wont't be updated to no-signal immediately until

won?t

Quoted 6 lines

aspeed_video_get_resolution() in aspeed_video_resolution_work().

During the period of time, aspeed_video_start_frame() could be called because it doesn't know signal is unstable now. If it goes with aspeed_video_init_regs() of aspeed_video_irq_res_change() simultaneously , it will mess up hw state.

Please do not start a line with a comma, for example, put the comma on the line above.

Quoted 1 line

To fix this problem, v4l2_input_status will be updated to no-signal

? status is updated _ (Present tense in commit messages.)

Quoted 31 lines

immediately for VE_INTERRUPT_MODE_DETECT_WD irq.

Fixes d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
---
  drivers/media/platform/aspeed-video.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/aspeed-video.c +2 -1
index 1ade264a8b69..3facd7ecc1a1 100644
@@ -762,6 +762,8 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay)
  	set_bit(VIDEO_RES_CHANGE, &video->flags);
  	clear_bit(VIDEO_FRAME_INPRG, &video->flags);
 
+	video->v4l2_input_status = V4L2_IN_ST_NO_SIGNAL;
+
  	aspeed_video_off(video);
  	aspeed_video_on(video);
  	aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR);
@@ -1889,7 +1891,6 @@ static void aspeed_video_resolution_work(struct work_struct *work)
  	struct delayed_work *dwork = to_delayed_work(work);
  	struct aspeed_video *video = container_of(dwork, struct aspeed_video,
  						  res_work);
-	u32 input_status = video->v4l2_input_status;
 
  	/* Exit early in case no clients remain */
  	if (test_bit(VIDEO_STOPPED, &video->flags))

drivers/media/platform/aspeed-video.c static void aspeed_video_resolution_work(struct work_struct *work) · line 1909

Quoted 9 lines
drivers/media/platform/aspeed-video.c +1 -2
@@ -1902,8 +1903,7 @@ static void aspeed_video_resolution_work(struct work_struct *work)
  	aspeed_video_get_resolution(video);
 
  	if (video->detected_timings.width != video->active_timings.width ||
-	    video->detected_timings.height != video->active_timings.height ||
-	    input_status != video->v4l2_input_status) {
+	    video->detected_timings.height != video->active_timings.height) {
  		static const struct v4l2_event ev = {
  			.type = V4L2_EVENT_SOURCE_CHANGE,
  			.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,

Kind regards,

Paul

#2 lore raw

Dear Paul,

Thanks for your help. I will update in the next patch.

Quoted 72 lines · Paul Menzel

Dear Jammy,

Am 08.11.21 um 07:11 schrieb Jammy Huang:

Maybe for the commit message summary:

media: aspeed: Update signal status immediately to ensure sane hw state

Quoted 2 lines

If res-chg, VE_INTERRUPT_MODE_DETECT_WD irq will be raised. But v4l2_input_status wont't be updated to no-signal immediately until

won?t

Quoted 6 lines

aspeed_video_get_resolution() in aspeed_video_resolution_work().

During the period of time, aspeed_video_start_frame() could be called because it doesn't know signal is unstable now. If it goes with aspeed_video_init_regs() of aspeed_video_irq_res_change() simultaneously , it will mess up hw state.

Please do not start a line with a comma, for example, put the comma on the line above.

Quoted 1 line

To fix this problem, v4l2_input_status will be updated to no-signal

? status is updated _ (Present tense in commit messages.)

Quoted 31 lines

immediately for VE_INTERRUPT_MODE_DETECT_WD irq.

Fixes d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
---
   drivers/media/platform/aspeed-video.c | 6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/aspeed-video.c +2 -1
index 1ade264a8b69..3facd7ecc1a1 100644
@@ -762,6 +762,8 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay)
   	set_bit(VIDEO_RES_CHANGE, &video->flags);
   	clear_bit(VIDEO_FRAME_INPRG, &video->flags);
 
+	video->v4l2_input_status = V4L2_IN_ST_NO_SIGNAL;
+
   	aspeed_video_off(video);
   	aspeed_video_on(video);
   	aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR);
@@ -1889,7 +1891,6 @@ static void aspeed_video_resolution_work(struct work_struct *work)
   	struct delayed_work *dwork = to_delayed_work(work);
   	struct aspeed_video *video = container_of(dwork, struct aspeed_video,
   						  res_work);
-	u32 input_status = video->v4l2_input_status;
 
   	/* Exit early in case no clients remain */
   	if (test_bit(VIDEO_STOPPED, &video->flags))

drivers/media/platform/aspeed-video.c static void aspeed_video_resolution_work(struct work_struct *work) · line 1909

Quoted 9 lines
drivers/media/platform/aspeed-video.c +1 -2
@@ -1902,8 +1903,7 @@ static void aspeed_video_resolution_work(struct work_struct *work)
   	aspeed_video_get_resolution(video);
 
   	if (video->detected_timings.width != video->active_timings.width ||
-	    video->detected_timings.height != video->active_timings.height ||
-	    input_status != video->v4l2_input_status) {
+	    video->detected_timings.height != video->active_timings.height) {
   		static const struct v4l2_event ev = {
   			.type = V4L2_EVENT_SOURCE_CHANGE,
   			.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,

Kind regards,

Paul

Signature · 2 lines
Best Regards
Jammy