From 27e7183c5aa432bfd6a99e6164761eae3917748b Mon Sep 17 00:00:00 2001 From: Greg Hackmann Date: Fri, 13 Sep 2013 11:23:05 -0700 Subject: video: adf: add informational flags to interfaces Informational flags don't affect ADF directly but may be useful to clients. Currently used to indicate primary and external displays. Change-Id: I343c7f0148da0869244c8e818350e9855525df85 Signed-off-by: Greg Hackmann --- drivers/video/adf/adf.c | 12 +++++++++++- drivers/video/adf/adf_fops.c | 1 + drivers/video/adf/adf_fops32.c | 2 ++ drivers/video/adf/adf_fops32.h | 1 + include/uapi/video/adf.h | 5 +++++ include/video/adf.h | 6 ++++-- 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/video/adf/adf.c b/drivers/video/adf/adf.c index 15fbc4a0d53..79511759d2a 100644 --- a/drivers/video/adf/adf.c +++ b/drivers/video/adf/adf.c @@ -625,6 +625,7 @@ EXPORT_SYMBOL(adf_device_destroy); * @type: interface type (see enum @adf_interface_type) * @idx: which interface of type @type; * e.g. interface DSI.1 -> @type=%ADF_INTF_TYPE_DSI, @idx=1 + * @flags: informational flags (bitmask of %ADF_INTF_FLAG_* values) * @ops: the interface's associated ops * @fmt: formatting string for the display interface's name * @@ -637,11 +638,13 @@ EXPORT_SYMBOL(adf_device_destroy); * Returns 0 on success or error code (<0) on failure. */ int adf_interface_init(struct adf_interface *intf, struct adf_device *dev, - enum adf_interface_type type, u32 idx, + enum adf_interface_type type, u32 idx, u32 flags, const struct adf_interface_ops *ops, const char *fmt, ...) { int ret; va_list args; + const u32 allowed_flags = ADF_INTF_FLAG_PRIMARY | + ADF_INTF_FLAG_EXTERNAL; if (dev->n_interfaces == ADF_MAX_INTERFACES) { pr_err("%s: parent device %s has too many interfaces\n", @@ -654,6 +657,12 @@ int adf_interface_init(struct adf_interface *intf, struct adf_device *dev, return -EINVAL; } + if (flags & ~allowed_flags) { + pr_err("%s: invalid interface flags 0x%X\n", __func__, + flags & ~allowed_flags); + return -EINVAL; + } + memset(intf, 0, sizeof(*intf)); va_start(args, fmt); @@ -665,6 +674,7 @@ int adf_interface_init(struct adf_interface *intf, struct adf_device *dev, intf->type = type; intf->idx = idx; + intf->flags = flags; intf->ops = ops; init_waitqueue_head(&intf->vsync_wait); rwlock_init(&intf->vsync_lock); diff --git a/drivers/video/adf/adf_fops.c b/drivers/video/adf/adf_fops.c index 343bdcc7744..abec58ea2ed 100644 --- a/drivers/video/adf/adf_fops.c +++ b/drivers/video/adf/adf_fops.c @@ -570,6 +570,7 @@ static int adf_intf_get_data(struct adf_interface *intf, data.type = intf->type; data.id = intf->idx; + data.flags = intf->flags; err = adf_interface_get_screen_size(intf, &data.width_mm, &data.height_mm); diff --git a/drivers/video/adf/adf_fops32.c b/drivers/video/adf/adf_fops32.c index 2ecf8c8001f..60a47cf5a78 100644 --- a/drivers/video/adf/adf_fops32.c +++ b/drivers/video/adf/adf_fops32.c @@ -130,6 +130,8 @@ long adf_compat_get_interface_data(struct file *file, copy_in_user(&arg->type, &data->type, sizeof(arg->type)) || copy_in_user(&arg->id, &data->id, sizeof(arg->id)) || + copy_in_user(&arg->flags, &data->flags, + sizeof(arg->flags)) || copy_in_user(&arg->dpms_state, &data->dpms_state, sizeof(arg->dpms_state)) || copy_in_user(&arg->hotplug_detect, diff --git a/drivers/video/adf/adf_fops32.h b/drivers/video/adf/adf_fops32.h index 8d0413274bc..18c673dc5e2 100644 --- a/drivers/video/adf/adf_fops32.h +++ b/drivers/video/adf/adf_fops32.h @@ -47,6 +47,7 @@ struct adf_interface_data32 { __u8 type; __u32 id; /* e.g. type=ADF_INTF_TYPE_DSI, id=1 => DSI.1 */ + __u32 flags; __u8 dpms_state; __u8 hotplug_detect; diff --git a/include/uapi/video/adf.h b/include/uapi/video/adf.h index 108064626e0..2ba345ca458 100644 --- a/include/uapi/video/adf.h +++ b/include/uapi/video/adf.h @@ -36,6 +36,9 @@ enum adf_interface_type { ADF_INTF_TYPE_MAX = (~(__u32)0), }; +#define ADF_INTF_FLAG_PRIMARY (1 << 0) +#define ADF_INTF_FLAG_EXTERNAL (1 << 1) + enum adf_event_type { ADF_EVENT_VSYNC = 0, ADF_EVENT_HOTPLUG = 1, @@ -239,6 +242,7 @@ struct adf_device_data { * @type: interface type (see enum @adf_interface_type) * @id: which interface of type @type; * e.g. interface DSI.1 -> @type=@ADF_INTF_TYPE_DSI, @id=1 + * @flags: informational flags (bitmask of %ADF_INTF_FLAG_* values) * @dpms_state: DPMS state (one of @DRM_MODE_DPMS_* defined in drm_mode.h) * @hotplug_detect: whether a display is plugged in * @width_mm: screen width in millimeters, or 0 if unknown @@ -255,6 +259,7 @@ struct adf_interface_data { __u32 type; __u32 id; /* e.g. type=ADF_INTF_TYPE_DSI, id=1 => DSI.1 */ + __u32 flags; __u8 dpms_state; __u8 hotplug_detect; diff --git a/include/video/adf.h b/include/video/adf.h index eb7b9be19c7..82d49fcf00c 100644 --- a/include/video/adf.h +++ b/include/video/adf.h @@ -355,6 +355,7 @@ struct adf_interface { enum adf_interface_type type; u32 idx; + u32 flags; wait_queue_head_t vsync_wait; ktime_t vsync_timestamp; @@ -405,9 +406,10 @@ int __printf(4, 5) adf_device_init(struct adf_device *dev, struct device *parent, const struct adf_device_ops *ops, const char *fmt, ...); void adf_device_destroy(struct adf_device *dev); -int __printf(6, 7) adf_interface_init(struct adf_interface *intf, +int __printf(7, 8) adf_interface_init(struct adf_interface *intf, struct adf_device *dev, enum adf_interface_type type, u32 idx, - const struct adf_interface_ops *ops, const char *fmt, ...); + u32 flags, const struct adf_interface_ops *ops, const char *fmt, + ...); void adf_interface_destroy(struct adf_interface *intf); static inline struct adf_device *adf_interface_parent( struct adf_interface *intf) -- cgit v1.2.3