From: Greg Hackmann Date: Fri, 13 Sep 2013 18:23:05 +0000 (-0700) Subject: video: adf: add informational flags to interfaces X-Git-Tag: firefly_0821_release~2958^2~232 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e45fc30f3ee796625e26a8a9d7936bd273e1018f;p=firefly-linux-kernel-4.4.55.git 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 --- diff --git a/drivers/video/adf/adf.c b/drivers/video/adf/adf.c index 15fbc4a0d53b..79511759d2a5 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 343bdcc77443..abec58ea2ed8 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 2ecf8c8001f3..60a47cf5a781 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 8d0413274bcd..18c673dc5e2e 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 e35a505882da..2ba345ca458b 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, @@ -256,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 eb7b9be19c7e..82d49fcf00cf 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)