/* Set this flag if this subdev is a i2c device. */ #define V4L2_SUBDEV_FL_IS_I2C (1U << 0) /* Set this flag if this subdev is a spi device. */ #define V4L2_SUBDEV_FL_IS_SPI (1U << 1) /* Set this flag if this subdev needs a device node. */ #define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2) /* *Setthisflagifthissubdevgeneratesevents. *Notecontrolscansendevents,thusdriversexposingcontrols *shouldsetthisflag.
*/ #define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3) /* *Setthisflagifthissubdevsupportsmultiplexedstreams.Thismeans *thatthedriversupportsroutingandhandlesthestreamparameterinits *v4l2_subdev_pad_opshandlers.Morespecifically,thismeans: * *-Centrallymanagedsubdevactivestateisenabled *-Legacypadconfigis_not_supported(state->padsisNULL) *-Routingioctlsareavailable *-Multiplestreamsperpadaresupported
*/ #define V4L2_SUBDEV_FL_STREAMS (1U << 4)
/** *v4l2_subdev_get_fmt()-Fillformatbasedonstate *@sd:subdevice *@state:subdevicestate *@format:pointerto&structv4l2_subdev_format * *Fill@format->formatfieldbasedontheinformationinthe@formatstruct. * *Thisfunctioncanbeusedbythesubdevdriverswhichsupportactivestateto *implementv4l2_subdev_pad_ops.get_fmtifthesubdevdriverdoesnotneedto ## <O___,, # (see version control and CREDITS file for authors & dates) ## * * success otherwise.
*/
int(v4l2_subdev sd state
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 38
/**
* v4l2_subdev_get_frame_interval() - Fill frame interval based on state
* @sd: subdevice
* @@state:subdevice state
* pointer to&struct
*
information struct.
*
* This function can be used by the subdev drivers which support active state to
* implement v4l2_subdev_pad_ops.get_frame_interval if the subdev driver does
* not need to do anything special in their get_frame_interval op.
*
* Returns 0 on success, error value otherwise.
*/
int v4l2_subdev_get_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
struct v4l2_subdev_frame_interval *fi);
/**
* v4l2_subdev_set_routing() - Set given routing to subdev state
* @sd: The subdevice
* @state: The subdevice state
* @routing: Routing that will be copied to subdev state
*
* This will release old routing table (if any) from the state, allocate
* enough space for the given routing, and copy the routing.
*
* This can be used from the subdev driver's set_routing op, after validating
* the routing.
*/
int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
const struct v4l2_subdev_krouting *routing);
/**
* for_each_active_route - iterate on all active routes of a routing table
* @routing: The routing table
* @route: The route iterator
*/ #define for_each_active_route(routing, route) \ for ((route) = NULL; \
((route) = __v4l2_subdev_next_active_route((routing), (route)));)
/**
* v4l2_subdev_set_routing_with_fmt() - Set given routing and format to subdev
* state
* @sd: The subdevice
* @state: The subdevice state
* @routing: Routing that will be copied to subdev state
* @fmt: Format used to initialize all the streams
*
* This is the same as v4l2_subdev_set_routing, but additionally initializes
* all the streams using the given format.
*/
int v4l2_subdev_set_routing_with_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
const struct v4l2_subdev_krouting *routing,
const struct v4l2_mbus_framefmt *fmt);
/**
* v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
* @routing: routing used to find the opposite side
* @pad: pad id
* @stream: stream id
* @other_pad: pointer used to return the opposite pad
* @other_stream: pointer used to return the opposite stream
*
* This function uses the routing table to find the pad + stream which is
* opposite the given pad + stream.
*
* @other_pad and/or @other_stream can be NULL if the caller does not need the
* value.
*
* Returns 0 on success, or -EINVAL if no matching route is found.
*/
int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
u32 pad, u32 stream, u32 *other_pad,
u32 *other_stream);
/**
* v4l2_subdev_state_get_opposite_stream_format() - Get pointer to opposite
* stream format
* @state: subdevice state
* @pad: pad id
* @stream: stream id
*
* This returns a pointer to &struct v4l2_mbus_framefmt for the pad + stream
* that is opposite the given pad + stream in the subdev state.
*
* If the state does not contain the given pad + stream, NULL is returned.
*/
struct v4l2_mbus_framefmt *
v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state,
u32 pad, u32 stream);
/**
* v4l2_subdev_state_xlate_streams() - Translate streams from one pad to another
*
* @state: Subdevice state
* @pad0: The first pad
* @pad1: The second pad
* @streams: Streams bitmask on the first pad
*
* Streams on sink pads of a subdev are routed to source pads as expressed in
* the subdev state routing table. Stream numbers don't necessarily match on
* the sink and source side of a route. This function translates stream numbers
* on @pad0, expressed as a bitmask in @streams, to the corresponding streams
* on @pad1 using the routing table from the @state. It returns the stream mask
* on @pad1, and updates @streams with the streams that have been found in the
* routing table.
*
* @pad0 and @pad1 must be a sink and a source, in any order.
*
* Return: The bitmask of streams of @pad1 that are routed to @streams on @pad0.
*/
u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state,
u32 pad0, u32 pad1, u64 *streams);
/**
* enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions
*
* @V4L2_SUBDEV_ROUTING_NO_1_TO_N:
* an input stream shall not be routed to multiple output streams (stream
* duplication)
* @V4L2_SUBDEV_ROUTING_NO_N_TO_1:
* multiple input streams shall not be routed to the same output stream
* (stream merging)
* @V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX:
* all streams from a sink pad must be routed to a single source pad
* @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX:
* all streams on a source pad must originate from a single sink pad
* @V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING:
* source pads shall not contain multiplexed streams
* @V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING:
* sink pads shall not contain multiplexed streams
* @V4L2_SUBDEV_ROUTING_ONLY_1_TO_1:
* only non-overlapping 1-to-1 stream routing is allowed (a combination of
* @V4L2_SUBDEV_ROUTING_NO_1_TO_N and @V4L2_SUBDEV_ROUTING_NO_N_TO_1)
* @V4L2_SUBDEV_ROUTING_NO_STREAM_MIX:
* all streams from a sink pad must be routed to a single source pad, and
* that source pad shall not get routes from any other sink pad
* (a combination of @V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX and
* @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX)
* @V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING:
* no multiplexed streams allowed on either source or sink sides.
*/
enum v4l2_subdev_routing_restriction {
V4L2_SUBDEV_ROUTING_NO_1_TO_N = BIT(0),
V4L2_SUBDEV_ROUTING_NO_N_TO_1 = BIT(1),
V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX = BIT(2),
V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX = BIT(3),
V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING = BIT(4),
V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING = BIT(5),
V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 =
V4L2_SUBDEV_ROUTING_NO_1_TO_N |
V4L2_SUBDEV_ROUTING_NO_N_TO_1,
V4L2_SUBDEV_ROUTING_NO_STREAM_MIX =
V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX |
V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX,
V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING =
V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING |
V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING,
};
/**
* v4l2_subdev_routing_validate() - Verify that routes comply with driver
* constraints
* @sd: The subdevice
* @routing: Routing to verify
* @disallow: Restrictions on routes
*
* This verifies that the given routing complies with the @disallow constraints.
*
* Returns 0 on success, error value otherwise.
*/
int v4l2_subdev_routing_validate(struct v4l2_subdev *sd,
const struct v4l2_subdev_krouting *routing,
enum v4l2_subdev_routing_restriction disallow);
/**
* v4l2_subdev_enable_streams() - Enable streams on a pad
* @sd: The subdevice
* @pad: The pad
* @streams_mask: Bitmask of streams to enable
*
* This function enables streams on a source @pad of a subdevice. The pad is
* identified by its index, while the streams are identified by the
* @streams_mask bitmask. This allows enabling multiple streams on a pad at
* once.
*
* Enabling a stream that is already enabled isn't allowed. If @streams_mask
* contains an already enabled stream, this function returns -EALREADY without
* performing any operation.
*
* Per-stream enable is only available for subdevs that implement the
* .enable_streams() and .disable_streams() operations. For other subdevs, this
* function implements a best-effort compatibility by calling the .s_stream()
* operation, limited to subdevs that have a single source pad.
*
* Drivers that are not stream-aware shall set @streams_mask to BIT_ULL(0).
*
* Return:
* * 0: Success
* * -EALREADY: One of the streams in streams_mask is already enabled
* * -EINVAL: The pad index is invalid, or doesn't correspond to a source pad
* * -EOPNOTSUPP: Falling back to the legacy .s_stream() operation is
* impossible because the subdev has multiple source pads
*/
int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
u64 streams_mask);
/**
* v4l2_subdev_disable_streams() - Disable streams on a pad
* @sd: The subdevice
* @pad: The pad
* @streams_mask: Bitmask of streams to disable
*
* This function disables streams on a source @pad of a subdevice. The pad is
* identified by its index, while the streams are identified by the
* @streams_mask bitmask. This allows disabling multiple streams on a pad at
* once.
*
* Disabling a streams that isnot enabled isn't allowed. If @streams_mask
* contains a disabled stream, this function returns -EALREADY without
* performing any operation.
*
* Per-stream disable is only available for subdevs that implement the
* .enable_streams() and .disable_streams() operations. For other subdevs, this
* function implements a best-effort compatibility by calling the .s_stream()
* operation, limited to subdevs that have a single source pad.
*
* Drivers that are not stream-aware shall set @streams_mask to BIT_ULL(0).
*
* Return:
* * 0: Success
* * -EALREADY: One of the streams in streams_mask isnot enabled
* * -EINVAL: The pad index is invalid, or doesn't correspond to a source pad
* * -EOPNOTSUPP: Falling back to the legacy .s_stream() operation is
* impossible because the subdev has multiple source pads
*/
int v4l2_subdev_disable_streams(struct v4l2_subdev *sd, u32 pad,
u64 streams_mask);
/**
* v4l2_subdev_s_stream_helper() - Helper to implement the subdev s_stream
* operation using enable_streams and disable_streams
* @sd: The subdevice
* @enable: Enable or disable streaming
*
* Subdevice drivers that implement the streams-aware
* &v4l2_subdev_pad_ops.enable_streams and &v4l2_subdev_pad_ops.disable_streams
* operations can use this helper to implement the legacy
* &v4l2_subdev_video_ops.s_stream operation.
*
* This helper can only be used by subdevs that have a single source pad.
*
* Return: 0 on success, or a negative error code otherwise.
*/
int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable);
#endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */
#endif /* CONFIG_MEDIA_CONTROLLER */
/**
* v4l2_subdev_lock_state() - Locks the subdev state
* @state: The subdevice state
*
* Locks the given subdev state.
*
* The state must be unlocked with v4l2_subdev_unlock_state() after use.
*/
static inline void v4l2_subdev_lock_state(struct v4l2_subdev_state *state)
{
mutex_lock(state->lock);
}
/**
* v4l2_subdev_unlock_state() - Unlocks the subdev state
* @state: The subdevice state
*
* Unlocks the given subdev state.
*/
static inline void v4l2_subdev_unlock_state(struct v4l2_subdev_state *state)
{
mutex_unlock(state->lock);
}
/**
* v4l2_subdev_lock_states - Lock two sub-device states
* @state1: One subdevice state
* @state2: The other subdevice state
*
* Locks the state of two sub-devices.
*
* The states must be unlocked with v4l2_subdev_unlock_states() after use.
*
* This differs from calling v4l2_subdev_lock_state() on both states so that if
* the states share the same lock, the lock is acquired only once (so no
* deadlock occurs). The caller is responsible for ensuring the locks will
* always be acquired in the same order.
*/
static inline void v4l2_subdev_lock_states(struct v4l2_subdev_state *state1,
struct v4l2_subdev_state *state2)
{
mutex_lock(state1->lock); if (state1->lock != state2->lock)
mutex_lock(state2->lock);
}
/**
* v4l2_subdev_unlock_states() - Unlock two sub-device states
* @state1: One subdevice state
* @state2: The other subdevice state
*
* Unlocks the state of two sub-devices.
*
* This differs from calling v4l2_subdev_unlock_state() on both states so that
* if the states share the same lock, the lock is released only once.
*/
static inline void v4l2_subdev_unlock_states(struct v4l2_subdev_state *state1,
struct v4l2_subdev_state *state2)
{
mutex_unlock(state1->lock); if (state1->lock != state2->lock)
mutex_unlock(state2->lock);
}
/**
* v4l2_subdev_get_unlocked_active_state() - Checks that the active subdev state
* is unlocked and returns it
* @sd: The subdevice
*
* Returns the active state for the subdevice, or NULL if the subdev does not
* support active state. If the state isnot NULL, calls
* lockdep_assert_not_held() to issue a warning if the state is locked.
*
* This function is to be used e.g. when getting the active state for the sole
* purpose of passing it forward, without accessing the state fields.
*/
static inline struct v4l2_subdev_state *
v4l2_subdev_get_unlocked_active_state(struct v4l2_subdev *sd)
{ if (sd->active_state)
lockdep_assert_not_held(sd->active_state->lock); return sd->active_state;
}
/**
* v4l2_subdev_get_locked_active_state() - Checks that the active subdev state
* is locked and returns it
*
* @sd: The subdevice
*
* Returns the active state for the subdevice, or NULL if the subdev does not
* support active state. If the state isnot NULL, calls lockdep_assert_held()
* to issue a warning if the state isnot locked.
*
* This function is to be used when the caller knows that the active state is
* already locked.
*/
static inline struct v4l2_subdev_state *
v4l2_subdev_get_locked_active_state(struct v4l2_subdev *sd)
{ if (sd->active_state)
lockdep_assert_held(sd->active_state->lock); return sd->active_state;
}
/**
* v4l2_subdev_lock_and_get_active_state() - Locks and returns the active subdev
* state for the subdevice
* @sd: The subdevice
*
* Returns the locked active state for the subdevice, or NULL if the subdev
* does not support active state.
*
* The state must be unlocked with v4l2_subdev_unlock_state() after use.
*/
static inline struct v4l2_subdev_state *
v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
{ if (sd->active_state)
v4l2_subdev_lock_state(sd->active_state); return sd->active_state;
}
/**
* v4l2_subdev_init - initializes the sub-device struct
*
* @sd: pointer to the &struct v4l2_subdev to be initialized
* @ops: pointer to &struct v4l2_subdev_ops.
*/
void v4l2_subdev_init(struct v4l2_subdev *sd,
const struct v4l2_subdev_ops *ops);
/**
* v4l2_subdev_call - call an operation of a v4l2_subdev.
*
* @sd: pointer to the &struct v4l2_subdev
* @o: name of the element at &struct v4l2_subdev_ops that contains @f.
* Each element there groups a set of callbacks functions.
* @f: callback function to be called.
* The callback functions are defined in groups, according to
* each element at &struct v4l2_subdev_ops.
* @args: arguments for @f.
*
* Example: err = v4l2_subdev_call(sd, video, s_std, norm);
*/ #define v4l2_subdev_call(sd, o, f, args...) \
({ \
struct v4l2_subdev *__sd = (sd); \
int __result; \ if (!__sd) \
__result = -ENODEV; \ elseif (!(__sd->ops->o && __sd->ops->o->f)) \
__result = -ENOIOCTLCMD; \ elseif (v4l2_subdev_call_wrappers.o && \
v4l2_subdev_call_wrappers.o->f) \
__result = v4l2_subdev_call_wrappers.o->f( \
__sd, ##args); \ else \
__result = __sd->ops->o->f(__sd, ##args); \
__result; \
})
/**
* v4l2_subdev_call_state_active - call an operation of a v4l2_subdev which
* takes state as a parameter, passing the
* subdev its active state.
*
* @sd: pointer to the &struct v4l2_subdev
* @o: name of the element at &struct v4l2_subdev_ops that contains @f.
* Each element there groups a set of callbacks functions.
* @f: callback function to be called.
* The callback functions are defined in groups, according to
* each element at &struct v4l2_subdev_ops.
* @args: arguments for @f.
*
* This is similar to v4l2_subdev_call(), except that this version can only be
* used for ops that take a subdev state as a parameter. The macro will get the
* active state, lock it before calling the op and unlock it after the call.
*/ #define v4l2_subdev_call_state_active(sd, o, f, args...) \
({ \
int __result; \
struct v4l2_subdev_state *state; \
state = v4l2_subdev_get_unlocked_active_state(sd); \ if (state) \
v4l2_subdev_lock_state(state); \
__result = v4l2_subdev_call(sd, o, f, state, ##args); \ if (state) \
v4l2_subdev_unlock_state(state); \
__result; \
})
/**
* v4l2_subdev_call_state_try - call an operation of a v4l2_subdev which
* takes state as a parameter, passing the
* subdev a newly allocated try state.
*
* @sd: pointer to the &struct v4l2_subdev
* @o: name of the element at &struct v4l2_subdev_ops that contains @f.
* Each element there groups a set of callbacks functions.
* @f: callback function to be called.
* The callback functions are defined in groups, according to
* each element at &struct v4l2_subdev_ops.
* @args: arguments for @f.
*
* This is similar to v4l2_subdev_call_state_active(), except that as this
* version allocates a new state, this is only usable for
* V4L2_SUBDEV_FORMAT_TRY use cases.
*
* Note: only legacy non-MC drivers may need this macro.
*/ #define v4l2_subdev_call_state_try(sd, o, f, args...) \
({ \
int __result; \
static struct lock_class_key __key; \
const char *name = KBUILD_BASENAME \ ":" __stringify(__LINE__) ":state->lock"; \
struct v4l2_subdev_state *state = \
__v4l2_subdev_state_alloc(sd, name, &__key); \ if (IS_ERR(state)) { \
__result = PTR_ERR(state); \
} else { \
v4l2_subdev_lock_state(state); \
__result = v4l2_subdev_call(sd, o, f, state, ##args); \
v4l2_subdev_unlock_state(state); \
__v4l2_subdev_state_free(state); \
} \
__result; \
})
/**
* v4l2_subdev_has_op - Checks if a subdev defines a certain operation.
*
* @sd: pointer to the &struct v4l2_subdev
* @o: The group of callback functions in &struct v4l2_subdev_ops
* which @f is a part of.
* @f: callback function to be checked for its existence.
*/ #define v4l2_subdev_has_op(sd, o, f) \
((sd)->ops->o && (sd)->ops->o->f)
/**
* v4l2_subdev_notify_event() - Delivers event notification for subdevice
* @sd: The subdev for which to deliver the event
* @ev: The event to deliver
*
* Will deliver the specified event to all userspace event listeners which are
* subscribed to the v42l subdev event queue as well as to the bridge driver
* using the notify callback. The notification type for the notify callback
* will be %V4L2_DEVICE_NOTIFY_EVENT.
*/
void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
const struct v4l2_event *ev);
/**
* v4l2_subdev_is_streaming() - Returns if the subdevice is streaming
* @sd: The subdevice
*
* v4l2_subdev_is_streaming() tells if the subdevice is currently streaming.
* "Streaming" here means whether .s_stream() or .enable_streams() has been
* successfully called, and the streaming has not yet been disabled.
*
* If the subdevice implements .enable_streams() this function must be called
* while holding the active state lock.
*/
bool v4l2_subdev_is_streaming(struct v4l2_subdev *sd);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.