struct v4l2_subdev *sd结构体
struct v4l2_subdev {
#if defined(CONFIG_MEDIA_CONTROLLER)struct media_entity entity;
#endifstruct list_head list;struct module *owner;bool owner_v4l2_dev;u32 flags;struct v4l2_device *v4l2_dev;const struct v4l2_subdev_ops *ops;const struct v4l2_subdev_internal_ops *internal_ops;struct v4l2_ctrl_handler *ctrl_handler;char name[V4L2_SUBDEV_NAME_SIZE];u32 grp_id;void *dev_priv;void *host_priv;struct video_device *devnode;struct device *dev;struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;struct v4l2_async_notifier *subdev_notifier;struct v4l2_subdev_platform_data *pdata;
};
sd->ops
if(sd->ops == NULL){DEBUG_CORE("sd->ops NULL");break;}
然后看看 v4l2_subdev_ops 的定义
static const struct v4l2_subdev_ops ov5645_subdev_ops = {.core = &ov5645_core_ops,.video = &ov5645_video_ops,.pad = &ov5645_subdev_pad_ops,
};
if(sd->ops->core == NULL){DEBUG_CORE("sd->ops->core NULL");break;}
最后判断ioctl是否为空
if(sd->ops->core->ioctl == NULL){DEBUG_CORE("sd->ops->core NULL");break;}sd->ops->core->ioctl(sd, ctrl->id, &ctrl->val);
小结
最后把 v4l2_subdev_call(sd, core, ioctl, ctrl->id,ctrl->val);
转换为了 sd->ops->core->ioctl(sd, ctrl->id, &ctrl->val);
转换这个主要是为了空指针检查。解决问题了以后,还是用原来的宏就行了。