Improve stability of Aspeed video engine driver - 3rd phase
Subsystems (2)
cover Improve stability of Aspeed video engine driver - 3rd phase
This patch series adds bug fixes and improvements into the Aspeed video engine driver.
Jae Hyun Yoo (4):
media: aspeed: remove source buffer allocation before mode detection
media: aspeed: use different delays for triggering VE H/W reset
media: aspeed: fix an incorrect timeout checking in mode detection
media: aspeed: add a workaround to fix a silicon bug
drivers/media/platform/aspeed-video.c | 58 ++++++++++++--------------- 1 file changed, 25 insertions(+), 33 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/4 media: aspeed: remove source buffer allocation before mode detection
Mode detection doesn't require source buffer allocation so this commit removes that.
--- drivers/media/platform/aspeed-video.c | 21 --------------------- 1 file changed, 21 deletions(-)
drivers/media/platform/aspeed-video.c +0 -21
@@ -733,27 +733,6 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) det->height =MIN_HEIGHT ; video->v4l2_input_status =V4L2_IN_ST_NO_SIGNAL ; -/* -* Since we need max buffer size for detection, free the second source -* buffer first. -*/ -if (video->srcs[1 ].size) -aspeed_video_free_buf (video, &video->srcs[1 ]); - -if (video->srcs[0 ].size <VE_MAX_SRC_BUFFER_SIZE ) { -if (video->srcs[0 ].size) -aspeed_video_free_buf (video, &video->srcs[0 ]); - -if (!aspeed_video_alloc_buf (video, &video->srcs[0 ], -VE_MAX_SRC_BUFFER_SIZE )) { -dev_err (video->dev, -"Failed to allocate source buffers\n" ); -return ; - } - } - -aspeed_video_write (video,VE_SRC0_ADDR , video->srcs[0 ].dma); - do { if (tries) { set_current_state(TASK_INTERRUPTIBLE);
Signature · 1 line
2.21.0
Re: [PATCH dev-5.1 1/4] media: aspeed: remove source buffer allocation before mode detection
Quoted 2 lines · Jae Hyun Yoo
Mode detection doesn't require source buffer allocation so this commit removes that.
Quoted 38 lines
Signed-off-by Jae Hyun Yoo <[email protected]>--- drivers/media/platform/aspeed-video.c | 21 --------------------- 1 file changed, 21 deletions(-)drivers/media/platform/aspeed-video.c +0
-21@@ -733,27 +733,6 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) det->height =MIN_HEIGHT ; video->v4l2_input_status =V4L2_IN_ST_NO_SIGNAL ; -/* -* Since we need max buffer size for detection, free the second source -* buffer first. -*/ -if (video->srcs[1 ].size) -aspeed_video_free_buf (video, &video->srcs[1 ]); - -if (video->srcs[0 ].size <VE_MAX_SRC_BUFFER_SIZE ) { -if (video->srcs[0 ].size) -aspeed_video_free_buf (video, &video->srcs[0 ]); - -if (!aspeed_video_alloc_buf (video, &video->srcs[0 ], -VE_MAX_SRC_BUFFER_SIZE )) { -dev_err (video->dev, -"Failed to allocate source buffers\n" ); -return ; - } - } - -aspeed_video_write (video,VE_SRC0_ADDR , video->srcs[0 ].dma); - do { if (tries) { set_current_state(TASK_INTERRUPTIBLE);
PATCH 2/4 media: aspeed: use different delays for triggering VE H/W reset
In reply to Jae Hyun YooIn case of watchdog timeout detected while doing mode detection, it's better triggering video engine hardware reset immediately so this commit fixes code for the case. Other than the case, it will trigger video engine hardware reset after RESOLUTION_CHANGE_DELAY.
--- drivers/media/platform/aspeed-video.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/platform/aspeed-video.c +5 -4
@@ -522,7 +522,7 @@ static void aspeed_video_bufs_done(struct aspeed_video *video,spin_unlock_irqrestore (&video->lock, flags); } -static void aspeed_video_irq_res_change (struct aspeed_video *video) +static void aspeed_video_irq_res_change (struct aspeed_video *video,ulong delay) {spin_lock (&video->lock);dev_dbg (video->dev,"Resolution changed; resetting\n" );
@@ -534,7 +534,7 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video)spin_unlock (&video->lock);aspeed_video_bufs_done (video,VB2_BUF_STATE_ERROR ); -schedule_delayed_work (&video->res_work,RESOLUTION_CHANGE_DELAY ); +schedule_delayed_work (&video->res_work, delay); }static irqreturn_t aspeed_video_irq (int irq,void *arg)
@@ -547,7 +547,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)* re-initialize */ if (sts &VE_INTERRUPT_MODE_DETECT_WD ) { -aspeed_video_irq_res_change (video); +aspeed_video_irq_res_change (video,0 );return IRQ_HANDLED ; }
@@ -565,7 +565,8 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)* Signal acquired while NOT doing resolution * detection; reset the engine and re-initialize */ -aspeed_video_irq_res_change (video); +aspeed_video_irq_res_change (video, +RESOLUTION_CHANGE_DELAY );return IRQ_HANDLED ; } }
Signature · 1 line
2.21.0
Re: [PATCH dev-5.1 2/4] media: aspeed: use different delays for triggering VE H/W reset
Quoted 4 lines · Jae Hyun Yoo
In case of watchdog timeout detected while doing mode detection, it's better triggering video engine hardware reset immediately so this commit fixes code for the case. Other than the case, it will trigger video engine hardware reset after
RESOLUTION_CHANGE_DELAY.
Quoted 47 lines
Signed-off-by Jae Hyun Yoo <[email protected]>--- drivers/media/platform/aspeed-video.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/media/platform/aspeed-video.c +5
-4@@ -522,7 +522,7 @@ static void aspeed_video_bufs_done(struct aspeed_video *video,spin_unlock_irqrestore (&video->lock, flags); } -static void aspeed_video_irq_res_change (struct aspeed_video *video) +static void aspeed_video_irq_res_change (struct aspeed_video *video,ulong delay) {spin_lock (&video->lock);dev_dbg (video->dev,"Resolution changed; resetting\n" );@@ -534,7 +534,7 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video)spin_unlock (&video->lock);aspeed_video_bufs_done (video,VB2_BUF_STATE_ERROR ); -schedule_delayed_work (&video->res_work,RESOLUTION_CHANGE_DELAY ); +schedule_delayed_work (&video->res_work, delay); }static irqreturn_t aspeed_video_irq (int irq,void *arg)@@ -547,7 +547,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)* re-initialize */ if (sts &VE_INTERRUPT_MODE_DETECT_WD ) { -aspeed_video_irq_res_change (video); +aspeed_video_irq_res_change (video,0 );return IRQ_HANDLED ; }@@ -565,7 +565,8 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)* Signal acquired while NOT doing resolution * detection; reset the engine and re-initialize */ -aspeed_video_irq_res_change (video); +aspeed_video_irq_res_change (video, +RESOLUTION_CHANGE_DELAY );return IRQ_HANDLED ; } }
PATCH 3/4 media: aspeed: fix an incorrect timeout checking in mode detection
In reply to Jae Hyun YooThere is an incorrect timeout checking in mode detection logic so it misses resolution detecting chances. This commit fixes the bug.
--- drivers/media/platform/aspeed-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/aspeed-video.c +1 -1
@@ -737,7 +737,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) do { if (tries) { set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(INVALID_RESOLUTION_DELAY)) + if (!schedule_timeout(INVALID_RESOLUTION_DELAY)) return; }
Signature · 1 line
2.21.0
PATCH 4/4 media: aspeed: add a workaround to fix a silicon bug
In reply to Jae Hyun YooAST2500 silicon revision A1 and A2 have a silicon bug which causes extremly long capturing time on specific resolutions (1680 width). To fix the bug, this commit adjusts the capturing window register setting to 1728 if detected width is 1680. The compression window register setting will be kept as the original width so output result will be the same.
--- drivers/media/platform/aspeed-video.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/media/platform/aspeed-video.c +19 -7
@@ -826,8 +826,27 @@ static void aspeed_video_set_resolution(struct aspeed_video *video)struct v4l2_bt_timings *act = &video->active_timings;unsigned int size = act->width * act->height; +/* Set capture/compression frame sizes */ aspeed_video_calc_compressed_size (video, size); +if (video->active_timings.width ==1680 ) { +/* +* This is a workaround to fix a silicon bug on A1 and A2 +* revisions. Since it doesn't break capturing operation on A0 +* revision, use it for all revisions without checking the +* revision ID. +*/ +aspeed_video_write (video,VE_CAP_WINDOW , +1728 <<16 | act->height); + size += (1728 -1680 ) * video->active_timings.height; + }else { +aspeed_video_write (video,VE_CAP_WINDOW , + act->width <<16 | act->height); + } +aspeed_video_write (video,VE_COMP_WINDOW , + act->width <<16 | act->height); +aspeed_video_write (video,VE_SRC_SCANLINE_OFFSET , act->width *4 ); +/* Don't use direct mode below 1024 x 768 (irqs don't fire) */ if (size <DIRECT_FETCH_THRESHOLD ) { aspeed_video_write(video, VE_TGS_0,
@@ -844,13 +863,6 @@ static void aspeed_video_set_resolution(struct aspeed_video *video)aspeed_video_update (video,VE_CTRL ,0 ,VE_CTRL_DIRECT_FETCH ); } -/* Set capture/compression frame sizes */ -aspeed_video_write (video,VE_CAP_WINDOW , - act->width <<16 | act->height); -aspeed_video_write (video,VE_COMP_WINDOW , - act->width <<16 | act->height); -aspeed_video_write (video,VE_SRC_SCANLINE_OFFSET , act->width *4 ); - size *=4 ;if (size == video->srcs[0 ].size /2 ) {
Signature · 1 line
2.21.0