Commit ae85b0df authored by Dariusz Marcinkiewicz's avatar Dariusz Marcinkiewicz Committed by Hans Verkuil

drm_dp_cec: add connector info support.

Pass the connector info to the CEC adapter. This makes it possible
to associate the CEC adapter with the corresponding drm connector.
Signed-off-by: default avatarDariusz Marcinkiewicz <darekm@google.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Link: https://patchwork.freedesktop.org/patch/msgid/20190814104520.6001-2-darekm@google.com
parent 3e93bc2a
...@@ -416,7 +416,7 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm, ...@@ -416,7 +416,7 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
drm_dp_aux_register(&aconnector->dm_dp_aux.aux); drm_dp_aux_register(&aconnector->dm_dp_aux.aux);
drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux, drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux,
aconnector->base.name, dm->adev->dev); &aconnector->base);
aconnector->mst_mgr.cbs = &dm_mst_cbs; aconnector->mst_mgr.cbs = &dm_mst_cbs;
drm_dp_mst_topology_mgr_init( drm_dp_mst_topology_mgr_init(
&aconnector->mst_mgr, &aconnector->mst_mgr,
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <drm/drm_connector.h>
#include <drm/drm_dp_helper.h> #include <drm/drm_dp_helper.h>
#include <drm/drmP.h>
#include <media/cec.h> #include <media/cec.h>
/* /*
...@@ -295,7 +297,10 @@ static void drm_dp_cec_unregister_work(struct work_struct *work) ...@@ -295,7 +297,10 @@ static void drm_dp_cec_unregister_work(struct work_struct *work)
*/ */
void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid) void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
{ {
u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD; struct drm_connector *connector = aux->cec.connector;
u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD |
CEC_CAP_CONNECTOR_INFO;
struct cec_connector_info conn_info;
unsigned int num_las = 1; unsigned int num_las = 1;
u8 cap; u8 cap;
...@@ -344,13 +349,17 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid) ...@@ -344,13 +349,17 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
/* Create a new adapter */ /* Create a new adapter */
aux->cec.adap = cec_allocate_adapter(&drm_dp_cec_adap_ops, aux->cec.adap = cec_allocate_adapter(&drm_dp_cec_adap_ops,
aux, aux->cec.name, cec_caps, aux, connector->name, cec_caps,
num_las); num_las);
if (IS_ERR(aux->cec.adap)) { if (IS_ERR(aux->cec.adap)) {
aux->cec.adap = NULL; aux->cec.adap = NULL;
goto unlock; goto unlock;
} }
if (cec_register_adapter(aux->cec.adap, aux->cec.parent)) {
cec_fill_conn_info_from_drm(&conn_info, connector);
cec_s_conn_info(aux->cec.adap, &conn_info);
if (cec_register_adapter(aux->cec.adap, connector->dev->dev)) {
cec_delete_adapter(aux->cec.adap); cec_delete_adapter(aux->cec.adap);
aux->cec.adap = NULL; aux->cec.adap = NULL;
} else { } else {
...@@ -406,22 +415,20 @@ EXPORT_SYMBOL(drm_dp_cec_unset_edid); ...@@ -406,22 +415,20 @@ EXPORT_SYMBOL(drm_dp_cec_unset_edid);
/** /**
* drm_dp_cec_register_connector() - register a new connector * drm_dp_cec_register_connector() - register a new connector
* @aux: DisplayPort AUX channel * @aux: DisplayPort AUX channel
* @name: name of the CEC device * @connector: drm connector
* @parent: parent device
* *
* A new connector was registered with associated CEC adapter name and * A new connector was registered with associated CEC adapter name and
* CEC adapter parent device. After registering the name and parent * CEC adapter parent device. After registering the name and parent
* drm_dp_cec_set_edid() is called to check if the connector supports * drm_dp_cec_set_edid() is called to check if the connector supports
* CEC and to register a CEC adapter if that is the case. * CEC and to register a CEC adapter if that is the case.
*/ */
void drm_dp_cec_register_connector(struct drm_dp_aux *aux, const char *name, void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
struct device *parent) struct drm_connector *connector)
{ {
WARN_ON(aux->cec.adap); WARN_ON(aux->cec.adap);
if (WARN_ON(!aux->transfer)) if (WARN_ON(!aux->transfer))
return; return;
aux->cec.name = name; aux->cec.connector = connector;
aux->cec.parent = parent;
INIT_DELAYED_WORK(&aux->cec.unregister_work, INIT_DELAYED_WORK(&aux->cec.unregister_work,
drm_dp_cec_unregister_work); drm_dp_cec_unregister_work);
} }
......
...@@ -5693,7 +5693,6 @@ static int ...@@ -5693,7 +5693,6 @@ static int
intel_dp_connector_register(struct drm_connector *connector) intel_dp_connector_register(struct drm_connector *connector)
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_device *dev = connector->dev;
int ret; int ret;
ret = intel_connector_register(connector); ret = intel_connector_register(connector);
...@@ -5708,8 +5707,7 @@ intel_dp_connector_register(struct drm_connector *connector) ...@@ -5708,8 +5707,7 @@ intel_dp_connector_register(struct drm_connector *connector)
intel_dp->aux.dev = connector->kdev; intel_dp->aux.dev = connector->kdev;
ret = drm_dp_aux_register(&intel_dp->aux); ret = drm_dp_aux_register(&intel_dp->aux);
if (!ret) if (!ret)
drm_dp_cec_register_connector(&intel_dp->aux, drm_dp_cec_register_connector(&intel_dp->aux, connector);
connector->name, dev->dev);
return ret; return ret;
} }
......
...@@ -1416,8 +1416,7 @@ nouveau_connector_create(struct drm_device *dev, ...@@ -1416,8 +1416,7 @@ nouveau_connector_create(struct drm_device *dev,
switch (type) { switch (type) {
case DRM_MODE_CONNECTOR_DisplayPort: case DRM_MODE_CONNECTOR_DisplayPort:
case DRM_MODE_CONNECTOR_eDP: case DRM_MODE_CONNECTOR_eDP:
drm_dp_cec_register_connector(&nv_connector->aux, drm_dp_cec_register_connector(&nv_connector->aux, connector);
connector->name, dev->dev);
break; break;
} }
......
...@@ -1230,20 +1230,19 @@ struct drm_dp_aux_msg { ...@@ -1230,20 +1230,19 @@ struct drm_dp_aux_msg {
struct cec_adapter; struct cec_adapter;
struct edid; struct edid;
struct drm_connector;
/** /**
* struct drm_dp_aux_cec - DisplayPort CEC-Tunneling-over-AUX * struct drm_dp_aux_cec - DisplayPort CEC-Tunneling-over-AUX
* @lock: mutex protecting this struct * @lock: mutex protecting this struct
* @adap: the CEC adapter for CEC-Tunneling-over-AUX support. * @adap: the CEC adapter for CEC-Tunneling-over-AUX support.
* @name: name of the CEC adapter * @connector: the connector this CEC adapter is associated with
* @parent: parent device of the CEC adapter
* @unregister_work: unregister the CEC adapter * @unregister_work: unregister the CEC adapter
*/ */
struct drm_dp_aux_cec { struct drm_dp_aux_cec {
struct mutex lock; struct mutex lock;
struct cec_adapter *adap; struct cec_adapter *adap;
const char *name; struct drm_connector *connector;
struct device *parent;
struct delayed_work unregister_work; struct delayed_work unregister_work;
}; };
...@@ -1451,8 +1450,8 @@ drm_dp_has_quirk(const struct drm_dp_desc *desc, enum drm_dp_quirk quirk) ...@@ -1451,8 +1450,8 @@ drm_dp_has_quirk(const struct drm_dp_desc *desc, enum drm_dp_quirk quirk)
#ifdef CONFIG_DRM_DP_CEC #ifdef CONFIG_DRM_DP_CEC
void drm_dp_cec_irq(struct drm_dp_aux *aux); void drm_dp_cec_irq(struct drm_dp_aux *aux);
void drm_dp_cec_register_connector(struct drm_dp_aux *aux, const char *name, void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
struct device *parent); struct drm_connector *connector);
void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux); void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux);
void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid); void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid);
void drm_dp_cec_unset_edid(struct drm_dp_aux *aux); void drm_dp_cec_unset_edid(struct drm_dp_aux *aux);
...@@ -1461,9 +1460,9 @@ static inline void drm_dp_cec_irq(struct drm_dp_aux *aux) ...@@ -1461,9 +1460,9 @@ static inline void drm_dp_cec_irq(struct drm_dp_aux *aux)
{ {
} }
static inline void drm_dp_cec_register_connector(struct drm_dp_aux *aux, static inline void
const char *name, drm_dp_cec_register_connector(struct drm_dp_aux *aux,
struct device *parent) struct drm_connector *connector)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment