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;
}

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dianlong_lee

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值