Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: ti: cal: use frame desc to get vc and dt

Use get_frame_desc() to get the frame desc from the connected source,
and use the provided virtual channel and datatype instead of hardcoded
ones.

get_frame_desc() can contain multiple streams, but as we don't support
multiple streams yet, we will just always use the first stream.

If the source doesn't support get_frame_desc(), fall back to the
previous method of always capturing virtual channel 0 and any datatype.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Tomi Valkeinen and committed by
Mauro Carvalho Chehab
7a129031 897c45df

+76 -2
+27
drivers/media/platform/ti/cal/cal-camerarx.c
··· 583 583 return ret; 584 584 } 585 585 586 + int cal_camerarx_get_remote_frame_desc(struct cal_camerarx *phy, 587 + struct v4l2_mbus_frame_desc *desc) 588 + { 589 + struct media_pad *pad; 590 + int ret; 591 + 592 + if (!phy->source) 593 + return -EPIPE; 594 + 595 + pad = media_entity_remote_pad(&phy->pads[CAL_CAMERARX_PAD_SINK]); 596 + if (!pad) 597 + return -EPIPE; 598 + 599 + ret = v4l2_subdev_call(phy->source, pad, get_frame_desc, pad->index, 600 + desc); 601 + if (ret) 602 + return ret; 603 + 604 + if (desc->type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { 605 + dev_err(phy->cal->dev, 606 + "Frame descriptor does not describe CSI-2 link"); 607 + return -EINVAL; 608 + } 609 + 610 + return 0; 611 + } 612 + 586 613 /* ------------------------------------------------------------------ 587 614 * V4L2 Subdev Operations 588 615 * ------------------------------------------------------------------
+47 -2
drivers/media/platform/ti/cal/cal.c
··· 469 469 return stopped; 470 470 } 471 471 472 + static int 473 + cal_get_remote_frame_desc_entry(struct cal_camerarx *phy, 474 + struct v4l2_mbus_frame_desc_entry *entry) 475 + { 476 + struct v4l2_mbus_frame_desc fd; 477 + int ret; 478 + 479 + ret = cal_camerarx_get_remote_frame_desc(phy, &fd); 480 + if (ret) { 481 + if (ret != -ENOIOCTLCMD) 482 + dev_err(phy->cal->dev, 483 + "Failed to get remote frame desc: %d\n", ret); 484 + return ret; 485 + } 486 + 487 + if (fd.num_entries == 0) { 488 + dev_err(phy->cal->dev, 489 + "No streams found in the remote frame descriptor\n"); 490 + 491 + return -ENODEV; 492 + } 493 + 494 + if (fd.num_entries > 1) 495 + dev_dbg(phy->cal->dev, 496 + "Multiple streams not supported in remote frame descriptor, using the first one\n"); 497 + 498 + *entry = fd.entry[0]; 499 + 500 + return 0; 501 + } 502 + 472 503 int cal_ctx_prepare(struct cal_ctx *ctx) 473 504 { 505 + struct v4l2_mbus_frame_desc_entry entry; 474 506 int ret; 507 + 508 + ret = cal_get_remote_frame_desc_entry(ctx->phy, &entry); 509 + 510 + if (ret == -ENOIOCTLCMD) { 511 + ctx->vc = 0; 512 + ctx->datatype = CAL_CSI2_CTX_DT_ANY; 513 + } else if (!ret) { 514 + ctx_dbg(2, ctx, "Framedesc: len %u, vc %u, dt %#x\n", 515 + entry.length, entry.bus.csi2.vc, entry.bus.csi2.dt); 516 + 517 + ctx->vc = entry.bus.csi2.vc; 518 + ctx->datatype = entry.bus.csi2.dt; 519 + } else { 520 + return ret; 521 + } 475 522 476 523 ctx->use_pix_proc = !ctx->fmtinfo->meta; 477 524 ··· 981 934 ctx->dma_ctx = inst; 982 935 ctx->csi2_ctx = inst; 983 936 ctx->cport = inst; 984 - ctx->vc = 0; 985 - ctx->datatype = CAL_CSI2_CTX_DT_ANY; 986 937 987 938 ret = cal_ctx_v4l2_init(ctx); 988 939 if (ret)
+2
drivers/media/platform/ti/cal/cal.h
··· 323 323 324 324 void cal_quickdump_regs(struct cal_dev *cal); 325 325 326 + int cal_camerarx_get_remote_frame_desc(struct cal_camerarx *phy, 327 + struct v4l2_mbus_frame_desc *desc); 326 328 void cal_camerarx_disable(struct cal_camerarx *phy); 327 329 void cal_camerarx_i913_errata(struct cal_camerarx *phy); 328 330 struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,