Q1: 我的sensor驱动里,v4l2的s_power()回调没有被调用,s_stream()回调有被正常调用?我阅读了v4l2-core的驱动代码,看起来s_power()回调是在pipeline_pm_power_one() of board-support\ti-linux-kernel-6.1.46+gitAUTOINC+247b2535b2-g247b2535b2\drivers\media\v4l2-core\v4l2-mc.c 发起的,我在其中添加printk打印后测试,但是没看到这些打印。
static int pipeline_pm_power_one(struct media_entity *entity, int change)
{
struct v4l2_subdev *subdev;
int ret;
subdev = is_media_entity_v4l2_subdev(entity)
? media_entity_to_v4l2_subdev(entity) : NULL;
if (entity->use_count == 0 && change > 0 && subdev != NULL) {
ret = v4l2_subdev_call(subdev, core, s_power, 1);
printk(KERN_ERR "--HAWK--<%s> Line: %d--s_power(1)-owner:%s, v4l2_subdev_name:%s, ret:%d---\n", __FUNCTION__, __LINE__, subdev->owner, subdev->name, ret);
if (ret < 0 && ret != -ENOIOCTLCMD)
return ret;
}
entity->use_count += change;
WARN_ON(entity->use_count < 0);
if (entity->use_count == 0 && change < 0 && subdev != NULL)
{
v4l2_subdev_call(subdev, core, s_power, 0);
printk(KERN_ERR "--HAWK--<%s> Line: %d--s_power(0)-owner:%s, v4l2_subdev_name:%s--\n", __FUNCTION__, __LINE__, subdev->owner, subdev->name);
}
return 0;
}
而s_stream()回调是在v4l2_subdev_enable_streams_fallback() of board-support\ti-linux-kernel-6.1.46+gitAUTOINC+247b2535b2-g247b2535b2\drivers\media\v4l2-core\v4l2-subdev.c 发起的,我在其中添加printk打印后测试,能看到这些打印。
static int v4l2_subdev_enable_streams_fallback(struct v4l2_subdev *sd, u32 pad,
u64 streams_mask)
{
struct device *dev = sd->entity.graph_obj.mdev->dev;
unsigned int i;
int ret;
/*
* The subdev doesn't implement pad-based stream enable, fall back
* on the .s_stream() operation. This can only be done for subdevs that
* have a single source pad, as sd->enabled_streams is global to the
* subdev.
*/
if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
return -EOPNOTSUPP;
for (i = 0; i < sd->entity.num_pads; ++i) {
if (i != pad && sd->entity.pads[i].flags & MEDIA_PAD_FL_SOURCE)
return -EOPNOTSUPP;
}
if (sd->enabled_streams & streams_mask) {
dev_dbg(dev, "set of streams %#llx already enabled on %s:%u\n",
streams_mask, sd->entity.name, pad);
return -EALREADY;
}
/* Start streaming when the first streams are enabled. */
if (!sd->enabled_streams) {
ret = v4l2_subdev_call(sd, video, s_stream, 1);
printk(KERN_ERR "--HAWK--<%s> Line: %d--s_stream(1)-owner:%s, v4l2_subdev_name:%s, ret:%d---\n", __FUNCTION__, __LINE__, sd->owner, sd->name, ret);
if (ret)
return ret;
}
sd->enabled_streams |= streams_mask;
return 0;
}
2. 尽管我的kernel层dToF sensor驱动(ads6311)里s_stream()回调是返回0 (成功)的,但是用户层调用xioctl(fd, VIDIOC_STREAMON, &buf_type)还是返回了失败,错误信息如下,请问是什么原因呢?
Fail to stream_on for fd:7, errno: No such file or directory (2)...
我的dToF sensor驱动和应用层测试程序在另外一个平台(rk3568, Linux kernel 5.10)上运行是基本可以的,我现在正在移植到TI Am62ax平台上,我最近才接触TI的这个平台,确实不是很熟悉,因此希望得到你们的帮助。附件是完整的log文件(后半部分是dmesg命令的结果)。