其他分享
首页 > 其他分享> > v4l2架构专题模块crop及selection分析 --- 帧数据怎么处理?

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寄存器中

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

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

这里找到了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;
}

 

标签:channels,selection,struct,stream,dev,---,crop,id
来源: https://blog.csdn.net/ldl617/article/details/116125175