]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: rcar-vin: Remove emulated SEQ_{TB,BT}
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Mon, 10 Feb 2025 17:56:11 +0000 (18:56 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 25 Apr 2025 08:15:26 +0000 (10:15 +0200)
When the driver was converted from soc_camera software support for
V4L2_FIELD_SEQ_TB and V4L2_FIELD_SEQ_BT were added. This was done by
capturing twice to the same VB2 buffer, but at different offsets.

This turned out to be a bad idea and it never really worked properly in
all situations. As the hardware can't support this mode natively remove
trying to emulate it in software. It's still possible to capture TOP or
BOTTOM fields separately or both ALTERNATING. If user-space wants the
same  fields in the same buffer the same hack to capture twice to the
same buffer can be done.

Removing this error prone emulated support pave ways in future work to
simplify the internal buffer handling and making it less fragile, while
enabling adding support for other features the hardware actually
supports.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/renesas/rcar-vin/rcar-dma.c
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
drivers/media/platform/renesas/rcar-vin/rcar-vin.h

index edb06730bc7c065ca7361b99cb12bd9c115cb524..fc64f013ec050c9a8c3a97d69d2bcffcdf401719 100644 (file)
@@ -642,8 +642,6 @@ void rvin_scaler_gen3(struct rvin_dev *vin)
        case V4L2_FIELD_INTERLACED_TB:
        case V4L2_FIELD_INTERLACED_BT:
        case V4L2_FIELD_INTERLACED:
-       case V4L2_FIELD_SEQ_TB:
-       case V4L2_FIELD_SEQ_BT:
                clip_size |= vin->compose.height / 2;
                break;
        default:
@@ -711,8 +709,6 @@ static int rvin_setup(struct rvin_dev *vin)
        case V4L2_FIELD_INTERLACED_BT:
                vnmc = VNMC_IM_FULL | VNMC_FOC;
                break;
-       case V4L2_FIELD_SEQ_TB:
-       case V4L2_FIELD_SEQ_BT:
        case V4L2_FIELD_NONE:
        case V4L2_FIELD_ALTERNATE:
                vnmc = VNMC_IM_ODD_EVEN;
@@ -1005,33 +1001,14 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot)
        struct rvin_buffer *buf;
        struct vb2_v4l2_buffer *vbuf;
        dma_addr_t phys_addr;
-       int prev;
 
        /* A already populated slot shall never be overwritten. */
        if (WARN_ON(vin->buf_hw[slot].buffer))
                return;
 
-       prev = (slot == 0 ? HW_BUFFER_NUM : slot) - 1;
-
-       if (vin->buf_hw[prev].type == HALF_TOP) {
-               vbuf = vin->buf_hw[prev].buffer;
-               vin->buf_hw[slot].buffer = vbuf;
-               vin->buf_hw[slot].type = HALF_BOTTOM;
-               switch (vin->format.pixelformat) {
-               case V4L2_PIX_FMT_NV12:
-               case V4L2_PIX_FMT_NV16:
-                       phys_addr = vin->buf_hw[prev].phys +
-                               vin->format.sizeimage / 4;
-                       break;
-               default:
-                       phys_addr = vin->buf_hw[prev].phys +
-                               vin->format.sizeimage / 2;
-                       break;
-               }
-       } else if ((vin->state != STOPPED && vin->state != RUNNING) ||
-                  list_empty(&vin->buf_list)) {
+       if ((vin->state != STOPPED && vin->state != RUNNING) ||
+           list_empty(&vin->buf_list)) {
                vin->buf_hw[slot].buffer = NULL;
-               vin->buf_hw[slot].type = FULL;
                phys_addr = vin->scratch_phys;
        } else {
                /* Keep track of buffer we give to HW */
@@ -1040,16 +1017,12 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot)
                list_del_init(to_buf_list(vbuf));
                vin->buf_hw[slot].buffer = vbuf;
 
-               vin->buf_hw[slot].type =
-                       V4L2_FIELD_IS_SEQUENTIAL(vin->format.field) ?
-                       HALF_TOP : FULL;
-
                /* Setup DMA */
                phys_addr = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, 0);
        }
 
-       vin_dbg(vin, "Filling HW slot: %d type: %d buffer: %p\n",
-               slot, vin->buf_hw[slot].type, vin->buf_hw[slot].buffer);
+       vin_dbg(vin, "Filling HW slot: %d buffer: %p\n",
+               slot, vin->buf_hw[slot].buffer);
 
        vin->buf_hw[slot].phys = phys_addr;
        rvin_set_slot_addr(vin, slot, phys_addr);
@@ -1057,15 +1030,12 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot)
 
 static int rvin_capture_start(struct rvin_dev *vin)
 {
-       int slot, ret;
+       int ret;
 
-       for (slot = 0; slot < HW_BUFFER_NUM; slot++) {
+       for (unsigned int slot = 0; slot < HW_BUFFER_NUM; slot++) {
                vin->buf_hw[slot].buffer = NULL;
-               vin->buf_hw[slot].type = FULL;
-       }
-
-       for (slot = 0; slot < HW_BUFFER_NUM; slot++)
                rvin_fill_hw_slot(vin, slot);
+       }
 
        ret = rvin_setup(vin);
        if (ret)
@@ -1146,16 +1116,6 @@ static irqreturn_t rvin_irq(int irq, void *data)
 
        /* Capture frame */
        if (vin->buf_hw[slot].buffer) {
-               /*
-                * Nothing to do but refill the hardware slot if
-                * capture only filled first half of vb2 buffer.
-                */
-               if (vin->buf_hw[slot].type == HALF_TOP) {
-                       vin->buf_hw[slot].buffer = NULL;
-                       rvin_fill_hw_slot(vin, slot);
-                       goto done;
-               }
-
                vin->buf_hw[slot].buffer->field =
                        rvin_get_active_field(vin, vnms);
                vin->buf_hw[slot].buffer->sequence = vin->sequence;
@@ -1306,8 +1266,6 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
        case V4L2_FIELD_INTERLACED_TB:
        case V4L2_FIELD_INTERLACED_BT:
        case V4L2_FIELD_INTERLACED:
-       case V4L2_FIELD_SEQ_TB:
-       case V4L2_FIELD_SEQ_BT:
                /* Supported natively */
                break;
        case V4L2_FIELD_ALTERNATE:
@@ -1320,8 +1278,6 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
                case V4L2_FIELD_INTERLACED_TB:
                case V4L2_FIELD_INTERLACED_BT:
                case V4L2_FIELD_INTERLACED:
-               case V4L2_FIELD_SEQ_TB:
-               case V4L2_FIELD_SEQ_BT:
                        /* Use VIN hardware to combine the two fields */
                        fmt.format.height *= 2;
                        break;
index 756fdfdbce616ce54cc3ba7f4758ec51a738e3da..a5763f1c5784a0b95e527914920186cc7b15a962 100644 (file)
@@ -161,9 +161,6 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin,
                break;
        }
 
-       if (V4L2_FIELD_IS_SEQUENTIAL(pix->field))
-               align = 0x80;
-
        return ALIGN(pix->width, align) * fmt->bpp;
 }
 
@@ -194,8 +191,6 @@ static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix)
        case V4L2_FIELD_INTERLACED_BT:
        case V4L2_FIELD_INTERLACED:
        case V4L2_FIELD_ALTERNATE:
-       case V4L2_FIELD_SEQ_TB:
-       case V4L2_FIELD_SEQ_BT:
                break;
        default:
                pix->field = RVIN_DEFAULT_FIELD;
@@ -504,8 +499,6 @@ static int rvin_remote_rectangle(struct rvin_dev *vin, struct v4l2_rect *rect)
                case V4L2_FIELD_INTERLACED_TB:
                case V4L2_FIELD_INTERLACED_BT:
                case V4L2_FIELD_INTERLACED:
-               case V4L2_FIELD_SEQ_TB:
-               case V4L2_FIELD_SEQ_BT:
                        rect->height *= 2;
                        break;
                }
index f87d4bc9e53ed3dab20818bfeaf2ae283fb1558b..d5763462809a9e9585bf2810100a3d7517c45a03 100644 (file)
@@ -77,23 +77,6 @@ enum rvin_dma_state {
        SUSPENDED,
 };
 
-/**
- * enum rvin_buffer_type
- *
- * Describes how a buffer is given to the hardware. To be able
- * to capture SEQ_TB/BT it's needed to capture to the same vb2
- * buffer twice so the type of buffer needs to be kept.
- *
- * @FULL: One capture fills the whole vb2 buffer
- * @HALF_TOP: One capture fills the top half of the vb2 buffer
- * @HALF_BOTTOM: One capture fills the bottom half of the vb2 buffer
- */
-enum rvin_buffer_type {
-       FULL,
-       HALF_TOP,
-       HALF_BOTTOM,
-};
-
 /**
  * struct rvin_video_format - Data format stored in memory
  * @fourcc:    Pixelformat
@@ -237,7 +220,6 @@ struct rvin_dev {
        spinlock_t qlock;
        struct {
                struct vb2_v4l2_buffer *buffer;
-               enum rvin_buffer_type type;
                dma_addr_t phys;
        } buf_hw[HW_BUFFER_NUM];
        struct list_head buf_list;