Lines Matching full:sd
51 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd) in subdev_fh_init() argument
56 state = __v4l2_subdev_state_alloc(sd, "fh->state->lock", &key); in subdev_fh_init()
74 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_open() local
82 ret = subdev_fh_init(subdev_fh, sd); in subdev_open()
92 if (sd->v4l2_dev->mdev && sd->entity.graph_obj.mdev->dev) { in subdev_open()
95 owner = sd->entity.graph_obj.mdev->dev->driver->owner; in subdev_open()
103 if (sd->internal_ops && sd->internal_ops->open) { in subdev_open()
104 ret = sd->internal_ops->open(sd, subdev_fh); in subdev_open()
124 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_close() local
128 if (sd->internal_ops && sd->internal_ops->close) in subdev_close()
129 sd->internal_ops->close(sd, subdev_fh); in subdev_close()
151 static void v4l2_subdev_enable_privacy_led(struct v4l2_subdev *sd) in v4l2_subdev_enable_privacy_led() argument
154 if (!IS_ERR_OR_NULL(sd->privacy_led)) in v4l2_subdev_enable_privacy_led()
155 led_set_brightness(sd->privacy_led, in v4l2_subdev_enable_privacy_led()
156 sd->privacy_led->max_brightness); in v4l2_subdev_enable_privacy_led()
160 static void v4l2_subdev_disable_privacy_led(struct v4l2_subdev *sd) in v4l2_subdev_disable_privacy_led() argument
163 if (!IS_ERR_OR_NULL(sd->privacy_led)) in v4l2_subdev_disable_privacy_led()
164 led_set_brightness(sd->privacy_led, 0); in v4l2_subdev_disable_privacy_led()
177 static inline int check_pad(struct v4l2_subdev *sd, u32 pad) in check_pad() argument
180 if (sd->entity.num_pads) { in check_pad()
181 if (pad >= sd->entity.num_pads) in check_pad()
192 static int check_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, in check_state() argument
195 if (sd->flags & V4L2_SUBDEV_FL_STREAMS) { in check_state()
214 static inline int check_format(struct v4l2_subdev *sd, in check_format() argument
221 return check_which(format->which) ? : check_pad(sd, format->pad) ? : in check_format()
222 check_state(sd, state, format->which, format->pad, format->stream); in check_format()
225 static int call_get_fmt(struct v4l2_subdev *sd, in call_get_fmt() argument
229 return check_format(sd, state, format) ? : in call_get_fmt()
230 sd->ops->pad->get_fmt(sd, state, format); in call_get_fmt()
233 static int call_set_fmt(struct v4l2_subdev *sd, in call_set_fmt() argument
237 return check_format(sd, state, format) ? : in call_set_fmt()
238 sd->ops->pad->set_fmt(sd, state, format); in call_set_fmt()
241 static int call_enum_mbus_code(struct v4l2_subdev *sd, in call_enum_mbus_code() argument
248 return check_which(code->which) ? : check_pad(sd, code->pad) ? : in call_enum_mbus_code()
249 check_state(sd, state, code->which, code->pad, code->stream) ? : in call_enum_mbus_code()
250 sd->ops->pad->enum_mbus_code(sd, state, code); in call_enum_mbus_code()
253 static int call_enum_frame_size(struct v4l2_subdev *sd, in call_enum_frame_size() argument
260 return check_which(fse->which) ? : check_pad(sd, fse->pad) ? : in call_enum_frame_size()
261 check_state(sd, state, fse->which, fse->pad, fse->stream) ? : in call_enum_frame_size()
262 sd->ops->pad->enum_frame_size(sd, state, fse); in call_enum_frame_size()
265 static int call_enum_frame_interval(struct v4l2_subdev *sd, in call_enum_frame_interval() argument
272 return check_which(fie->which) ? : check_pad(sd, fie->pad) ? : in call_enum_frame_interval()
273 check_state(sd, state, fie->which, fie->pad, fie->stream) ? : in call_enum_frame_interval()
274 sd->ops->pad->enum_frame_interval(sd, state, fie); in call_enum_frame_interval()
277 static inline int check_selection(struct v4l2_subdev *sd, in check_selection() argument
284 return check_which(sel->which) ? : check_pad(sd, sel->pad) ? : in check_selection()
285 check_state(sd, state, sel->which, sel->pad, sel->stream); in check_selection()
288 static int call_get_selection(struct v4l2_subdev *sd, in call_get_selection() argument
292 return check_selection(sd, state, sel) ? : in call_get_selection()
293 sd->ops->pad->get_selection(sd, state, sel); in call_get_selection()
296 static int call_set_selection(struct v4l2_subdev *sd, in call_set_selection() argument
300 return check_selection(sd, state, sel) ? : in call_set_selection()
301 sd->ops->pad->set_selection(sd, state, sel); in call_set_selection()
304 static inline int check_frame_interval(struct v4l2_subdev *sd, in check_frame_interval() argument
311 return check_which(fi->which) ? : check_pad(sd, fi->pad) ? : in check_frame_interval()
312 check_state(sd, state, fi->which, fi->pad, fi->stream); in check_frame_interval()
315 static int call_get_frame_interval(struct v4l2_subdev *sd, in call_get_frame_interval() argument
319 return check_frame_interval(sd, state, fi) ? : in call_get_frame_interval()
320 sd->ops->pad->get_frame_interval(sd, state, fi); in call_get_frame_interval()
323 static int call_set_frame_interval(struct v4l2_subdev *sd, in call_set_frame_interval() argument
327 return check_frame_interval(sd, state, fi) ? : in call_set_frame_interval()
328 sd->ops->pad->set_frame_interval(sd, state, fi); in call_set_frame_interval()
331 static int call_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, in call_get_frame_desc() argument
338 if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)) in call_get_frame_desc()
344 ret = sd->ops->pad->get_frame_desc(sd, pad, fd); in call_get_frame_desc()
348 dev_dbg(sd->dev, "Frame descriptor on pad %u, type %s\n", pad, in call_get_frame_desc()
363 dev_dbg(sd->dev, in call_get_frame_desc()
372 static inline int check_edid(struct v4l2_subdev *sd, in check_edid() argument
381 return check_pad(sd, edid->pad); in check_edid()
384 static int call_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) in call_get_edid() argument
386 return check_edid(sd, edid) ? : sd->ops->pad->get_edid(sd, edid); in call_get_edid()
389 static int call_set_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) in call_set_edid() argument
391 return check_edid(sd, edid) ? : sd->ops->pad->set_edid(sd, edid); in call_set_edid()
394 static int call_s_dv_timings(struct v4l2_subdev *sd, unsigned int pad, in call_s_dv_timings() argument
400 return check_pad(sd, pad) ? : in call_s_dv_timings()
401 sd->ops->pad->s_dv_timings(sd, pad, timings); in call_s_dv_timings()
404 static int call_g_dv_timings(struct v4l2_subdev *sd, unsigned int pad, in call_g_dv_timings() argument
410 return check_pad(sd, pad) ? : in call_g_dv_timings()
411 sd->ops->pad->g_dv_timings(sd, pad, timings); in call_g_dv_timings()
414 static int call_query_dv_timings(struct v4l2_subdev *sd, unsigned int pad, in call_query_dv_timings() argument
420 return check_pad(sd, pad) ? : in call_query_dv_timings()
421 sd->ops->pad->query_dv_timings(sd, pad, timings); in call_query_dv_timings()
424 static int call_dv_timings_cap(struct v4l2_subdev *sd, in call_dv_timings_cap() argument
430 return check_pad(sd, cap->pad) ? : in call_dv_timings_cap()
431 sd->ops->pad->dv_timings_cap(sd, cap); in call_dv_timings_cap()
434 static int call_enum_dv_timings(struct v4l2_subdev *sd, in call_enum_dv_timings() argument
440 return check_pad(sd, dvt->pad) ? : in call_enum_dv_timings()
441 sd->ops->pad->enum_dv_timings(sd, dvt); in call_enum_dv_timings()
444 static int call_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad, in call_get_mbus_config() argument
449 return check_pad(sd, pad) ? : in call_get_mbus_config()
450 sd->ops->pad->get_mbus_config(sd, pad, config); in call_get_mbus_config()
453 static int call_s_stream(struct v4l2_subdev *sd, int enable) in call_s_stream() argument
462 if (WARN_ON(sd->s_stream_enabled == !!enable)) in call_s_stream()
465 ret = sd->ops->video->s_stream(sd, enable); in call_s_stream()
468 dev_warn(sd->dev, "disabling streaming failed (%d)\n", ret); in call_s_stream()
473 sd->s_stream_enabled = enable; in call_s_stream()
476 v4l2_subdev_enable_privacy_led(sd); in call_s_stream()
478 v4l2_subdev_disable_privacy_led(sd); in call_s_stream()
491 static int call_##f##_state(struct v4l2_subdev *sd, \
498 state = v4l2_subdev_lock_and_get_active_state(sd); \
499 ret = call_##f(sd, state, arg); \
508 static int call_##f##_state(struct v4l2_subdev *sd, \
512 return call_##f(sd, state, arg); \
559 subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh, in subdev_ioctl_get_state() argument
607 v4l2_subdev_get_unlocked_active_state(sd); in subdev_ioctl_get_state()
614 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_do_ioctl() local
618 bool streams_subdev = sd->flags & V4L2_SUBDEV_FL_STREAMS; in subdev_do_ioctl()
680 vdev, sd->v4l2_dev->mdev, arg); in subdev_do_ioctl()
686 vdev, sd->v4l2_dev->mdev, arg); in subdev_do_ioctl()
692 vdev, sd->v4l2_dev->mdev, arg); in subdev_do_ioctl()
695 if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) in subdev_do_ioctl()
701 if (v4l2_subdev_has_op(sd, core, subscribe_event)) in subdev_do_ioctl()
702 return v4l2_subdev_call(sd, core, subscribe_event, in subdev_do_ioctl()
705 if ((sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) && in subdev_do_ioctl()
707 return v4l2_ctrl_subdev_subscribe_event(sd, vfh, arg); in subdev_do_ioctl()
712 if (v4l2_subdev_has_op(sd, core, unsubscribe_event)) in subdev_do_ioctl()
713 return v4l2_subdev_call(sd, core, unsubscribe_event, in subdev_do_ioctl()
716 if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) in subdev_do_ioctl()
717 return v4l2_event_subdev_unsubscribe(sd, vfh, arg); in subdev_do_ioctl()
728 return v4l2_subdev_call(sd, core, g_register, p); in subdev_do_ioctl()
736 return v4l2_subdev_call(sd, core, s_register, p); in subdev_do_ioctl()
744 if (sd->ops->core && sd->ops->core->s_register) in subdev_do_ioctl()
746 if (sd->ops->core && sd->ops->core->g_register) in subdev_do_ioctl()
748 strscpy(p->name, sd->name, sizeof(p->name)); in subdev_do_ioctl()
757 sd->name); in subdev_do_ioctl()
758 ret = v4l2_subdev_call(sd, core, log_status); in subdev_do_ioctl()
760 sd->name); in subdev_do_ioctl()
772 return v4l2_subdev_call(sd, pad, get_fmt, state, format); in subdev_do_ioctl()
786 return v4l2_subdev_call(sd, pad, set_fmt, state, format); in subdev_do_ioctl()
804 sd, pad, get_selection, state, &sel); in subdev_do_ioctl()
830 sd, pad, set_selection, state, &sel); in subdev_do_ioctl()
844 return v4l2_subdev_call(sd, pad, enum_mbus_code, state, in subdev_do_ioctl()
855 return v4l2_subdev_call(sd, pad, enum_frame_size, state, in subdev_do_ioctl()
866 return v4l2_subdev_call(sd, pad, get_frame_interval, state, fi); in subdev_do_ioctl()
879 return v4l2_subdev_call(sd, pad, set_frame_interval, state, fi); in subdev_do_ioctl()
889 return v4l2_subdev_call(sd, pad, enum_frame_interval, state, in subdev_do_ioctl()
901 sd, pad, get_selection, state, sel); in subdev_do_ioctl()
915 sd, pad, set_selection, state, sel); in subdev_do_ioctl()
921 return v4l2_subdev_call(sd, pad, get_edid, edid); in subdev_do_ioctl()
927 return v4l2_subdev_call(sd, pad, set_edid, edid); in subdev_do_ioctl()
933 return v4l2_subdev_call(sd, pad, dv_timings_cap, cap); in subdev_do_ioctl()
939 return v4l2_subdev_call(sd, pad, enum_dv_timings, dvt); in subdev_do_ioctl()
943 return v4l2_subdev_call(sd, pad, query_dv_timings, 0, arg); in subdev_do_ioctl()
946 return v4l2_subdev_call(sd, pad, g_dv_timings, 0, arg); in subdev_do_ioctl()
952 return v4l2_subdev_call(sd, pad, s_dv_timings, 0, arg); in subdev_do_ioctl()
955 return v4l2_subdev_call(sd, video, g_std, arg); in subdev_do_ioctl()
963 return v4l2_subdev_call(sd, video, s_std, *std); in subdev_do_ioctl()
970 if (v4l2_subdev_call(sd, video, g_tvnorms, &id)) in subdev_do_ioctl()
977 return v4l2_subdev_call(sd, video, querystd, arg); in subdev_do_ioctl()
986 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) in subdev_do_ioctl()
1012 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) in subdev_do_ioctl()
1025 const struct media_pad *pads = sd->entity.pads; in subdev_do_ioctl()
1031 if (route->sink_pad >= sd->entity.num_pads) in subdev_do_ioctl()
1038 if (route->source_pad >= sd->entity.num_pads) in subdev_do_ioctl()
1050 if (!v4l2_subdev_has_op(sd, pad, set_routing)) { in subdev_do_ioctl()
1064 rval = v4l2_subdev_call(sd, pad, set_routing, state, in subdev_do_ioctl()
1107 return v4l2_subdev_call(sd, core, ioctl, cmd, arg); in subdev_do_ioctl()
1123 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_do_ioctl_lock() local
1128 state = subdev_ioctl_get_state(sd, subdev_fh, cmd, arg); in subdev_do_ioctl_lock()
1155 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_compat_ioctl32() local
1157 return v4l2_subdev_call(sd, core, compat_ioctl32, cmd, arg); in subdev_compat_ioctl32()
1180 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); in subdev_poll() local
1183 if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) in subdev_poll()
1211 struct v4l2_subdev *sd; in v4l2_subdev_get_fwnode_pad_1_to_1() local
1216 sd = media_entity_to_v4l2_subdev(entity); in v4l2_subdev_get_fwnode_pad_1_to_1()
1221 if (device_match_fwnode(sd->dev, fwnode)) in v4l2_subdev_get_fwnode_pad_1_to_1()
1228 int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, in v4l2_subdev_link_validate_default() argument
1237 dev_dbg(sd->entity.graph_obj.mdev->dev, in v4l2_subdev_link_validate_default()
1245 dev_dbg(sd->entity.graph_obj.mdev->dev, in v4l2_subdev_link_validate_default()
1253 dev_dbg(sd->entity.graph_obj.mdev->dev, in v4l2_subdev_link_validate_default()
1266 dev_dbg(sd->entity.graph_obj.mdev->dev, in v4l2_subdev_link_validate_default()
1276 dev_dbg(sd->entity.graph_obj.mdev->dev, in v4l2_subdev_link_validate_default()
1291 struct v4l2_subdev *sd; in v4l2_subdev_link_validate_get_format() local
1294 sd = media_entity_to_v4l2_subdev(pad->entity); in v4l2_subdev_link_validate_get_format()
1301 state = v4l2_subdev_get_locked_active_state(sd); in v4l2_subdev_link_validate_get_format()
1303 state = v4l2_subdev_lock_and_get_active_state(sd); in v4l2_subdev_link_validate_get_format()
1305 ret = v4l2_subdev_call(sd, pad, get_fmt, state, fmt); in v4l2_subdev_link_validate_get_format()
1538 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); in v4l2_subdev_has_pad_interdep() local
1543 state = v4l2_subdev_lock_and_get_active_state(sd); in v4l2_subdev_has_pad_interdep()
1567 __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, in __v4l2_subdev_state_alloc() argument
1578 if (sd->state_lock) in __v4l2_subdev_state_alloc()
1579 state->lock = sd->state_lock; in __v4l2_subdev_state_alloc()
1583 state->sd = sd; in __v4l2_subdev_state_alloc()
1586 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS) && sd->entity.num_pads) { in __v4l2_subdev_state_alloc()
1587 state->pads = kvcalloc(sd->entity.num_pads, in __v4l2_subdev_state_alloc()
1595 if (sd->internal_ops && sd->internal_ops->init_state) { in __v4l2_subdev_state_alloc()
1601 ret = sd->internal_ops->init_state(sd, state); in __v4l2_subdev_state_alloc()
1634 int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, in __v4l2_subdev_init_finalize() argument
1638 struct device *dev = sd->dev; in __v4l2_subdev_init_finalize()
1645 has_s_stream = v4l2_subdev_has_op(sd, video, s_stream); in __v4l2_subdev_init_finalize()
1646 has_enable_streams = v4l2_subdev_has_op(sd, pad, enable_streams); in __v4l2_subdev_init_finalize()
1647 has_disable_streams = v4l2_subdev_has_op(sd, pad, disable_streams); in __v4l2_subdev_init_finalize()
1652 sd->name); in __v4l2_subdev_init_finalize()
1656 if (sd->flags & V4L2_SUBDEV_FL_STREAMS) { in __v4l2_subdev_init_finalize()
1660 sd->name); in __v4l2_subdev_init_finalize()
1666 if (sd->ctrl_handler) in __v4l2_subdev_init_finalize()
1667 sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS; in __v4l2_subdev_init_finalize()
1669 state = __v4l2_subdev_state_alloc(sd, name, key); in __v4l2_subdev_init_finalize()
1673 sd->active_state = state; in __v4l2_subdev_init_finalize()
1679 void v4l2_subdev_cleanup(struct v4l2_subdev *sd) in v4l2_subdev_cleanup() argument
1683 __v4l2_subdev_state_free(sd->active_state); in v4l2_subdev_cleanup()
1684 sd->active_state = NULL; in v4l2_subdev_cleanup()
1687 if (!sd->async_subdev_endpoint_list.next) in v4l2_subdev_cleanup()
1690 list_for_each_entry_safe(ase, ase_tmp, &sd->async_subdev_endpoint_list, in v4l2_subdev_cleanup()
1713 if (pad >= state->sd->entity.num_pads) in __v4l2_subdev_state_get_format()
1747 if (pad >= state->sd->entity.num_pads) in __v4l2_subdev_state_get_crop()
1781 if (pad >= state->sd->entity.num_pads) in __v4l2_subdev_state_get_compose()
1817 if (pad >= state->sd->entity.num_pads) in __v4l2_subdev_state_get_interval()
1888 int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, in v4l2_subdev_get_fmt() argument
1903 int v4l2_subdev_get_frame_interval(struct v4l2_subdev *sd, in v4l2_subdev_get_frame_interval() argument
1919 int v4l2_subdev_set_routing(struct v4l2_subdev *sd, in v4l2_subdev_set_routing() argument
1977 int v4l2_subdev_set_routing_with_fmt(struct v4l2_subdev *sd, in v4l2_subdev_set_routing_with_fmt() argument
1986 ret = v4l2_subdev_set_routing(sd, state, routing); in v4l2_subdev_set_routing_with_fmt()
2073 int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, in v4l2_subdev_routing_validate() argument
2083 remote_pads = kcalloc(sd->entity.num_pads, sizeof(*remote_pads), in v4l2_subdev_routing_validate()
2088 for (i = 0; i < sd->entity.num_pads; ++i) in v4l2_subdev_routing_validate()
2096 if (route->sink_pad >= sd->entity.num_pads || in v4l2_subdev_routing_validate()
2097 !(sd->entity.pads[route->sink_pad].flags & MEDIA_PAD_FL_SINK)) { in v4l2_subdev_routing_validate()
2098 dev_dbg(sd->dev, "route %u sink (%u) is not a sink pad\n", in v4l2_subdev_routing_validate()
2103 if (route->source_pad >= sd->entity.num_pads || in v4l2_subdev_routing_validate()
2104 !(sd->entity.pads[route->source_pad].flags & MEDIA_PAD_FL_SOURCE)) { in v4l2_subdev_routing_validate()
2105 dev_dbg(sd->dev, "route %u source (%u) is not a source pad\n", in v4l2_subdev_routing_validate()
2117 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2131 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2145 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2159 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2181 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2195 dev_dbg(sd->dev, in v4l2_subdev_routing_validate()
2212 static void v4l2_subdev_collect_streams(struct v4l2_subdev *sd, in v4l2_subdev_collect_streams() argument
2218 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) { in v4l2_subdev_collect_streams()
2221 (sd->enabled_pads & BIT_ULL(pad)) ? BIT_ULL(0) : 0; in v4l2_subdev_collect_streams()
2241 static void v4l2_subdev_set_streams_enabled(struct v4l2_subdev *sd, in v4l2_subdev_set_streams_enabled() argument
2246 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) { in v4l2_subdev_set_streams_enabled()
2248 sd->enabled_pads |= BIT_ULL(pad); in v4l2_subdev_set_streams_enabled()
2250 sd->enabled_pads &= ~BIT_ULL(pad); in v4l2_subdev_set_streams_enabled()
2263 int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad, in v4l2_subdev_enable_streams() argument
2266 struct device *dev = sd->entity.graph_obj.mdev->dev; in v4l2_subdev_enable_streams()
2275 if (pad >= sd->entity.num_pads) in v4l2_subdev_enable_streams()
2278 if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)) in v4l2_subdev_enable_streams()
2285 if (pad >= sizeof(sd->enabled_pads) * BITS_PER_BYTE) in v4l2_subdev_enable_streams()
2292 use_s_stream = !v4l2_subdev_has_op(sd, pad, enable_streams); in v4l2_subdev_enable_streams()
2295 state = v4l2_subdev_lock_and_get_active_state(sd); in v4l2_subdev_enable_streams()
2304 v4l2_subdev_collect_streams(sd, state, pad, streams_mask, in v4l2_subdev_enable_streams()
2309 streams_mask & ~found_streams, sd->entity.name, pad); in v4l2_subdev_enable_streams()
2316 enabled_streams, sd->entity.name, pad); in v4l2_subdev_enable_streams()
2323 already_streaming = v4l2_subdev_is_streaming(sd); in v4l2_subdev_enable_streams()
2327 ret = v4l2_subdev_call(sd, pad, enable_streams, state, pad, in v4l2_subdev_enable_streams()
2332 ret = v4l2_subdev_call(sd, video, s_stream, 1); in v4l2_subdev_enable_streams()
2344 v4l2_subdev_set_streams_enabled(sd, state, pad, streams_mask, true); in v4l2_subdev_enable_streams()
2354 v4l2_subdev_enable_privacy_led(sd); in v4l2_subdev_enable_streams()
2364 int v4l2_subdev_disable_streams(struct v4l2_subdev *sd, u32 pad, in v4l2_subdev_disable_streams() argument
2367 struct device *dev = sd->entity.graph_obj.mdev->dev; in v4l2_subdev_disable_streams()
2375 if (pad >= sd->entity.num_pads) in v4l2_subdev_disable_streams()
2378 if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)) in v4l2_subdev_disable_streams()
2385 if (pad >= sizeof(sd->enabled_pads) * BITS_PER_BYTE) in v4l2_subdev_disable_streams()
2392 use_s_stream = !v4l2_subdev_has_op(sd, pad, disable_streams); in v4l2_subdev_disable_streams()
2395 state = v4l2_subdev_lock_and_get_active_state(sd); in v4l2_subdev_disable_streams()
2404 v4l2_subdev_collect_streams(sd, state, pad, streams_mask, in v4l2_subdev_disable_streams()
2409 streams_mask & ~found_streams, sd->entity.name, pad); in v4l2_subdev_disable_streams()
2416 streams_mask & ~enabled_streams, sd->entity.name, pad); in v4l2_subdev_disable_streams()
2425 ret = v4l2_subdev_call(sd, pad, disable_streams, state, pad, in v4l2_subdev_disable_streams()
2430 if (!(sd->enabled_pads & ~BIT_ULL(pad))) in v4l2_subdev_disable_streams()
2431 ret = v4l2_subdev_call(sd, video, s_stream, 0); in v4l2_subdev_disable_streams()
2442 v4l2_subdev_set_streams_enabled(sd, state, pad, streams_mask, false); in v4l2_subdev_disable_streams()
2446 if (!v4l2_subdev_is_streaming(sd)) in v4l2_subdev_disable_streams()
2447 v4l2_subdev_disable_privacy_led(sd); in v4l2_subdev_disable_streams()
2456 int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable) in v4l2_subdev_s_stream_helper() argument
2469 media_entity_for_each_pad(&sd->entity, pad) { in v4l2_subdev_s_stream_helper()
2479 if (sd->flags & V4L2_SUBDEV_FL_STREAMS) { in v4l2_subdev_s_stream_helper()
2484 state = v4l2_subdev_lock_and_get_active_state(sd); in v4l2_subdev_s_stream_helper()
2499 return v4l2_subdev_enable_streams(sd, pad_index, source_mask); in v4l2_subdev_s_stream_helper()
2501 return v4l2_subdev_disable_streams(sd, pad_index, source_mask); in v4l2_subdev_s_stream_helper()
2509 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) in v4l2_subdev_init() argument
2511 INIT_LIST_HEAD(&sd->list); in v4l2_subdev_init()
2513 sd->ops = ops; in v4l2_subdev_init()
2514 sd->v4l2_dev = NULL; in v4l2_subdev_init()
2515 sd->flags = 0; in v4l2_subdev_init()
2516 sd->name[0] = '\0'; in v4l2_subdev_init()
2517 sd->grp_id = 0; in v4l2_subdev_init()
2518 sd->dev_priv = NULL; in v4l2_subdev_init()
2519 sd->host_priv = NULL; in v4l2_subdev_init()
2520 sd->privacy_led = NULL; in v4l2_subdev_init()
2521 INIT_LIST_HEAD(&sd->async_subdev_endpoint_list); in v4l2_subdev_init()
2523 sd->entity.name = sd->name; in v4l2_subdev_init()
2524 sd->entity.obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV; in v4l2_subdev_init()
2525 sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; in v4l2_subdev_init()
2530 void v4l2_subdev_notify_event(struct v4l2_subdev *sd, in v4l2_subdev_notify_event() argument
2533 v4l2_event_queue(sd->devnode, ev); in v4l2_subdev_notify_event()
2534 v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT, (void *)ev); in v4l2_subdev_notify_event()
2538 bool v4l2_subdev_is_streaming(struct v4l2_subdev *sd) in v4l2_subdev_is_streaming() argument
2542 if (!v4l2_subdev_has_op(sd, pad, enable_streams)) in v4l2_subdev_is_streaming()
2543 return sd->s_stream_enabled; in v4l2_subdev_is_streaming()
2545 if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) in v4l2_subdev_is_streaming()
2546 return !!sd->enabled_pads; in v4l2_subdev_is_streaming()
2548 state = v4l2_subdev_get_locked_active_state(sd); in v4l2_subdev_is_streaming()
2563 int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd) in v4l2_subdev_get_privacy_led() argument
2566 sd->privacy_led = led_get(sd->dev, "privacy-led"); in v4l2_subdev_get_privacy_led()
2567 if (IS_ERR(sd->privacy_led) && PTR_ERR(sd->privacy_led) != -ENOENT) in v4l2_subdev_get_privacy_led()
2568 return dev_err_probe(sd->dev, PTR_ERR(sd->privacy_led), in v4l2_subdev_get_privacy_led()
2571 if (!IS_ERR_OR_NULL(sd->privacy_led)) { in v4l2_subdev_get_privacy_led()
2572 mutex_lock(&sd->privacy_led->led_access); in v4l2_subdev_get_privacy_led()
2573 led_sysfs_disable(sd->privacy_led); in v4l2_subdev_get_privacy_led()
2574 led_trigger_remove(sd->privacy_led); in v4l2_subdev_get_privacy_led()
2575 led_set_brightness(sd->privacy_led, 0); in v4l2_subdev_get_privacy_led()
2576 mutex_unlock(&sd->privacy_led->led_access); in v4l2_subdev_get_privacy_led()
2583 void v4l2_subdev_put_privacy_led(struct v4l2_subdev *sd) in v4l2_subdev_put_privacy_led() argument
2586 if (!IS_ERR_OR_NULL(sd->privacy_led)) { in v4l2_subdev_put_privacy_led()
2587 mutex_lock(&sd->privacy_led->led_access); in v4l2_subdev_put_privacy_led()
2588 led_sysfs_enable(sd->privacy_led); in v4l2_subdev_put_privacy_led()
2589 mutex_unlock(&sd->privacy_led->led_access); in v4l2_subdev_put_privacy_led()
2590 led_put(sd->privacy_led); in v4l2_subdev_put_privacy_led()