media: aspeed: refine mode detection flow
Subsystems (2)
v2 cover media: aspeed: refine mode detection flow
This patch series refines mode detection flow by fixing and refining of hsync/vsync polarity setting register handling. Please review this change.
Thanks,
-Jae
Changes since v1:
* Updated commit message.
Jae Hyun Yoo (2):
media: aspeed: refine hsync/vsync polarity setting logic
media: aspeed: set hsync and vsync polarities to normal before
starting mode detection
drivers/media/platform/aspeed-video.c | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/2 media: aspeed: refine hsync/vsync polarity setting logic
To prevent inaccurate detections of resolution, this commit enables clearing of hsync/vsync polarity bits based on probed sync state.
---
Changes since v1:
* Updated commit message.
drivers/media/platform/aspeed-video.c | 43 +++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-)
drivers/media/platform/aspeed-video.c +21 -22
@@ -614,7 +614,7 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video)int i;int hsync_counter =0 ;int vsync_counter =0 ; -u32 sts; +u32 sts, ctrl;for (i =0 ; i <NUM_POLARITY_CHECKS ; ++i) { sts =aspeed_video_read (video,VE_MODE_DETECT_STATUS );
@@ -629,30 +629,29 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video) hsync_counter++; } -if (hsync_counter <0 || vsync_counter <0 ) { -u32 ctrl =0 ; + ctrl =aspeed_video_read (video,VE_CTRL ); -if (hsync_counter <0 ) { - ctrl =VE_CTRL_HSYNC_POL ; - video->detected_timings.polarities &= - ~V4L2_DV_HSYNC_POS_POL ; - }else { - video->detected_timings.polarities |= -V4L2_DV_HSYNC_POS_POL ; - } - -if (vsync_counter <0 ) { - ctrl =VE_CTRL_VSYNC_POL ; - video->detected_timings.polarities &= - ~V4L2_DV_VSYNC_POS_POL ; - }else { - video->detected_timings.polarities |= -V4L2_DV_VSYNC_POS_POL ; - } +if (hsync_counter <0 ) { + ctrl |=VE_CTRL_HSYNC_POL ; + video->detected_timings.polarities &= + ~V4L2_DV_HSYNC_POS_POL ; + }else { + ctrl &= ~VE_CTRL_HSYNC_POL ; + video->detected_timings.polarities |= +V4L2_DV_HSYNC_POS_POL ; + } -if (ctrl) -aspeed_video_update (video,VE_CTRL ,0 , ctrl); +if (vsync_counter <0 ) { + ctrl |=VE_CTRL_VSYNC_POL ; + video->detected_timings.polarities &= + ~V4L2_DV_VSYNC_POS_POL ; + }else { + ctrl &= ~VE_CTRL_VSYNC_POL ; + video->detected_timings.polarities |= +V4L2_DV_VSYNC_POS_POL ; } + +aspeed_video_write (video,VE_CTRL , ctrl); } static bool aspeed_video_alloc_buf(struct aspeed_video *video,
Signature · 1 line
2.23.0
PATCH v2 1/2 media: aspeed: refine hsync/vsync polarity setting logic
Quoted 2 lines · Jae Hyun Yoo
To prevent inaccurate detections of resolution, this commit enables clearing of hsync/vsync polarity bits based on probed sync state.
Thanks Jae, looks fine.
Quoted 73 lines
Signed-off-by Jae Hyun Yoo <[email protected]>---
Changes since v1:
* Updated commit message.drivers/media/platform/aspeed-video.c | 43 +++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-)drivers/media/platform/aspeed-video.c +21
-22@@ -614,7 +614,7 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video)int i;int hsync_counter =0 ;int vsync_counter =0 ; -u32 sts; +u32 sts, ctrl;for (i =0 ; i <NUM_POLARITY_CHECKS ; ++i) { sts =aspeed_video_read (video,VE_MODE_DETECT_STATUS );@@ -629,30 +629,29 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video) hsync_counter++; } -if (hsync_counter <0 || vsync_counter <0 ) { -u32 ctrl =0 ; + ctrl =aspeed_video_read (video,VE_CTRL ); -if (hsync_counter <0 ) { - ctrl =VE_CTRL_HSYNC_POL ; - video->detected_timings.polarities &= - ~V4L2_DV_HSYNC_POS_POL ; - }else { - video->detected_timings.polarities |= -V4L2_DV_HSYNC_POS_POL ; - } - -if (vsync_counter <0 ) { - ctrl =VE_CTRL_VSYNC_POL ; - video->detected_timings.polarities &= - ~V4L2_DV_VSYNC_POS_POL ; - }else { - video->detected_timings.polarities |= -V4L2_DV_VSYNC_POS_POL ; - } +if (hsync_counter <0 ) { + ctrl |=VE_CTRL_HSYNC_POL ; + video->detected_timings.polarities &= + ~V4L2_DV_HSYNC_POS_POL ; + }else { + ctrl &= ~VE_CTRL_HSYNC_POL ; + video->detected_timings.polarities |= +V4L2_DV_HSYNC_POS_POL ; + } -if (ctrl) -aspeed_video_update (video,VE_CTRL ,0 , ctrl); +if (vsync_counter <0 ) { + ctrl |=VE_CTRL_VSYNC_POL ; + video->detected_timings.polarities &= + ~V4L2_DV_VSYNC_POS_POL ; + }else { + ctrl &= ~VE_CTRL_VSYNC_POL ; + video->detected_timings.polarities |= +V4L2_DV_VSYNC_POS_POL ; } + +aspeed_video_write (video,VE_CTRL , ctrl); } static bool aspeed_video_alloc_buf(struct aspeed_video *video,
PATCH v2 2/2 media: aspeed: set hsync and vsync polarities to normal before starting mode detection
In reply to Jae Hyun YooSometimes it detects a weird resolution such as 1024x287 when the actual resolution is 1024x768. To resolve such an issue, this commit adds clearing for hsync and vsync polarity register bits at the beginning of the first mode detection. This is recommended in the datasheet.
---
Changes since v1:
None
drivers/media/platform/aspeed-video.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/aspeed-video.c +2 -0
@@ -740,6 +740,8 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) }set_bit (VIDEO_RES_DETECT , &video->flags); +aspeed_video_update (video,VE_CTRL , +VE_CTRL_VSYNC_POL |VE_CTRL_HSYNC_POL ,0 );aspeed_video_enable_mode_detect (video); rc = wait_event_interruptible_timeout(video->wait,
Signature · 1 line
2.23.0
PATCH v2 2/2 media: aspeed: set hsync and vsync polarities to normal before starting mode detection
Quoted 5 lines · Jae Hyun Yoo
Sometimes it detects a weird resolution such as 1024x287 when the actual resolution is 1024x768. To resolve such an issue, this commit adds clearing for hsync and vsync polarity register bits at the beginning of the first mode detection. This is recommended in the datasheet.
Quoted 22 lines
Signed-off-by Jae Hyun Yoo <[email protected]>---
Changes since v1:
Nonedrivers/media/platform/aspeed-video.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/platform/aspeed-video.c +2
-0@@ -740,6 +740,8 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) }set_bit (VIDEO_RES_DETECT , &video->flags); +aspeed_video_update (video,VE_CTRL , +VE_CTRL_VSYNC_POL |VE_CTRL_HSYNC_POL ,0 );aspeed_video_enable_mode_detect (video); rc = wait_event_interruptible_timeout(video->wait,