v4l2架构专题模块crop及selection分析 --- 帧数据怎么处理?

Linux v4l2架构学习总链接

写到最后了,突然想起来帧数据是怎么处理的?从buffer中裁剪吗?

static int rkcif_stream_start(struct rkcif_stream *stream)
{
    ...
    if (stream->crop_enable) {
		dev->channels[stream->id].crop_en = 1;
		dev->channels[stream->id].crop_st_x = stream->crop[CROP_SRC_ACT].left;
		dev->channels[stream->id].crop_st_y = stream->crop[CROP_SRC_ACT].top;
		dev->channels[stream->id].width = stream->crop[CROP_SRC_ACT].width;
		dev->channels[stream->id].height = stream->crop[CROP_SRC_ACT].height;
	} else {
		dev->channels[stream->id].crop_st_y = 0;
		dev->channels[stream->id].crop_st_x = 0;
		dev->channels[stream->id].width = stream->pixm.width;
		dev->channels[stream->id].height = stream->pixm.height;
		dev->channels[stream->id].crop_en = 0;
	}

	rkcif_write_register(dev, CIF_REG_DVP_CROP,
			     dev->channels[stream->id].crop_st_y << CIF_CROP_Y_SHIFT |
			     dev->channels[stream->id].crop_st_x);
    ...
}

可以看到crop_enable满足的时候,代码中将值给了crop_st_x,crop_st_y,最后写到了CIF_REG_DVP_CROP寄存器中

所以这里可以认为是硬件操作

v4l2架构专题模块crop及selection分析 --- 帧数据怎么处理?

如果硬件不支持的话,会出现什么情况?

这里找到了imx6的代码,明确的写了不支持crop 功能...

static int mx6s_vidioc_cropcap(struct file *file, void *fh, 
                  struct v4l2_cropcap *a)
{
    struct mx6s_csi_dev *csi_dev = video_drvdata(file);

    if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
        return -EINVAL;
    dev_dbg(csi_dev->dev, "VIDIOC_CROPCAP not implemented\n");

    return 0;
}

static int mx6s_vidioc_g_crop(struct file *file, void *priv,
                 struct v4l2_crop *a)
{
    struct mx6s_csi_dev *csi_dev = video_drvdata(file);

    if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
        return -EINVAL;
    dev_dbg(csi_dev->dev, "VIDIOC_G_CROP not implemented\n");

    return 0;
}

static int mx6s_vidioc_s_crop(struct file *file, void *priv,
                 const struct v4l2_crop *a)
{
    struct mx6s_csi_dev *csi_dev = video_drvdata(file);

    if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
        return -EINVAL;

    dev_dbg(csi_dev->dev, "VIDIOC_S_CROP not implemented\n");

    return 0;
}

 

上一篇:目标检测后得到box四位坐标后的裁剪图片操作


下一篇:v4l2架构专题模块crop及selection分析 --- get_selection中V4L2_SEL_TGT_CROP_BOUNDS的目的