Add ChromeOS EC CEC Support
Subsystems (7)
v2 cover Add ChromeOS EC CEC Support
Hi All,
The new Google "Fizz" Intel-based ChromeOS device is gaining CEC support through it's Embedded Controller, to enable the Linux CEC Core to communicate with it and get the CEC Physical Address from the correct HDMI Connector, the following must be added/changed:
- Add the CEC sub-device registration in the ChromeOS EC MFD Driver
- Add the CEC related commands and events definitions into the EC MFD driver
- Add a way to get a CEC notifier with it's (optional) connector name
- Add the CEC notifier to the i915 HDMI driver
- Add the proper ChromeOS EC CEC Driver
The CEC notifier with the connector name is the tricky point, since even on Device-Tree platforms, there is no way to distinguish between multiple HDMI connectors from the same DRM driver. The solution I implemented is pretty simple and only adds an optional connector name to eventually distinguish an HDMI connector notifier from another if they share the same device.
Feel free to comment this patchset !
Changes since v1:
- Added cec_notifier_put to intel_hdmi
- Fixed all small reported issues on the EC CEC driver
- Moved the cec_notifier_get out of the #if .. #else .. #endif
Changes since RFC:
- Moved CEC sub-device registration after CEC commands and events definitions patch
- Removed get_notifier_get_byname
- Added CEC_CORE select into i915 Kconfig
- Removed CEC driver fallback if notifier is not configured on HW, added explicit warn
- Fixed CEC core return type on error
- Moved to cros-ec-cec media platform directory
- Use bus_find_device() to find the pci i915 device instead of get_notifier_get_byname()
- Fix Logical Address setup
- Added comment about HW support
- Removed memset of msg structures
Neil Armstrong (5):
media: cec-notifier: Get notifier by device and connector name drm/i915: hdmi: add CEC notifier to intel_hdmi
mfd: cros-ec: Introduce CEC commands and events definitions.
mfd: cros_ec_dev: Add CEC sub-device registration
media: platform: Add Chrome OS EC CEC driver
drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_hdmi.c | 12 + drivers/media/cec/cec-notifier.c | 11 +- drivers/media/platform/Kconfig | 11 + drivers/media/platform/Makefile | 2 + drivers/media/platform/cros-ec-cec/Makefile | 1 + drivers/media/platform/cros-ec-cec/cros-ec-cec.c | 335 +++++++++++++++++++++++ drivers/mfd/cros_ec_dev.c | 16 ++ drivers/platform/chrome/cros_ec_proto.c | 42 ++- include/linux/mfd/cros_ec.h | 2 +- include/linux/mfd/cros_ec_commands.h | 80 ++++++ include/media/cec-notifier.h | 27 +- 13 files changed, 526 insertions(+), 16 deletions(-) create mode 100644 drivers/media/platform/cros-ec-cec/Makefile create mode 100644 drivers/media/platform/cros-ec-cec/cros-ec-cec.c
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/5 media: cec-notifier: Get notifier by device and connector name
In non device-tree world, we can need to get the notifier by the driver name directly and eventually defer probe if not yet created.
This patch adds a variant of the get function by using the device name instead and will not create a notifier if not yet created.
But the i915 driver exposes at least 2 HDMI connectors, this patch also adds the possibility to add a connector name tied to the notifier device to form a tuple and associate different CEC controllers for each HDMI connectors.
--- drivers/media/cec/cec-notifier.c | 11 ++++++++--- include/media/cec-notifier.h | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-)
drivers/media/cec/cec-notifier.c +8 -3
@@ -21,6 +21,7 @@ struct cec_notifier {struct list_head head;struct kref kref;struct device *dev; +const char *conn;struct cec_adapter *cec_adap;void (*callback)(struct cec_adapter *adap,u16 pa);
@@ -30,13 +31,14 @@ struct cec_notifier {static LIST_HEAD (cec_notifiers);static DEFINE_MUTEX (cec_notifiers_lock); -struct cec_notifier *cec_notifier_get (struct device *dev) +struct cec_notifier *cec_notifier_get_conn (struct device *dev,const char *conn) {struct cec_notifier *n;mutex_lock (&cec_notifiers_lock);list_for_each_entry (n, &cec_notifiers, head) { -if (n->dev == dev) { +if (n->dev == dev && + (!conn || !strcmp (n->conn, conn))) {kref_get (&n->kref);mutex_unlock (&cec_notifiers_lock);return n;
@@ -46,6 +48,8 @@ struct cec_notifier *cec_notifier_get(struct device *dev)if (!n) goto unlock; n->dev = dev; +if (conn) + n->conn =kstrdup (conn,GFP_KERNEL ); n->phys_addr =CEC_PHYS_ADDR_INVALID ;mutex_init (&n->lock);kref_init (&n->kref);
@@ -54,7 +58,7 @@ struct cec_notifier *cec_notifier_get(struct device *dev)mutex_unlock (&cec_notifiers_lock);return n; } -EXPORT_SYMBOL_GPL (cec_notifier_get); +EXPORT_SYMBOL_GPL (cec_notifier_get_conn);static void cec_notifier_release (struct kref *kref) {
@@ -62,6 +66,7 @@ static void cec_notifier_release(struct kref *kref) container_of(kref, struct cec_notifier, kref);list_del (&n->head); +kfree (n->conn);kfree (n); }
include/media/cec-notifier.h +24 -3
@@ -20,8 +20,10 @@ struct cec_notifier;#if IS_REACHABLE (CONFIG_CEC_CORE ) &&IS_ENABLED (CONFIG_CEC_NOTIFIER )/** -* cec_notifier_get - find or create a new cec_notifier for the given device. +* cec_notifier_get_conn - find or create a new cec_notifier for the given +* device and connector tuple. * @dev: device that sends the events. +* @conn: the connector name from which the event occurs * * If a notifier for device @dev already exists, then increase the refcount * and return that notifier.
@@ -31,7 +33,8 @@ struct cec_notifier;* * Return NULL if the memory could not be allocated. */ -struct cec_notifier *cec_notifier_get (struct device *dev); +struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn);/** * cec_notifier_put - decrease refcount and delete when the refcount reaches 0.
@@ -85,7 +88,8 @@ void cec_register_cec_notifier(struct cec_adapter *adap, struct cec_notifier *notifier);#else -static inline struct cec_notifier *cec_notifier_get (struct device *dev) +static inline struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn) {/* A non-NULL pointer is expected on success */ return (struct cec_notifier *)0xdeadfeed ;
@@ -121,6 +125,23 @@ static inline void cec_register_cec_notifier(struct cec_adapter *adap,#endif /** +* cec_notifier_get - find or create a new cec_notifier for the given device. +* @dev: device that sends the events. +* +* If a notifier for device @dev already exists, then increase the refcount +* and return that notifier. +* +* If it doesn't exist, then allocate a new notifier struct and return a +* pointer to that new struct. +* +* Return NULL if the memory could not be allocated. +*/ +static inline struct cec_notifier *cec_notifier_get (struct device *dev) +{ +return cec_notifier_get_conn (dev,NULL ); +} + +/** * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID * * @n: the CEC notifier
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/5 drm/i915: hdmi: add CEC notifier to intel_hdmi
In reply to Neil ArmstrongThis patchs adds the cec_notifier feature to the intel_hdmi part of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.
--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)
drivers/gpu/drm/i915/Kconfig +1 -0
@@ -23,6 +23,7 @@ config DRM_I915 select SYNC_FILE select IOSF_MBI select CRC32 + select CEC_CORE if CEC_NOTIFIER help Choose this option if you have a system that has "Intel Graphics Media Accelerator" or "HD Graphics" integrated graphics,
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -39,6 +39,7 @@#include <drm/drm_dp_mst_helper.h> #include <drm/drm_rect.h> #include <drm/drm_atomic.h> +#include <media/cec-notifier.h> /** * __wait_for - magic wait macro
@@ -1001,6 +1002,7 @@ struct intel_hdmi {bool has_audio;bool rgb_quant_range_selectable;struct intel_connector *attached_connector; +struct cec_notifier *notifier; };struct intel_dp_mst_encoder ;
drivers/gpu/drm/i915/intel_hdmi.c +12 -0
@@ -1868,6 +1868,8 @@ intel_hdmi_set_edid(struct drm_connector *connector) connected = true; } +cec_notifier_set_phys_addr_from_edid (intel_hdmi->notifier, edid); +return connected; }
@@ -1876,6 +1878,7 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) {enum drm_connector_status status;struct drm_i915_private *dev_priv =to_i915 (connector->dev); +struct intel_hdmi *intel_hdmi =intel_attached_hdmi (connector);DRM_DEBUG_KMS ("[CONNECTOR:%d:%s]\n" , connector->base.id, connector->name);
@@ -1891,6 +1894,9 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); +if (status != connector_status_connected) +cec_notifier_phys_addr_invalidate (intel_hdmi->notifier); +return status; }
@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);
@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name); +if (!intel_hdmi->notifier) +DRM_DEBUG_KMS ("CEC notifier get failed\n" ); } void intel_hdmi_init(struct drm_i915_private *dev_priv,
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/5 mfd: cros-ec: Introduce CEC commands and events definitions.
In reply to Neil ArmstrongThe EC can expose a CEC bus, this patch adds the CEC related definitions needed by the cros-ec-cec driver.
Having a 16 byte mkbp event size makes it possible to send CEC messages from the EC to the AP directly inside the mkbp event instead of first doing a notification and then a read.
--- drivers/platform/chrome/cros_ec_proto.c | 42 +++++++++++++---- include/linux/mfd/cros_ec.h | 2 +- include/linux/mfd/cros_ec_commands.h | 80 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 10 deletions(-)
drivers/platform/chrome/cros_ec_proto.c +33 -9
@@ -504,29 +504,53 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, }EXPORT_SYMBOL (cros_ec_cmd_xfer_status); +static int get_next_event_xfer (struct cros_ec_device *ec_dev, +struct cros_ec_command *msg, +int version,uint32_t size) +{ +int ret; + + msg->version = version; + msg->command =EC_CMD_GET_NEXT_EVENT ; + msg->insize = size; + msg->outsize =0 ; + + ret =cros_ec_cmd_xfer (ec_dev, msg); +if (ret >0 ) { + ec_dev->event_size = ret -1 ; +memcpy (&ec_dev->event_data, msg->data, size); + } + +return ret; +} +static int get_next_event (struct cros_ec_device *ec_dev) {u8 buffer[sizeof (struct cros_ec_command ) +sizeof (ec_dev->event_data)];struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; +static int cmd_version =1 ;int ret; +BUILD_BUG_ON (sizeof (union ec_response_get_next_data_v1 ) !=16 ); +if (ec_dev->suspended) {dev_dbg (ec_dev->dev,"Device suspended.\n" );return -EHOSTDOWN ; } - msg->version =0 ; - msg->command =EC_CMD_GET_NEXT_EVENT ; - msg->insize =sizeof (ec_dev->event_data); - msg->outsize =0 ; +if (cmd_version ==1 ) { + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (ec_dev->event_data)); +if (ret !=EC_RES_INVALID_VERSION ) +return ret; - ret =cros_ec_cmd_xfer (ec_dev, msg); -if (ret >0 ) { - ec_dev->event_size = ret -1 ; -memcpy (&ec_dev->event_data, msg->data, -sizeof (ec_dev->event_data)); +/* Fallback to version 0 for future send attempts */ + cmd_version =0 ; } + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (struct ec_response_get_next_event )); +return ret; }
include/linux/mfd/cros_ec.h +1 -1
@@ -147,7 +147,7 @@ struct cros_ec_device {bool mkbp_event_supported;struct blocking_notifier_head event_notifier; -struct ec_response_get_next_event event_data; +struct ec_response_get_next_event_v1 event_data;int event_size;u32 host_event_wake_mask; };
include/linux/mfd/cros_ec_commands.h +80 -0
110 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/5 mfd: cros_ec_dev: Add CEC sub-device registration
In reply to Neil ArmstrongThe EC can expose a CEC bus, thus add the cros-ec-cec MFD sub-device when the CEC feature bit is present.
--- drivers/mfd/cros_ec_dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/mfd/cros_ec_dev.c +16 -0
@@ -383,6 +383,18 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); } +static void cros_ec_cec_register (struct cros_ec_dev *ec) +{ +int ret; +struct mfd_cell cec_cell = { + .name ="cros-ec-cec" , + }; + + ret =mfd_add_devices (ec->dev,0 , &cec_cell,1 ,NULL ,0 ,NULL ); +if (ret) +dev_err (ec->dev,"failed to add EC CEC\n" ); +} +static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;
@@ -422,6 +434,10 @@ static int ec_device_probe(struct platform_device *pdev)if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec); +/* check whether this EC handles CEC. */ +if (cros_ec_check_features (ec,EC_FEATURE_CEC )) +cros_ec_cec_register (ec); +/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 );
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/5 media: platform: Add Chrome OS EC CEC driver
In reply to Neil ArmstrongThe Chrome OS Embedded Controller can expose a CEC bus, this patch add the driver for such feature of the Embedded Controller.
This driver is part of the cros-ec MFD and will be add as a sub-device when the feature bit is exposed by the EC.
The controller will only handle a single logical address and handles all the messages retries and will only expose Success or Error.
The controller will be tied to the HDMI CEC notifier by using the platform DMI Data and the i915 device name and connector name.
--- drivers/media/platform/Kconfig | 11 + drivers/media/platform/Makefile | 2 + drivers/media/platform/cros-ec-cec/Makefile | 1 + drivers/media/platform/cros-ec-cec/cros-ec-cec.c | 335 +++++++++++++++++++++++ 4 files changed, 349 insertions(+) create mode 100644 drivers/media/platform/cros-ec-cec/Makefile create mode 100644 drivers/media/platform/cros-ec-cec/cros-ec-cec.c
drivers/media/platform/Kconfig +11 -0
@@ -546,6 +546,17 @@ menuconfig CEC_PLATFORM_DRIVERS if CEC_PLATFORM_DRIVERS +config VIDEO_CROS_EC_CEC + tristate "Chrome OS EC CEC driver" + depends on MFD_CROS_EC || COMPILE_TEST + select CEC_CORE + select CEC_NOTIFIER + ---help--- + If you say yes here you will get support for the + Chrome OS Embedded Controller's CEC. + The CEC bus is present in the HDMI connector and enables communication + between compatible devices. + config VIDEO_MESON_AO_CEC tristate "Amlogic Meson AO CEC driver" depends on ARCH_MESON || COMPILE_TEST
drivers/media/platform/Makefile +2 -0
@@ -92,3 +92,5 @@ obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom/camss-8x16/ obj-$(CONFIG_VIDEO_QCOM_VENUS) += qcom/venus/ obj-y += meson/ + +obj-y += cros-ec-cec/
drivers/media/platform/cros-ec-cec/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_VIDEO_CROS_EC_CEC) += cros-ec-cec.o
drivers/media/platform/cros-ec-cec/cros-ec-cec.c new file +335 -0
335 lines not on this page · raw message
Signature · 1 line
2.7.4
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for Add ChromeOS EC CEC Support (rev3)
In reply to Neil Armstrong== Series Details ==
== Series Details ==
Series: Add ChromeOS EC CEC Support (rev3)
URL : https://patchwork.freedesktop.org/series/43162/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 942485c481d1 media: cec-notifier: Get notifier by device and connector name 9a7496b1dc2b drm/i915: hdmi: add CEC notifier to intel_hdmi -:7: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #7: of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate
total: 0 errors, 1 warnings, 0 checks, 63 lines checkedc4b1822a051c mfd: cros-ec: Introduce CEC commands and events definitions. 989aec7a5772 mfd: cros_ec_dev: Add CEC sub-device registration 53858da0ac10 media: platform: Add Chrome OS EC CEC driver
-:28: WARNING:CONFIG_DESCRIPTION: prefer 'help' over '---help---' for new help texts #28: FILE: drivers/media/platform/Kconfig:549:
+config VIDEO_CROS_EC_CEC
-:53: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #53:
new file mode 100644
-:368: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #368: FILE: drivers/media/platform/cros-ec-cec/cros-ec-cec.c:304:
+ ret = blocking_notifier_chain_unregister(
total: 0 errors, 2 warnings, 1 checks, 358 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 1/5] media: cec-notifier: Get notifier by device and connector name
In reply to Neil ArmstrongQuoted 10 lines · Neil Armstrong
In non device-tree world, we can need to get the notifier by the driver name directly and eventually defer probe if not yet created.
This patch adds a variant of the get function by using the device name instead and will not create a notifier if not yet created.
But the i915 driver exposes at least 2 HDMI connectors, this patch also adds the possibility to add a connector name tied to the notifier device to form a tuple and associate different CEC controllers for each HDMI connectors.
The patch looks good, but I'm curious about this paragraph above.
Was this tested with devices with more than one HDMI output? Or only on laptops with a single physical HDMI output? If there are two or more outputs then I guess it is the HW designer that decides with output gets CEC support?
Regards,
Hans
Quoted 113 lines
Signed-off-by Neil Armstrong <[email protected]>--- drivers/media/cec/cec-notifier.c | 11 ++++++++--- include/media/cec-notifier.h | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-)drivers/media/cec/cec-notifier.c +8
-3@@ -21,6 +21,7 @@ struct cec_notifier {struct list_head head;struct kref kref;struct device *dev; +const char *conn;struct cec_adapter *cec_adap;void (*callback)(struct cec_adapter *adap,u16 pa);@@ -30,13 +31,14 @@ struct cec_notifier {static LIST_HEAD (cec_notifiers);static DEFINE_MUTEX (cec_notifiers_lock); -struct cec_notifier *cec_notifier_get (struct device *dev) +struct cec_notifier *cec_notifier_get_conn (struct device *dev,const char *conn) {struct cec_notifier *n;mutex_lock (&cec_notifiers_lock);list_for_each_entry (n, &cec_notifiers, head) { -if (n->dev == dev) { +if (n->dev == dev && + (!conn || !strcmp (n->conn, conn))) {kref_get (&n->kref);mutex_unlock (&cec_notifiers_lock);return n;@@ -46,6 +48,8 @@ struct cec_notifier *cec_notifier_get(struct device *dev)if (!n) goto unlock; n->dev = dev; +if (conn) + n->conn =kstrdup (conn,GFP_KERNEL ); n->phys_addr =CEC_PHYS_ADDR_INVALID ;mutex_init (&n->lock);kref_init (&n->kref);@@ -54,7 +58,7 @@ struct cec_notifier *cec_notifier_get(struct device *dev)mutex_unlock (&cec_notifiers_lock);return n; } -EXPORT_SYMBOL_GPL (cec_notifier_get); +EXPORT_SYMBOL_GPL (cec_notifier_get_conn);static void cec_notifier_release (struct kref *kref) {@@ -62,6 +66,7 @@ static void cec_notifier_release(struct kref *kref) container_of(kref, struct cec_notifier, kref);list_del (&n->head); +kfree (n->conn);kfree (n); }include/media/cec-notifier.h +17
-3@@ -20,8 +20,10 @@ struct cec_notifier;#if IS_REACHABLE (CONFIG_CEC_CORE ) &&IS_ENABLED (CONFIG_CEC_NOTIFIER )/** -* cec_notifier_get - find or create a new cec_notifier for the given device. +* cec_notifier_get_conn - find or create a new cec_notifier for the given +* device and connector tuple. * @dev: device that sends the events. +* @conn: the connector name from which the event occurs * * If a notifier for device @dev already exists, then increase the refcount * and return that notifier. @@ -31,7 +33,8 @@ struct cec_notifier;* * Return NULL if the memory could not be allocated. */ -struct cec_notifier *cec_notifier_get (struct device *dev); +struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn);/** * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. @@ -85,7 +88,8 @@ void cec_register_cec_notifier(struct cec_adapter *adap, struct cec_notifier *notifier);#else -static inline struct cec_notifier *cec_notifier_get (struct device *dev) +static inline struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn) {/* A non-NULL pointer is expected on success */ return (struct cec_notifier *)0xdeadfeed ;@@ -121,6 +125,23 @@ static inline void cec_register_cec_notifier(struct cec_adapter *adap,#endif /** +* cec_notifier_get - find or create a new cec_notifier for the given device. +* @dev: device that sends the events. +* +* If a notifier for device @dev already exists, then increase the refcount +* and return that notifier. +* +* If it doesn't exist, then allocate a new notifier struct and return a +* pointer to that new struct. +* +* Return NULL if the memory could not be allocated.
include/media/cec-notifier.h static inline void cec_register_cec_notifier(struct cec_adapter *adap, · line 147
Quoted 10 lines
include/media/cec-notifier.h +7
-0+*/ +static inline struct cec_notifier *cec_notifier_get (struct device *dev) +{ +return cec_notifier_get_conn (dev,NULL ); +} + +/** * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID * * @n: the CEC notifier
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
In reply to Neil ArmstrongQuoted 7 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>
Thanks!
Hans
Quoted 80 lines
--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)drivers/gpu/drm/i915/Kconfig +1
-0@@ -23,6 +23,7 @@ config DRM_I915 select SYNC_FILE select IOSF_MBI select CRC32 + select CEC_CORE if CEC_NOTIFIER help Choose this option if you have a system that has "Intel Graphics Media Accelerator" or "HD Graphics" integrated graphics,drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -39,6 +39,7 @@#include <drm/drm_dp_mst_helper.h> #include <drm/drm_rect.h> #include <drm/drm_atomic.h> +#include <media/cec-notifier.h> /** * __wait_for - magic wait macro @@ -1001,6 +1002,7 @@ struct intel_hdmi {bool has_audio;bool rgb_quant_range_selectable;struct intel_connector *attached_connector; +struct cec_notifier *notifier; };struct intel_dp_mst_encoder ;drivers/gpu/drm/i915/intel_hdmi.c +8
-0@@ -1868,6 +1868,8 @@ intel_hdmi_set_edid(struct drm_connector *connector) connected = true; } +cec_notifier_set_phys_addr_from_edid (intel_hdmi->notifier, edid); +return connected; }@@ -1876,6 +1878,7 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) {enum drm_connector_status status;struct drm_i915_private *dev_priv =to_i915 (connector->dev); +struct intel_hdmi *intel_hdmi =intel_attached_hdmi (connector);DRM_DEBUG_KMS ("[CONNECTOR:%d:%s]\n" , connector->base.id, connector->name);@@ -1891,6 +1894,9 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); +if (status != connector_status_connected) +cec_notifier_phys_addr_invalidate (intel_hdmi->notifier); +return status; }@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2375
Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +4
-0@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name); +if (!intel_hdmi->notifier) +DRM_DEBUG_KMS ("CEC notifier get failed\n" ); } void intel_hdmi_init(struct drm_i915_private *dev_priv,
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/5] mfd: cros-ec: Introduce CEC commands and events definitions.
In reply to Neil ArmstrongQuoted 40 lines · Neil Armstrong
The EC can expose a CEC bus, this patch adds the CEC related definitions needed by the cros-ec-cec driver.
Having a 16 byte mkbp event size makes it possible to send CEC messages from the EC to the AP directly inside the mkbp event instead of first doing a notification and then a read.Signed-off-by Stefan Adolfsson <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- drivers/platform/chrome/cros_ec_proto.c | 42 +++++++++++++---- include/linux/mfd/cros_ec.h | 2 +- include/linux/mfd/cros_ec_commands.h | 80 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 10 deletions(-)drivers/platform/chrome/cros_ec_proto.c +18
-0@@ -504,29 +504,53 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, }EXPORT_SYMBOL (cros_ec_cmd_xfer_status); +static int get_next_event_xfer (struct cros_ec_device *ec_dev, +struct cros_ec_command *msg, +int version,uint32_t size) +{ +int ret; + + msg->version = version; + msg->command =EC_CMD_GET_NEXT_EVENT ; + msg->insize = size; + msg->outsize =0 ; + + ret =cros_ec_cmd_xfer (ec_dev, msg); +if (ret >0 ) { + ec_dev->event_size = ret -1 ; +memcpy (&ec_dev->event_data, msg->data, size); + } + +return ret;
drivers/platform/chrome/cros_ec_proto.c int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, · line 534
Quoted 10 lines
drivers/platform/chrome/cros_ec_proto.c +4
-0+} +static int get_next_event (struct cros_ec_device *ec_dev) {u8 buffer[sizeof (struct cros_ec_command ) +sizeof (ec_dev->event_data)];struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; +static int cmd_version =1 ;int ret; +BUILD_BUG_ON (sizeof (union ec_response_get_next_data_v1 ) !=16 );
Use the define instead of hardcoding 16. I'm not really sure why you need this. If cec_message uses the right define for the array size (see my comment below), then this really can't go wrong, can it?
Quoted 103 lines
drivers/platform/chrome/cros_ec_proto.c +11
-9+if (ec_dev->suspended) {dev_dbg (ec_dev->dev,"Device suspended.\n" );return -EHOSTDOWN ; } - msg->version =0 ; - msg->command =EC_CMD_GET_NEXT_EVENT ; - msg->insize =sizeof (ec_dev->event_data); - msg->outsize =0 ; +if (cmd_version ==1 ) { + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (ec_dev->event_data)); +if (ret !=EC_RES_INVALID_VERSION ) +return ret; - ret =cros_ec_cmd_xfer (ec_dev, msg); -if (ret >0 ) { - ec_dev->event_size = ret -1 ; -memcpy (&ec_dev->event_data, msg->data, -sizeof (ec_dev->event_data)); +/* Fallback to version 0 for future send attempts */ + cmd_version =0 ; } + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (struct ec_response_get_next_event )); +return ret; }include/linux/mfd/cros_ec.h +1
-1@@ -147,7 +147,7 @@ struct cros_ec_device {bool mkbp_event_supported;struct blocking_notifier_head event_notifier; -struct ec_response_get_next_event event_data; +struct ec_response_get_next_event_v1 event_data;int event_size;u32 host_event_wake_mask; };include/linux/mfd/cros_ec_commands.h +27
-0@@ -804,6 +804,8 @@ enum ec_feature_code {EC_FEATURE_MOTION_SENSE_FIFO =24 ,/* EC has RTC feature that can be controlled by host commands */ EC_FEATURE_RTC =27 , +/* EC supports CEC commands */ + EC_FEATURE_CEC = 35, };#define EC_FEATURE_MASK_0 (event_code) (1UL << (event_code % 32))@@ -2078,6 +2080,12 @@ enum ec_mkbp_event {/* EC sent a sysrq command */ EC_MKBP_EVENT_SYSRQ =6 , +/* Notify the AP that something happened on CEC */ +EC_MKBP_CEC_EVENT =8 , + +/* Send an incoming CEC message to the AP */ +EC_MKBP_EVENT_CEC_MESSAGE =9 , +/* Number of MKBP events */ EC_MKBP_EVENT_COUNT, };@@ -2093,12 +2101,31 @@ union ec_response_get_next_data {uint32_t sysrq; } __packed; +union ec_response_get_next_data_v1 { +uint8_t key_matrix[16 ]; + +/* Unaligned */ +uint32_t host_event; + +uint32_t buttons; +uint32_t switches; +uint32_t sysrq; +uint32_t cec_events; +uint8_t cec_message[16 ]; +} __packed; +struct ec_response_get_next_event {uint8_t event_type;/* Followed by event data if any */ union ec_response_get_next_data data; } __packed; +struct ec_response_get_next_event_v1 { +uint8_t event_type; +/* Followed by event data if any */ +union ec_response_get_next_data_v1 data; +} __packed; +/* Bit indices for buttons and switches.*/ /* Buttons */ #define EC_MKBP_POWER_BUTTON 0
include/linux/mfd/cros_ec_commands.h struct ec_params_reboot_ec { · line 2864
Quoted 10 lines
include/linux/mfd/cros_ec_commands.h +7
-0@@ -2828,6 +2855,59 @@ struct ec_params_reboot_ec {/* Current version of ACPI memory address space */ #define EC_ACPI_MEM_VERSION_CURRENT 1 +/*****************************************************************************/ +/* +* HDMI CEC commands +* +* These commands are for sending and receiving message via HDMI CEC +*/ +#define MAX_CEC_MSG_LEN 16
Hmm, uapi/linux/cec.h already defines CEC_MAX_MSG_SIZE with the same value. Perhaps it is better to include linux/cec.h here instead of creating a second define?
And shouldn't this define also be used for the cec_message array above?
Regards,
Hans
Quoted 40 lines
include/linux/mfd/cros_ec_commands.h +39
-0+ +/* CEC message from the AP to be written on the CEC bus */ +#define EC_CMD_CEC_WRITE_MSG 0x00B8 + +/* Message to write to the CEC bus */ +struct ec_params_cec_write { +uint8_t msg[MAX_CEC_MSG_LEN ]; +} __packed; + +/* Set various CEC parameters */ +#define EC_CMD_CEC_SET 0x00BA + +struct ec_params_cec_set { +uint8_t cmd;/* enum cec_command */ +union { +uint8_t enable; +uint8_t address; + }; +} __packed; + +/* Read various CEC parameters */ +#define EC_CMD_CEC_GET 0x00BB + +struct ec_params_cec_get { +uint8_t cmd;/* enum cec_command */ +} __packed; + +struct ec_response_cec_get { +union { +uint8_t enable; +uint8_t address; + }; +} __packed; + +enum cec_command { +/* CEC reading, writing and events enable */ +CEC_CMD_ENABLE , +/* CEC logical address */ +CEC_CMD_LOGICAL_ADDRESS ,
include/linux/mfd/cros_ec_commands.h struct ec_params_reboot_ec { · line 2913
Quoted 10 lines
include/linux/mfd/cros_ec_commands.h +7
-0+}; + +/* Events from CEC to AP */ +enum mkbp_cec_event { +EC_MKBP_CEC_SEND_OK =1 <<0 , +EC_MKBP_CEC_SEND_FAILED =1 <<1 , +};/*****************************************************************************/ /*
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/5] mfd: cros_ec_dev: Add CEC sub-device registration
In reply to Neil ArmstrongQuoted 4 lines · Neil Armstrong
The EC can expose a CEC bus, thus add the cros-ec-cec MFD sub-device when the CEC feature bit is present.
Signed-off-by Neil Armstrong <[email protected]>
For what it is worth (not an MFD expert):
Thanks!
Hans
Quoted 29 lines
--- drivers/mfd/cros_ec_dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/mfd/cros_ec_dev.c +12
-0@@ -383,6 +383,18 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); } +static void cros_ec_cec_register (struct cros_ec_dev *ec) +{ +int ret; +struct mfd_cell cec_cell = { + .name ="cros-ec-cec" , + }; + + ret =mfd_add_devices (ec->dev,0 , &cec_cell,1 ,NULL ,0 ,NULL ); +if (ret) +dev_err (ec->dev,"failed to add EC CEC\n" ); +} +static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 443
Quoted 10 lines
drivers/mfd/cros_ec_dev.c +4
-0@@ -422,6 +434,10 @@ static int ec_device_probe(struct platform_device *pdev)if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec); +/* check whether this EC handles CEC. */ +if (cros_ec_check_features (ec,EC_FEATURE_CEC )) +cros_ec_cec_register (ec); +/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 );
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
In reply to Neil ArmstrongQuoted 86 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)drivers/gpu/drm/i915/Kconfig +1
-0@@ -23,6 +23,7 @@ config DRM_I915 select SYNC_FILE select IOSF_MBI select CRC32 + select CEC_CORE if CEC_NOTIFIER help Choose this option if you have a system that has "Intel Graphics Media Accelerator" or "HD Graphics" integrated graphics,drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -39,6 +39,7 @@#include <drm/drm_dp_mst_helper.h> #include <drm/drm_rect.h> #include <drm/drm_atomic.h> +#include <media/cec-notifier.h> /** * __wait_for - magic wait macro @@ -1001,6 +1002,7 @@ struct intel_hdmi {bool has_audio;bool rgb_quant_range_selectable;struct intel_connector *attached_connector; +struct cec_notifier *notifier; };struct intel_dp_mst_encoder ;drivers/gpu/drm/i915/intel_hdmi.c +8
-0@@ -1868,6 +1868,8 @@ intel_hdmi_set_edid(struct drm_connector *connector) connected = true; } +cec_notifier_set_phys_addr_from_edid (intel_hdmi->notifier, edid); +return connected; }@@ -1876,6 +1878,7 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) {enum drm_connector_status status;struct drm_i915_private *dev_priv =to_i915 (connector->dev); +struct intel_hdmi *intel_hdmi =intel_attached_hdmi (connector);DRM_DEBUG_KMS ("[CONNECTOR:%d:%s]\n" , connector->base.id, connector->name);@@ -1891,6 +1894,9 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); +if (status != connector_status_connected) +cec_notifier_phys_addr_invalidate (intel_hdmi->notifier); +return status; }@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2370
Quoted 5 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name);
What are we doing with the connector name here? Those are not actually guaranteed to be stable, and any change in the connector probe order may cause the name to change.
Quoted 12 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0+if (!intel_hdmi->notifier) +DRM_DEBUG_KMS ("CEC notifier get failed\n" ); } void intel_hdmi_init(struct drm_i915_private *dev_priv,Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 5/5] media: platform: Add Chrome OS EC CEC driver
In reply to Neil ArmstrongQuoted 14 lines · Neil Armstrong
The Chrome OS Embedded Controller can expose a CEC bus, this patch add the driver for such feature of the Embedded Controller.
This driver is part of the cros-ec MFD and will be add as a sub-device when the feature bit is exposed by the EC.
The controller will only handle a single logical address and handles all the messages retries and will only expose Success or Error.
The controller will be tied to the HDMI CEC notifier by using the platform DMI Data and the i915 device name and connector name.
Signed-off-by Neil Armstrong <[email protected]>---
<snip>
drivers/media/platform/cros-ec-cec/cros-ec-cec.c line 202
Quoted 5 lines
drivers/media/platform/cros-ec-cec/cros-ec-cec.c new file +5
-0+static SIMPLE_DEV_PM_OPS(cros_ec_cec_pm_ops, + cros_ec_cec_suspend, cros_ec_cec_resume); + +/* +* The Firmware only handles single CEC interface tied to a single HDMI
single CEC -> a single CEC
Quoted 1 line
+ * connector we specify along the DRM device name handling the HDMI output
along -> along with
drivers/media/platform/cros-ec-cec/cros-ec-cec.c line 212
Quoted 9 lines
+ */
drivers/media/platform/cros-ec-cec/cros-ec-cec.c new file +8
-0+ +struct cec_dmi_match { +char *sys_vendor; +char *product_name; +char *devname; +char *conn; +}; +
Looks good!
Regards,
Hans
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for Add ChromeOS EC CEC Support (rev3)
In reply to Neil Armstrong== Series Details ==
== Series Details ==
Series: Add ChromeOS EC CEC Support (rev3)
URL : https://patchwork.freedesktop.org/series/43162/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4186 -> Patchwork_9008 =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_9008 need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_9008, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43162/revisions/3/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_9008:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_gttfill@basic:
fi-pnv-d510: SKIP -> PASS== Known issues ==
Here are the changes found in Patchwork_9008 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c-frame-sequence:
fi-cfl-s3: PASS -> FAIL (fdo#103481)fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
== Participating hosts (41 -> 37) ==
Additional (1): fi-bxt-dsi
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-skl-6700hq
== Build changes ==
* Linux: CI_DRM_4186 -> Patchwork_9008
CI_DRM_4186: c03987223c762e4a61142f0a9be6027bb181cdfa @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4481: 94df67655566f18f05e599bb53a4090b598057f2 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9008: 53858da0ac10f9d6ad9a2f26e44d5a474e35d66e @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4481: 3ba0657bff4216d1ec7179935590261855f1651e @ git://anongit.freedesktop.org/piglit
== Linux commits ==
53858da0ac10 media: platform: Add Chrome OS EC CEC driver 989aec7a5772 mfd: cros_ec_dev: Add CEC sub-device registration c4b1822a051c mfd: cros-ec: Introduce CEC commands and events definitions. 9a7496b1dc2b drm/i915: hdmi: add CEC notifier to intel_hdmi 942485c481d1 media: cec-notifier: Get notifier by device and connector name
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9008/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 1/5] media: cec-notifier: Get notifier by device and connector name
In reply to Hans VerkuilQuoted 12 lines · Hans Verkuil
Quoted 10 lines · Neil Armstrong
In non device-tree world, we can need to get the notifier by the driver name directly and eventually defer probe if not yet created.
This patch adds a variant of the get function by using the device name instead and will not create a notifier if not yet created.
But the i915 driver exposes at least 2 HDMI connectors, this patch also adds the possibility to add a connector name tied to the notifier device to form a tuple and associate different CEC controllers for each HDMI connectors.
Quoted 6 lines
The patch looks good, but I'm curious about this paragraph above.
Was this tested with devices with more than one HDMI output? Or only on laptops with a single physical HDMI output? If there are two or more outputs then I guess it is the HW designer that decides with output gets CEC support?
The driver exposes 2 HDMI connectors (I suspect one is connected to the USB-C alt mode mux along the DP port), and only one connected has the CEC line connected to the Embedded Controller.
Neil
Quoted 120 lines
Regards,
Hans
Quoted 115 lines
Signed-off-by Neil Armstrong <[email protected]>--- drivers/media/cec/cec-notifier.c | 11 ++++++++--- include/media/cec-notifier.h | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-)drivers/media/cec/cec-notifier.c +8
-3@@ -21,6 +21,7 @@ struct cec_notifier {struct list_head head;struct kref kref;struct device *dev; +const char *conn;struct cec_adapter *cec_adap;void (*callback)(struct cec_adapter *adap,u16 pa);@@ -30,13 +31,14 @@ struct cec_notifier {static LIST_HEAD (cec_notifiers);static DEFINE_MUTEX (cec_notifiers_lock); -struct cec_notifier *cec_notifier_get (struct device *dev) +struct cec_notifier *cec_notifier_get_conn (struct device *dev,const char *conn) {struct cec_notifier *n;mutex_lock (&cec_notifiers_lock);list_for_each_entry (n, &cec_notifiers, head) { -if (n->dev == dev) { +if (n->dev == dev && + (!conn || !strcmp (n->conn, conn))) {kref_get (&n->kref);mutex_unlock (&cec_notifiers_lock);return n;@@ -46,6 +48,8 @@ struct cec_notifier *cec_notifier_get(struct device *dev)if (!n) goto unlock; n->dev = dev; +if (conn) + n->conn =kstrdup (conn,GFP_KERNEL ); n->phys_addr =CEC_PHYS_ADDR_INVALID ;mutex_init (&n->lock);kref_init (&n->kref);@@ -54,7 +58,7 @@ struct cec_notifier *cec_notifier_get(struct device *dev)mutex_unlock (&cec_notifiers_lock);return n; } -EXPORT_SYMBOL_GPL (cec_notifier_get); +EXPORT_SYMBOL_GPL (cec_notifier_get_conn);static void cec_notifier_release (struct kref *kref) {@@ -62,6 +66,7 @@ static void cec_notifier_release(struct kref *kref) container_of(kref, struct cec_notifier, kref);list_del (&n->head); +kfree (n->conn);kfree (n); }include/media/cec-notifier.h +20
-3@@ -20,8 +20,10 @@ struct cec_notifier;#if IS_REACHABLE (CONFIG_CEC_CORE ) &&IS_ENABLED (CONFIG_CEC_NOTIFIER )/** -* cec_notifier_get - find or create a new cec_notifier for the given device. +* cec_notifier_get_conn - find or create a new cec_notifier for the given +* device and connector tuple. * @dev: device that sends the events. +* @conn: the connector name from which the event occurs * * If a notifier for device @dev already exists, then increase the refcount * and return that notifier. @@ -31,7 +33,8 @@ struct cec_notifier;* * Return NULL if the memory could not be allocated. */ -struct cec_notifier *cec_notifier_get (struct device *dev); +struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn);/** * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. @@ -85,7 +88,8 @@ void cec_register_cec_notifier(struct cec_adapter *adap, struct cec_notifier *notifier);#else -static inline struct cec_notifier *cec_notifier_get (struct device *dev) +static inline struct cec_notifier *cec_notifier_get_conn (struct device *dev, +const char *conn) {/* A non-NULL pointer is expected on success */ return (struct cec_notifier *)0xdeadfeed ;@@ -121,6 +125,23 @@ static inline void cec_register_cec_notifier(struct cec_adapter *adap,#endif /** +* cec_notifier_get - find or create a new cec_notifier for the given device. +* @dev: device that sends the events. +* +* If a notifier for device @dev already exists, then increase the refcount +* and return that notifier. +* +* If it doesn't exist, then allocate a new notifier struct and return a +* pointer to that new struct. +* +* Return NULL if the memory could not be allocated. +*/ +static inline struct cec_notifier *cec_notifier_get (struct device *dev) +{
Quoted 9 lines
include/media/cec-notifier.h static inline void cec_register_cec_notifier(struct cec_adapter *adap, · line 147
Quoted 8 lines
include/media/cec-notifier.h +4
-0+return cec_notifier_get_conn (dev,NULL ); +} + +/** * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID * * @n: the CEC notifier
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/5] mfd: cros_ec_dev: Add CEC sub-device registration
In reply to Hans VerkuilHi Neil,
I suspect that this patch will conflict with some patches that will be queued for 4.18 that also introduces new devices, well, for now I don't see these merged in the Lee's tree.
Based on some reviews I got when I send a patch to this file ...
2018-05-15 17:29 GMT+02:00 Hans Verkuil <[email protected]>:
Quoted 26 lines · Neil Armstrong
Quoted 4 lines
The EC can expose a CEC bus, thus add the cros-ec-cec MFD sub-device when the CEC feature bit is present.
Signed-off-by Neil Armstrong <[email protected]>For what it is worth (not an MFD expert):
Acked-by Hans Verkuil <[email protected]>Thanks!
Hans
Quoted 12 lines
--- drivers/mfd/cros_ec_dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/mfd/cros_ec_dev.c +0
-0@@ -383,6 +383,18 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); }
Quoted 12 lines
drivers/mfd/cros_ec_dev.c static void cros_ec_sensors_register(struct cros_ec_dev *ec) · line 397
Quoted 12 lines
drivers/mfd/cros_ec_dev.c +12
-0+static void cros_ec_cec_register (struct cros_ec_dev *ec) +{ +int ret; +struct mfd_cell cec_cell = { + .name ="cros-ec-cec" , + }; + + ret =mfd_add_devices (ec->dev,0 , &cec_cell,1 ,NULL ,0 ,NULL ); +if (ret) +dev_err (ec->dev,"failed to add EC CEC\n" ); +} +
Do not create a single function to only call mfd_add_devices, instead do the following on top:
static const struct mfd_cell cros_ec_cec_cells[] = {
{ .name = "cros-ec-cec" }
};Quoted 11 lines
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 440
Quoted 11 lines
drivers/mfd/cros_ec_dev.c +4
-0static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;@@ -422,6 +434,10 @@ static int ec_device_probe(struct platform_device *pdev)if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec); +/* check whether this EC handles CEC. */ +if (cros_ec_check_features (ec,EC_FEATURE_CEC )) +cros_ec_cec_register (ec); +
and use PLATFORM_DEVID_AUTO and the ARRAY_SIZE macro, something like this.
/* Check whether this EC instance handles CEC */
if (cros_ec_check_features(ec, EC_FEATURE_CEC)) {
retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
cros_ec_cec_cells,
ARRAY_SIZE(cros_ec_cec_cells),
NULL, 0, NULL);
if (retval)
dev_err(ec->dev, "failed to add cros-ec-cec device: %d\n",
retval);
}Best regards,
Enric
Quoted 9 lines
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 443
Quoted 4 lines
drivers/mfd/cros_ec_dev.c +0
-0/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 );_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for Add ChromeOS EC CEC Support (rev3)
In reply to Neil Armstrong== Series Details ==
== Series Details ==
Series: Add ChromeOS EC CEC Support (rev3)
URL : https://patchwork.freedesktop.org/series/43162/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4186_full -> Patchwork_9008_full =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_9008_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_9008_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43162/revisions/3/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_9008_full:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_schedule@deep-bsd2:
shard-kbl: PASS -> SKIP +1
igt@pm_rc6_residency@rc6-accuracy:
shard-kbl: SKIP -> PASS== Known issues ==
Here are the changes found in Patchwork_9008_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_eio@in-flight-contexts-immediate:
shard-hsw: PASS -> DMESG-WARN (fdo#106523) +1
igt@gem_eio@in-flight-immediate:
shard-apl: PASS -> DMESG-WARN (fdo#106523) +2
igt@gem_eio@in-flight-internal-10ms:
shard-glk: PASS -> DMESG-WARN (fdo#106523) +2
igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
shard-hsw: PASS -> FAIL (fdo#103060)
igt@kms_flip@2x-flip-vs-expired-vblank:
shard-glk: PASS -> FAIL (fdo#105363)
igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
shard-hsw: PASS -> FAIL (fdo#102887)
shard-glk: PASS -> FAIL (fdo#105707)
igt@kms_flip@flip-vs-wf_vblank-interruptible:
shard-hsw: PASS -> FAIL (fdo#103928)
igt@kms_flip@modeset-vs-vblank-race:
shard-glk: PASS -> FAIL (fdo#103060)
igt@kms_setmode@basic:
shard-apl: PASS -> FAIL (fdo#99912)
==== Possible fixes ====
igt@drv_selftest@live_gtt:
shard-apl: INCOMPLETE (fdo#103927) -> PASS
igt@drv_suspend@debugfs-reader:
shard-snb: DMESG-WARN (fdo#102365) -> PASS
igt@gem_eio@in-flight-10ms:
shard-hsw: DMESG-WARN (fdo#106523) -> PASS
igt@gem_eio@in-flight-external:
shard-glk: DMESG-WARN (fdo#106523) -> PASS +2
igt@gem_eio@in-flight-internal-10ms:
shard-apl: DMESG-WARN (fdo#106523) -> PASS +2
igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
shard-glk: FAIL (fdo#105703) -> PASS
igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
shard-glk: FAIL (fdo#105454) -> PASS
igt@kms_flip@basic-flip-vs-modeset:
shard-hsw: DMESG-WARN (fdo#102614) -> PASS
igt@kms_flip@dpms-vs-vblank-race:
shard-hsw: FAIL (fdo#103060) -> PASS
igt@kms_flip@flip-vs-expired-vblank-interruptible:
shard-glk: FAIL (fdo#105363) -> PASS
igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-spr-indfb-draw-blt:
shard-glk: FAIL (fdo#103167, fdo#104724) -> PASS fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
fdo#105707 https://bugs.freedesktop.org/show_bug.cgi?id=105707
fdo#106523 https://bugs.freedesktop.org/show_bug.cgi?id=106523
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4186 -> Patchwork_9008
CI_DRM_4186: c03987223c762e4a61142f0a9be6027bb181cdfa @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4481: 94df67655566f18f05e599bb53a4090b598057f2 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9008: 53858da0ac10f9d6ad9a2f26e44d5a474e35d66e @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4481: 3ba0657bff4216d1ec7179935590261855f1651e @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9008/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
In reply to Ville SyrjäläHi Ville,
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)
[..]
Quoted 13 lines
Quoted 13 lines
}
drivers/gpu/drm/i915/intel_hdmi.c +2
-0@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );
Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2370
Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name);What are we doing with the connector name here? Those are not actually guaranteed to be stable, and any change in the connector probe order may cause the name to change.
The i915 driver can expose multiple HDMI connectors, but each connected will have a different EDID and CEC physical address, so we will need a different notifier for each connector.
The connector name is DRM dependent, but user-space actually uses this name for operations, so I supposed it was kind of stable.
Anyway, is there another stable id/name/whatever that can be used to make a name to distinguish the HDMI connectors ?
Neil
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0+if (!intel_hdmi->notifier) +DRM_DEBUG_KMS ("CEC notifier get failed\n" ); }
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c +0
-0void intel_hdmi_init(struct drm_i915_private *dev_priv,Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
Quoted 46 lines · Neil Armstrong
Hi Ville,
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)[..]
Quoted 13 lines
Quoted 13 lines
}
drivers/gpu/drm/i915/intel_hdmi.c +2
-0@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2370
Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name);What are we doing with the connector name here? Those are not actually guaranteed to be stable, and any change in the connector probe order may cause the name to change.
The i915 driver can expose multiple HDMI connectors, but each connected will have a different EDID and CEC physical address, so we will need a different notifier for each connector.
Quoted 5 lines
The connector name is DRM dependent, but user-space actually uses this name for operations, so I supposed it was kind of stable.
Anyway, is there another stable id/name/whatever that can be used to make a name to distinguish the HDMI connectors ?
Would "HDMI %c", port_name(port) be OK to use ?
Neil
Quoted 18 lines
Neil
Quoted 14 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0+if (!intel_hdmi->notifier) +DRM_DEBUG_KMS ("CEC notifier get failed\n" ); } void intel_hdmi_init(struct drm_i915_private *dev_priv,Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 4/5] mfd: cros_ec_dev: Add CEC sub-device registration
In reply to Enric Balletbo SerraHi Enric,
Quoted 5 lines · Enric Balletbo Serra
Hi Neil,
I suspect that this patch will conflict with some patches that will be queued for 4.18 that also introduces new devices, well, for now I don't see these merged in the Lee's tree.
Indeed, I found your patches, I'll rebase this one when Lee pushes them in his tree.
Quoted 46 lines
Based on some reviews I got when I send a patch to this file ...
2018-05-15 17:29 GMT+02:00 Hans Verkuil <[email protected]>:
Quoted 26 lines · Neil Armstrong
Quoted 4 lines
The EC can expose a CEC bus, thus add the cros-ec-cec MFD sub-device when the CEC feature bit is present.
Signed-off-by Neil Armstrong <[email protected]>For what it is worth (not an MFD expert):
Acked-by Hans Verkuil <[email protected]>Thanks!
Hans
Quoted 12 lines
--- drivers/mfd/cros_ec_dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/mfd/cros_ec_dev.c +0
-0@@ -383,6 +383,18 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); }Quoted 12 lines
drivers/mfd/cros_ec_dev.c static void cros_ec_sensors_register(struct cros_ec_dev *ec) · line 397
Quoted 12 lines
drivers/mfd/cros_ec_dev.c +12
-0+static void cros_ec_cec_register (struct cros_ec_dev *ec) +{ +int ret; +struct mfd_cell cec_cell = { + .name ="cros-ec-cec" , + }; + + ret =mfd_add_devices (ec->dev,0 , &cec_cell,1 ,NULL ,0 ,NULL ); +if (ret) +dev_err (ec->dev,"failed to add EC CEC\n" ); +} +Do not create a single function to only call
mfd_add_devices, instead do the following on top:
Quoted 3 lines
static const struct mfd_cell cros_ec_cec_cells[] = {
{ .name = "cros-ec-cec" }
};OK
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
drivers/mfd/cros_ec_dev.c +0
-0static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;@@ -422,6 +434,10 @@ static int ec_device_probe(struct platform_device *pdev)if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec);Quoted 4 lines
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 440
Quoted 4 lines
drivers/mfd/cros_ec_dev.c +4
-0+/* check whether this EC handles CEC. */ +if (cros_ec_check_features (ec,EC_FEATURE_CEC )) +cros_ec_cec_register (ec); +and use
PLATFORM_DEVID_AUTOand theARRAY_SIZEmacro, something like this./* Check whether this EC instance handles CEC */
Quoted 9 lines
if (cros_ec_check_features(ec, EC_FEATURE_CEC)) {
retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
cros_ec_cec_cells,
ARRAY_SIZE(cros_ec_cec_cells),
NULL, 0, NULL);
if (retval)
dev_err(ec->dev, "failed to add cros-ec-cec device: %d\n",
retval);
}Ok, like the RTC registration.
Thanks,
Neil
Quoted 13 lines
Best regards,
EnricQuoted 9 lines
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 443
Quoted 4 lines
drivers/mfd/cros_ec_dev.c +0
-0/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 );_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/5] mfd: cros-ec: Introduce CEC commands and events definitions.
In reply to Hans VerkuilHi Hans,
Quoted 50 lines · Hans Verkuil
Quoted 49 lines · Neil Armstrong
The EC can expose a CEC bus, this patch adds the CEC related definitions needed by the cros-ec-cec driver.
Having a 16 byte mkbp event size makes it possible to send CEC messages from the EC to the AP directly inside the mkbp event instead of first doing a notification and then a read.Signed-off-by Stefan Adolfsson <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- drivers/platform/chrome/cros_ec_proto.c | 42 +++++++++++++---- include/linux/mfd/cros_ec.h | 2 +- include/linux/mfd/cros_ec_commands.h | 80 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 10 deletions(-)drivers/platform/chrome/cros_ec_proto.c +21
-0@@ -504,29 +504,53 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, }EXPORT_SYMBOL (cros_ec_cmd_xfer_status); +static int get_next_event_xfer (struct cros_ec_device *ec_dev, +struct cros_ec_command *msg, +int version,uint32_t size) +{ +int ret; + + msg->version = version; + msg->command =EC_CMD_GET_NEXT_EVENT ; + msg->insize = size; + msg->outsize =0 ; + + ret =cros_ec_cmd_xfer (ec_dev, msg); +if (ret >0 ) { + ec_dev->event_size = ret -1 ; +memcpy (&ec_dev->event_data, msg->data, size); + } + +return ret; +} +static int get_next_event (struct cros_ec_device *ec_dev) {u8 buffer[sizeof (struct cros_ec_command ) +sizeof (ec_dev->event_data)];struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; +static int cmd_version =1 ;int ret;
Quoted 5 lines
drivers/platform/chrome/cros_ec_proto.c int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, · line 534
Quoted 1 line
drivers/platform/chrome/cros_ec_proto.c +1
-0+BUILD_BUG_ON (sizeof (union ec_response_get_next_data_v1 ) !=16 );Use the define instead of hardcoding 16. I'm not really sure why you need this. If
cec_messageuses the right define for the array size (see my comment below), then this really can't go wrong, can it?
This is taken from the chrome kernelk, to be sure the size is ok, but yes it should be 16, I'll see if I can drop this.
Quoted 119 lines
Quoted 104 lines
drivers/platform/chrome/cros_ec_proto.c +11
-9+if (ec_dev->suspended) {dev_dbg (ec_dev->dev,"Device suspended.\n" );return -EHOSTDOWN ; } - msg->version =0 ; - msg->command =EC_CMD_GET_NEXT_EVENT ; - msg->insize =sizeof (ec_dev->event_data); - msg->outsize =0 ; +if (cmd_version ==1 ) { + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (ec_dev->event_data)); +if (ret !=EC_RES_INVALID_VERSION ) +return ret; - ret =cros_ec_cmd_xfer (ec_dev, msg); -if (ret >0 ) { - ec_dev->event_size = ret -1 ; -memcpy (&ec_dev->event_data, msg->data, -sizeof (ec_dev->event_data)); +/* Fallback to version 0 for future send attempts */ + cmd_version =0 ; } + ret =get_next_event_xfer (ec_dev, msg, cmd_version, +sizeof (struct ec_response_get_next_event )); +return ret; }include/linux/mfd/cros_ec.h +1
-1@@ -147,7 +147,7 @@ struct cros_ec_device {bool mkbp_event_supported;struct blocking_notifier_head event_notifier; -struct ec_response_get_next_event event_data; +struct ec_response_get_next_event_v1 event_data;int event_size;u32 host_event_wake_mask; };include/linux/mfd/cros_ec_commands.h +27
-0@@ -804,6 +804,8 @@ enum ec_feature_code {EC_FEATURE_MOTION_SENSE_FIFO =24 ,/* EC has RTC feature that can be controlled by host commands */ EC_FEATURE_RTC =27 , +/* EC supports CEC commands */ + EC_FEATURE_CEC = 35, };#define EC_FEATURE_MASK_0 (event_code) (1UL << (event_code % 32))@@ -2078,6 +2080,12 @@ enum ec_mkbp_event {/* EC sent a sysrq command */ EC_MKBP_EVENT_SYSRQ =6 , +/* Notify the AP that something happened on CEC */ +EC_MKBP_CEC_EVENT =8 , + +/* Send an incoming CEC message to the AP */ +EC_MKBP_EVENT_CEC_MESSAGE =9 , +/* Number of MKBP events */ EC_MKBP_EVENT_COUNT, };@@ -2093,12 +2101,31 @@ union ec_response_get_next_data {uint32_t sysrq; } __packed; +union ec_response_get_next_data_v1 { +uint8_t key_matrix[16 ]; + +/* Unaligned */ +uint32_t host_event; + +uint32_t buttons; +uint32_t switches; +uint32_t sysrq; +uint32_t cec_events; +uint8_t cec_message[16 ]; +} __packed; +struct ec_response_get_next_event {uint8_t event_type;/* Followed by event data if any */ union ec_response_get_next_data data; } __packed; +struct ec_response_get_next_event_v1 { +uint8_t event_type; +/* Followed by event data if any */ +union ec_response_get_next_data_v1 data; +} __packed; +/* Bit indices for buttons and switches.*/ /* Buttons */ #define EC_MKBP_POWER_BUTTON 0include/linux/mfd/cros_ec_commands.h struct ec_params_reboot_ec { · line 2864
Quoted 10 lines
include/linux/mfd/cros_ec_commands.h +7
-0@@ -2828,6 +2855,59 @@ struct ec_params_reboot_ec {/* Current version of ACPI memory address space */ #define EC_ACPI_MEM_VERSION_CURRENT 1 +/*****************************************************************************/ +/* +* HDMI CEC commands +* +* These commands are for sending and receiving message via HDMI CEC +*/ +#define MAX_CEC_MSG_LEN 16Hmm,
uapi/linux/cec.halready definesCEC_MAX_MSG_SIZEwith the same value. Perhaps it is better to includelinux/cec.hhere instead of creating a second define?
Quoted 1 line
And shouldn't this define also be used for the
cec_messagearray above?
These defines are tied to the Embedded Controller API, so it may be goog to keep them separated from the rest of the Linux APO, I'll see about using the define in the event struct, but I think they want to have a formal array size using a number.
Neil
Quoted 52 lines
Regards,
Hans
Quoted 47 lines
include/linux/mfd/cros_ec_commands.h +46
-0+ +/* CEC message from the AP to be written on the CEC bus */ +#define EC_CMD_CEC_WRITE_MSG 0x00B8 + +/* Message to write to the CEC bus */ +struct ec_params_cec_write { +uint8_t msg[MAX_CEC_MSG_LEN ]; +} __packed; + +/* Set various CEC parameters */ +#define EC_CMD_CEC_SET 0x00BA + +struct ec_params_cec_set { +uint8_t cmd;/* enum cec_command */ +union { +uint8_t enable; +uint8_t address; + }; +} __packed; + +/* Read various CEC parameters */ +#define EC_CMD_CEC_GET 0x00BB + +struct ec_params_cec_get { +uint8_t cmd;/* enum cec_command */ +} __packed; + +struct ec_response_cec_get { +union { +uint8_t enable; +uint8_t address; + }; +} __packed; + +enum cec_command { +/* CEC reading, writing and events enable */ +CEC_CMD_ENABLE , +/* CEC logical address */ +CEC_CMD_LOGICAL_ADDRESS , +}; + +/* Events from CEC to AP */ +enum mkbp_cec_event { +EC_MKBP_CEC_SEND_OK =1 <<0 , +EC_MKBP_CEC_SEND_FAILED =1 <<1 , +};
Quoted 4 lines
include/linux/mfd/cros_ec_commands.h struct ec_params_reboot_ec { · line 2913
Quoted 3 lines
include/linux/mfd/cros_ec_commands.h +0
-0/*****************************************************************************/ /*
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
In reply to Neil ArmstrongQuoted 47 lines · Neil Armstrong
Quoted 46 lines · Neil Armstrong
Hi Ville,
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)[..]
Quoted 13 lines
Quoted 13 lines
}
drivers/gpu/drm/i915/intel_hdmi.c +2
-0@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2370
Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name);What are we doing with the connector name here? Those are not actually guaranteed to be stable, and any change in the connector probe order may cause the name to change.
The i915 driver can expose multiple HDMI connectors, but each connected will have a different EDID and CEC physical address, so we will need a different notifier for each connector.
Quoted 7 lines
Quoted 5 lines
The connector name is DRM dependent, but user-space actually uses this name for operations, so I supposed it was kind of stable.
Anyway, is there another stable id/name/whatever that can be used to make a name to distinguish the HDMI connectors ?
Would "HDMI %c",
port_name(port)be OK to use ?
Yeah, something like seems like a reasonable approach. That does mean we have to be a little careful with changing enum port or port_name() in the future, but I guess we could just add a small function to generated the name/id specifically for this thing.
We're also going to have to think what to do with enum port and port_name() on ICL+ though. There we won't just have A-F but also TC1-TC<n>. Hmm. Looks like what we have for those ports in our codebase ATM is a bit wonky since we haven't even changed port_name() to give us the TC<n> type names.
Also we might not want "HDMI" in the identifier since the physical port is not HDMI specific. There are different things we could call these but I think we could just go with a generic "Port A-F" and "Port TC1-TC<n>" approach. I think something like that should work fine for current and upcoming hardware. And in theory that could then be used for other things as well which need a stable identifier.
Oh, and now I recall that input subsystem at least has some kind of "physical path" property on devices. So I guess what we're dicussing is a somewhat similar idea. I think input drivers generally include the pci/usb/etc. device in the path as well. Even though we currently only ever have the one pci device it would seem like decent idea to include that information in our identifiers as well. Or what do you think?
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v2 2/5] drm/i915: hdmi: add CEC notifier to intel_hdmi
Hi Ville,
Quoted 75 lines · Ville Syrjälä
Quoted 47 lines · Neil Armstrong
Quoted 46 lines · Neil Armstrong
Hi Ville,
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Neil Armstrong
This patchs adds the
cec_notifierfeature to theintel_hdmipart of the i915 DRM driver. It uses the HDMI DRM connector name to differentiate between each HDMI ports.
The changes will allow the i915 HDMI code to notify EDID and HPD changes to an eventual CEC adapter.Signed-off-by Neil Armstrong <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)[..]
Quoted 13 lines
Quoted 13 lines
}
drivers/gpu/drm/i915/intel_hdmi.c +2
-0@@ -2031,6 +2037,8 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,static void intel_hdmi_destroy (struct drm_connector *connector) { +if (intel_attached_hdmi (connector)->notifier) +cec_notifier_put (intel_attached_hdmi (connector)->notifier);kfree (to_intel_connector (connector)->detect_edid);drm_connector_cleanup (connector);kfree (connector);@@ -2358,6 +2366,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,u32 temp =I915_READ (PEG_BAND_GAP_DATA );Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, · line 2370
Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +2
-0I915_WRITE (PEG_BAND_GAP_DATA , (temp & ~0xf ) |0xd ); } + + intel_hdmi->notifier =cec_notifier_get_conn (dev->dev, connector->name);What are we doing with the connector name here? Those are not actually guaranteed to be stable, and any change in the connector probe order may cause the name to change.
The i915 driver can expose multiple HDMI connectors, but each connected will have a different EDID and CEC physical address, so we will need a different notifier for each connector.
Quoted 7 lines
Quoted 5 lines
The connector name is DRM dependent, but user-space actually uses this name for operations, so I supposed it was kind of stable.
Anyway, is there another stable id/name/whatever that can be used to make a name to distinguish the HDMI connectors ?
Would "HDMI %c",
port_name(port)be OK to use ?Yeah, something like seems like a reasonable approach. That does mean we have to be a little careful with changing enum port or
port_name()in the future, but I guess we could just add a small function to generated the name/id specifically for this thing.We're also going to have to think what to do with enum port and
port_name()on ICL+ though. There we won't just have A-F but also TC1-TC<n>. Hmm. Looks like what we have for those ports in our codebase ATM is a bit wonky since we haven't even changedport_name()to give us the TC<n> type names.Also we might not want "HDMI" in the identifier since the physical port is not HDMI specific. There are different things we could call these but I think we could just go with a generic "Port A-F" and "Port TC1-TC<n>" approach. I think something like that should work fine for current and upcoming hardware. And in theory that could then be used for other things as well which need a stable identifier.
Quoted 8 lines
Oh, and now I recall that input subsystem at least has some kind of "physical path" property on devices. So I guess what we're dicussing is a somewhat similar idea. I think input drivers generally include the pci/usb/etc. device in the path as well. Even though we currently only ever have the one pci device it would seem like decent idea to include that information in our identifiers as well. Or what do you think?
Thanks for the clarifications !
Having a "Port <id>" will be great indeed, no need to specify HDMI since only HDMI connectors will get a CEC notifier anyway.
The issue is that port_name() returns a character, which is lame. Would it be acceptable to introduce a :
const char *port_identifier(struct drm_i915_private *dev_priv,
enum port port)
{
char *id = devm_kzalloc(dev_priv->drm->dev, 16, GFP_KERNEL);
if (id)
return NULL;
snprintf("Port %c", port_name(port));
return id;
}and use the result of this for the cec_notifier connector name ?
Neil
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
kbuild test robot
build botRe: [Intel-gfx] [PATCH v2 5/5] media: platform: Add Chrome OS EC CEC driver
In reply to Neil ArmstrongI love your patch! Yet something to improve:
Hi Neil,
I love your patch! Yet something to improve:
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Neil-Armstrong/Add-ChromeOS-EC-CEC-Support/20180516-180519 base: git://linuxtv.org/media_tree.git master config: m68k-allmodconfig (attached as .config) compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k
All errors (new ones prefixed by >>):
drivers/media//platform/cros-ec-cec/cros-ec-cec.c: In function 'cros_ec_cec_get_notifier':
>> drivers/media//platform/cros-ec-cec/cros-ec-cec.c:231:33: error: 'pci_bus_type' undeclared (first use in this function); did you mean 'pci_pcie_type'?
d = bus_find_device_by_name(&pci_bus_type, NULL,
^~~~~~~~~~~~
pci_pcie_type
drivers/media//platform/cros-ec-cec/cros-ec-cec.c:231:33: note: each undeclared identifier is reported only once for each function it appears in
vim +231 drivers/media//platform/cros-ec-cec/cros-ec-cec.c
217
218 static int cros_ec_cec_get_notifier(struct device *dev,
219 struct cec_notifier **notify)
220 {
221 int i;
222
223 for (i = 0 ; i < ARRAY_SIZE(cec_dmi_match_table) ; ++i) {
224 const struct cec_dmi_match *m = &cec_dmi_match_table[i];
225
226 if (dmi_match(DMI_SYS_VENDOR, m->sys_vendor) &&
227 dmi_match(DMI_PRODUCT_NAME, m->product_name)) {
228 struct device *d;
229
230 /* Find the device, bail out if not yet registered */
> 231 d = bus_find_device_by_name(&pci_bus_type, NULL,
232 m->devname);
233 if (!d)
234 return -EPROBE_DEFER;
235
236 *notify = cec_notifier_get_conn(d, m->conn);
237 return 0;
238 }
239 }
240
241 /* Hardware support must be added in the cec_dmi_match_table */
242 dev_warn(dev, "CEC notifier not configured for this hardware\n");
243
244 return -ENODEV;
245 }
246
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx