diff options
author | Duncan Sands <baldrick@free.fr> | 2006-04-02 03:14:57 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-05-12 18:54:35 -0400 |
commit | 3203f94a25ea04b3052d22c7be9518538862d88f (patch) | |
tree | 5227daa69929027e83e49be2c169891fda76cfc5 /drivers/media | |
parent | faa88df860fdfad13afc99fc7201432f9263b3b5 (diff) |
V4L/DVB (3704): Fix some errors on bttv_risc_overlay
There are tree mistakes on bttv_risc_overlay.
1) When skip_odd is true, the number of lines for which
instructions are written is (height+1)/2, not height/2.
2) This occurs when clipping: the number of instruction bytes
written can be as much as 8 + 12*nclips, not 8 + 8*nclips, as
currently estimated.
3) Coverity check were wrong with nskips=0, since it means that
it can clipped at most one line.
Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/bt8xx/bttv-risc.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c index 16323a5d68ac..afcfe71e3792 100644 --- a/drivers/media/video/bt8xx/bttv-risc.c +++ b/drivers/media/video/bt8xx/bttv-risc.c | |||
@@ -233,7 +233,7 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | |||
233 | const struct bttv_format *fmt, struct bttv_overlay *ov, | 233 | const struct bttv_format *fmt, struct bttv_overlay *ov, |
234 | int skip_even, int skip_odd) | 234 | int skip_even, int skip_odd) |
235 | { | 235 | { |
236 | int instructions,rc,line,maxy,start,end,skip,nskips; | 236 | int dwords,rc,line,maxy,start,end,skip,nskips; |
237 | struct btcx_skiplist *skips; | 237 | struct btcx_skiplist *skips; |
238 | u32 *rp,ri,ra; | 238 | u32 *rp,ri,ra; |
239 | u32 addr; | 239 | u32 addr; |
@@ -242,12 +242,12 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | |||
242 | if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL))) | 242 | if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL))) |
243 | return -ENOMEM; | 243 | return -ENOMEM; |
244 | 244 | ||
245 | /* estimate risc mem: worst case is (clip+1) * lines instructions | 245 | /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions |
246 | + sync + jump (all 2 dwords) */ | 246 | + sync + jump (all 2 dwords) */ |
247 | instructions = (ov->nclips + 1) * | 247 | dwords = (3 * ov->nclips + 2) * |
248 | ((skip_even || skip_odd) ? ov->w.height>>1 : ov->w.height); | 248 | ((skip_even || skip_odd) ? (ov->w.height+1)>>1 : ov->w.height); |
249 | instructions += 2; | 249 | dwords += 4; |
250 | if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0) { | 250 | if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,dwords*4)) < 0) { |
251 | kfree(skips); | 251 | kfree(skips); |
252 | return rc; | 252 | return rc; |
253 | } | 253 | } |
@@ -276,8 +276,6 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | |||
276 | if (line > maxy) | 276 | if (line > maxy) |
277 | btcx_calc_skips(line, ov->w.width, &maxy, | 277 | btcx_calc_skips(line, ov->w.width, &maxy, |
278 | skips, &nskips, ov->clips, ov->nclips); | 278 | skips, &nskips, ov->clips, ov->nclips); |
279 | else | ||
280 | nskips = 0; | ||
281 | 279 | ||
282 | /* write out risc code */ | 280 | /* write out risc code */ |
283 | for (start = 0, skip = 0; start < ov->w.width; start = end) { | 281 | for (start = 0, skip = 0; start < ov->w.width; start = end) { |