linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next v2 0/2] media: aspeed: refine mode detection flow
@ 2019-09-13 18:11 Jae Hyun Yoo
  2019-09-13 18:11 ` [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic Jae Hyun Yoo
  2019-09-13 18:11 ` [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection Jae Hyun Yoo
  0 siblings, 2 replies; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-09-13 18:11 UTC (permalink / raw)
  To: Eddie James, Mauro Carvalho Chehab, Joel Stanley, Andrew Jeffery
  Cc: linux-aspeed, linux-media, openbmc, Jae Hyun Yoo

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(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic
  2019-09-13 18:11 [PATCH -next v2 0/2] media: aspeed: refine mode detection flow Jae Hyun Yoo
@ 2019-09-13 18:11 ` Jae Hyun Yoo
  2019-10-09 13:54   ` Eddie James
  2019-09-13 18:11 ` [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection Jae Hyun Yoo
  1 sibling, 1 reply; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-09-13 18:11 UTC (permalink / raw)
  To: Eddie James, Mauro Carvalho Chehab, Joel Stanley, Andrew Jeffery
  Cc: linux-aspeed, linux-media, openbmc, Jae Hyun Yoo

To prevent inaccurate detections of resolution, this commit enables
clearing of hsync/vsync polarity bits based on probed sync state.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
---
Changes since v1:
 * Updated commit message.

 drivers/media/platform/aspeed-video.c | 43 +++++++++++++--------------
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index eb12f3793062..8f77079da55a 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -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,
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection
  2019-09-13 18:11 [PATCH -next v2 0/2] media: aspeed: refine mode detection flow Jae Hyun Yoo
  2019-09-13 18:11 ` [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic Jae Hyun Yoo
@ 2019-09-13 18:11 ` Jae Hyun Yoo
  2019-10-09 13:55   ` Eddie James
  1 sibling, 1 reply; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-09-13 18:11 UTC (permalink / raw)
  To: Eddie James, Mauro Carvalho Chehab, Joel Stanley, Andrew Jeffery
  Cc: linux-aspeed, linux-media, openbmc, 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.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
---
Changes since v1:
 None

 drivers/media/platform/aspeed-video.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index 8f77079da55a..929b3a5b8849 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -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,
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic
  2019-09-13 18:11 ` [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic Jae Hyun Yoo
@ 2019-10-09 13:54   ` Eddie James
  0 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2019-10-09 13:54 UTC (permalink / raw)
  To: Jae Hyun Yoo, Eddie James, Mauro Carvalho Chehab, Joel Stanley,
	Andrew Jeffery
  Cc: openbmc, linux-aspeed, linux-media


On 9/13/19 1:11 PM, Jae Hyun Yoo wrote:
> To prevent inaccurate detections of resolution, this commit enables
> clearing of hsync/vsync polarity bits based on probed sync state.


Thanks Jae, looks fine.

Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
> ---
> Changes since v1:
>   * Updated commit message.
>
>   drivers/media/platform/aspeed-video.c | 43 +++++++++++++--------------
>   1 file changed, 21 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..8f77079da55a 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection
  2019-09-13 18:11 ` [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection Jae Hyun Yoo
@ 2019-10-09 13:55   ` Eddie James
  0 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2019-10-09 13:55 UTC (permalink / raw)
  To: Jae Hyun Yoo, Eddie James, Mauro Carvalho Chehab, Joel Stanley,
	Andrew Jeffery
  Cc: openbmc, linux-aspeed, linux-media


On 9/13/19 1:11 PM, Jae Hyun Yoo wrote:
> 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.


Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
> ---
> Changes since v1:
>   None
>
>   drivers/media/platform/aspeed-video.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index 8f77079da55a..929b3a5b8849 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-09 13:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 18:11 [PATCH -next v2 0/2] media: aspeed: refine mode detection flow Jae Hyun Yoo
2019-09-13 18:11 ` [PATCH -next v2 1/2] media: aspeed: refine hsync/vsync polarity setting logic Jae Hyun Yoo
2019-10-09 13:54   ` Eddie James
2019-09-13 18:11 ` [PATCH -next v2 2/2] media: aspeed: set hsync and vsync polarities to normal before starting mode detection Jae Hyun Yoo
2019-10-09 13:55   ` Eddie James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).