bttv-risc.c (cdd38c5f1ce4398ec58fec95904b75824daab7b5) | bttv-risc.c (3c161e82dfbd3ee67a1548691412d04d04ad6a37) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 4 bttv-risc.c -- interfaces to other kernel modules 5 6 bttv risc code handling 7 - memory management 8 - generation --- 217 unchanged lines hidden (view full) --- 226 } 227 228 /* save pointer to jmp instruction address */ 229 risc->jmp = rp; 230 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 231 return 0; 232} 233 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 4 bttv-risc.c -- interfaces to other kernel modules 5 6 bttv risc code handling 7 - memory management 8 - generation --- 217 unchanged lines hidden (view full) --- 226 } 227 228 /* save pointer to jmp instruction address */ 229 risc->jmp = rp; 230 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 231 return 0; 232} 233 |
234static int 235bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, 236 const struct bttv_format *fmt, struct bttv_overlay *ov, 237 int skip_even, int skip_odd) 238{ 239 int dwords, rc, line, maxy, start, end; 240 unsigned skip, nskips; 241 struct btcx_skiplist *skips; 242 __le32 *rp; 243 u32 ri,ra; 244 u32 addr; 245 246 /* skip list for window clipping */ 247 skips = kmalloc_array(ov->nclips, sizeof(*skips),GFP_KERNEL); 248 if (NULL == skips) 249 return -ENOMEM; 250 251 /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions 252 + sync + jump (all 2 dwords) */ 253 dwords = (3 * ov->nclips + 2) * 254 ((skip_even || skip_odd) ? (ov->w.height+1)>>1 : ov->w.height); 255 dwords += 4; 256 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,dwords*4)) < 0) { 257 kfree(skips); 258 return rc; 259 } 260 261 /* sync instruction */ 262 rp = risc->cpu; 263 *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1); 264 *(rp++) = cpu_to_le32(0); 265 266 addr = (unsigned long)btv->fbuf.base; 267 addr += btv->fbuf.fmt.bytesperline * ov->w.top; 268 addr += (fmt->depth >> 3) * ov->w.left; 269 270 /* scan lines */ 271 for (maxy = -1, line = 0; line < ov->w.height; 272 line++, addr += btv->fbuf.fmt.bytesperline) { 273 if ((btv->opt_vcr_hack) && 274 (line >= (ov->w.height - VCR_HACK_LINES))) 275 continue; 276 if ((line%2) == 0 && skip_even) 277 continue; 278 if ((line%2) == 1 && skip_odd) 279 continue; 280 281 /* calculate clipping */ 282 if (line > maxy) 283 btcx_calc_skips(line, ov->w.width, &maxy, 284 skips, &nskips, ov->clips, ov->nclips); 285 286 /* write out risc code */ 287 for (start = 0, skip = 0; start < ov->w.width; start = end) { 288 if (skip >= nskips) { 289 ri = BT848_RISC_WRITE; 290 end = ov->w.width; 291 } else if (start < skips[skip].start) { 292 ri = BT848_RISC_WRITE; 293 end = skips[skip].start; 294 } else { 295 ri = BT848_RISC_SKIP; 296 end = skips[skip].end; 297 skip++; 298 } 299 if (BT848_RISC_WRITE == ri) 300 ra = addr + (fmt->depth>>3)*start; 301 else 302 ra = 0; 303 304 if (0 == start) 305 ri |= BT848_RISC_SOL; 306 if (ov->w.width == end) 307 ri |= BT848_RISC_EOL; 308 ri |= (fmt->depth>>3) * (end-start); 309 310 *(rp++)=cpu_to_le32(ri); 311 if (0 != ra) 312 *(rp++)=cpu_to_le32(ra); 313 } 314 } 315 316 /* save pointer to jmp instruction address */ 317 risc->jmp = rp; 318 BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 319 kfree(skips); 320 return 0; 321} 322 | |
323/* ---------------------------------------------------------- */ 324 325static void 326bttv_calc_geo_old(struct bttv *btv, struct bttv_geometry *geo, 327 int width, int height, int interleaved, 328 const struct bttv_tvnorm *tvnorm) 329{ 330 u32 xsf, sr; --- 512 unchanged lines hidden (view full) --- 843 buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES); 844 } 845 846 /* copy format info */ 847 buf->btformat = buf->fmt->btformat; 848 buf->btswap = buf->fmt->btswap; 849 return 0; 850} | 234/* ---------------------------------------------------------- */ 235 236static void 237bttv_calc_geo_old(struct bttv *btv, struct bttv_geometry *geo, 238 int width, int height, int interleaved, 239 const struct bttv_tvnorm *tvnorm) 240{ 241 u32 xsf, sr; --- 512 unchanged lines hidden (view full) --- 754 buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES); 755 } 756 757 /* copy format info */ 758 buf->btformat = buf->fmt->btformat; 759 buf->btswap = buf->fmt->btswap; 760 return 0; 761} |
851 852/* ---------------------------------------------------------- */ 853 854/* calculate geometry, build risc code */ 855int 856bttv_overlay_risc(struct bttv *btv, 857 struct bttv_overlay *ov, 858 const struct bttv_format *fmt, 859 struct bttv_buffer *buf) 860{ 861 /* check interleave, bottom+top fields */ 862 dprintk("%d: overlay fields: %s format: 0x%08x size: %dx%d\n", 863 btv->c.nr, v4l2_field_names[buf->vb.field], 864 fmt->fourcc, ov->w.width, ov->w.height); 865 866 /* calculate geometry */ 867 bttv_calc_geo(btv,&buf->geo,ov->w.width,ov->w.height, 868 V4L2_FIELD_HAS_BOTH(ov->field), 869 &bttv_tvnorms[ov->tvnorm],&buf->crop); 870 871 /* build risc code */ 872 switch (ov->field) { 873 case V4L2_FIELD_TOP: 874 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 0); 875 break; 876 case V4L2_FIELD_BOTTOM: 877 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0); 878 break; 879 case V4L2_FIELD_INTERLACED: 880 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1); 881 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0); 882 break; 883 default: 884 BUG(); 885 } 886 887 /* copy format info */ 888 buf->btformat = fmt->btformat; 889 buf->btswap = fmt->btswap; 890 buf->vb.field = ov->field; 891 return 0; 892} | |