Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: v4l: Support obtaining link frequency via get_mbus_config

Add link_freq field to struct v4l2_mbus_config in order to pass the link
frequency to the receiving sub-device.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Sakari Ailus and committed by
Hans Verkuil
9849b9fe 15f0035b

+15 -2
+13 -2
drivers/media/v4l2-core/v4l2-common.c
··· 508 508 s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, 509 509 unsigned int div) 510 510 { 511 + struct v4l2_mbus_config mbus_config = {}; 511 512 struct v4l2_subdev *sd; 513 + int ret; 512 514 513 515 sd = media_entity_to_v4l2_subdev(pad->entity); 514 - if (!sd) 515 - return -ENODEV; 516 + ret = v4l2_subdev_call(sd, pad, get_mbus_config, pad->index, 517 + &mbus_config); 518 + if (ret < 0 && ret != -ENOIOCTLCMD) 519 + return ret; 516 520 521 + if (mbus_config.link_freq) 522 + return mbus_config.link_freq; 523 + 524 + /* 525 + * Fall back to using the link frequency control if the media bus config 526 + * doesn't provide a link frequency. 527 + */ 517 528 return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div); 518 529 } 519 530 EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
+2
include/media/v4l2-mediabus.h
··· 169 169 /** 170 170 * struct v4l2_mbus_config - media bus configuration 171 171 * @type: interface type 172 + * @link_freq: The link frequency. See also V4L2_CID_LINK_FREQ control. 172 173 * @bus: bus configuration data structure 173 174 * @bus.parallel: embedded &struct v4l2_mbus_config_parallel. 174 175 * Used if the bus is parallel or BT.656. ··· 184 183 */ 185 184 struct v4l2_mbus_config { 186 185 enum v4l2_mbus_type type; 186 + u64 link_freq; 187 187 union { 188 188 struct v4l2_mbus_config_parallel parallel; 189 189 struct v4l2_mbus_config_mipi_csi1 mipi_csi1;