diff mbox series

[4/6] drm/cec: add drm_dp_cec_attach() as the non-edid version of set edid

Message ID f8ed9b38fd2ebcd8344a1889a6c0f288969454ea.1692884619.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm, cec and edid updates | expand

Commit Message

Jani Nikula Aug. 24, 2023, 1:46 p.m. UTC
Connectors have source physical address available in display
info. There's no need to parse the EDID again for this. Add
drm_dp_cec_attach() to do this.

Seems like the set_edid/unset_edid naming is a bit specific now that
there's no need to pass the EDID at all, so aim for attach/detach going
forward.

Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/display/drm_dp_cec.c | 22 +++++++++++++++++++---
 include/drm/display/drm_dp_helper.h  |  6 ++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

Comments

kernel test robot Aug. 25, 2023, 11:23 a.m. UTC | #1
Hi Jani,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm/drm-next next-20230825]
[cannot apply to drm-intel/for-linux-next-fixes drm-misc/drm-misc-next linus/master v6.5-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-edid-add-drm_edid_is_digital/20230824-220926
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/f8ed9b38fd2ebcd8344a1889a6c0f288969454ea.1692884619.git.jani.nikula%40intel.com
patch subject: [Intel-gfx] [PATCH 4/6] drm/cec: add drm_dp_cec_attach() as the non-edid version of set edid
config: nios2-randconfig-r036-20230824 (https://download.01.org/0day-ci/archive/20230825/202308251937.G5ETiCfF-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230825/202308251937.G5ETiCfF-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308251937.G5ETiCfF-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gpu/drm/display/drm_dp_cec.c: In function 'drm_dp_cec_attach':
>> drivers/gpu/drm/display/drm_dp_cec.c:342:41: error: 'adap' undeclared (first use in this function)
     342 |                         cec_s_phys_addr(adap, source_physical_address, false);
         |                                         ^~~~
   drivers/gpu/drm/display/drm_dp_cec.c:342:41: note: each undeclared identifier is reported only once for each function it appears in
   drivers/gpu/drm/display/drm_dp_cec.c: In function 'drm_dp_cec_set_edid':
>> drivers/gpu/drm/display/drm_dp_cec.c:388:25: error: invalid use of undefined type 'const struct edid'
     388 |         if (edid && edid->extensions)
         |                         ^~
>> drivers/gpu/drm/display/drm_dp_cec.c:389:17: error: 'pa' undeclared (first use in this function)
     389 |                 pa = cec_get_edid_phys_addr((const u8 *)edid,
         |                 ^~
>> drivers/gpu/drm/display/drm_dp_cec.c:390:45: error: 'EDID_LENGTH' undeclared (first use in this function)
     390 |                                             EDID_LENGTH * (edid->extensions + 1), NULL);
         |                                             ^~~~~~~~~~~
   drivers/gpu/drm/display/drm_dp_cec.c:390:64: error: invalid use of undefined type 'const struct edid'
     390 |                                             EDID_LENGTH * (edid->extensions + 1), NULL);
         |                                                                ^~


vim +/adap +342 drivers/gpu/drm/display/drm_dp_cec.c

   293	
   294	/*
   295	 * A new EDID is set. If there is no CEC adapter, then create one. If
   296	 * there was a CEC adapter, then check if the CEC adapter properties
   297	 * were unchanged and just update the CEC physical address. Otherwise
   298	 * unregister the old CEC adapter and create a new one.
   299	 */
   300	void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
   301	{
   302		struct drm_connector *connector = aux->cec.connector;
   303		u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD |
   304			       CEC_CAP_CONNECTOR_INFO;
   305		struct cec_connector_info conn_info;
   306		unsigned int num_las = 1;
   307		u8 cap;
   308	
   309		/* No transfer function was set, so not a DP connector */
   310		if (!aux->transfer)
   311			return;
   312	
   313	#ifndef CONFIG_MEDIA_CEC_RC
   314		/*
   315		 * CEC_CAP_RC is part of CEC_CAP_DEFAULTS, but it is stripped by
   316		 * cec_allocate_adapter() if CONFIG_MEDIA_CEC_RC is undefined.
   317		 *
   318		 * Do this here as well to ensure the tests against cec_caps are
   319		 * correct.
   320		 */
   321		cec_caps &= ~CEC_CAP_RC;
   322	#endif
   323		cancel_delayed_work_sync(&aux->cec.unregister_work);
   324	
   325		mutex_lock(&aux->cec.lock);
   326		if (!drm_dp_cec_cap(aux, &cap)) {
   327			/* CEC is not supported, unregister any existing adapter */
   328			cec_unregister_adapter(aux->cec.adap);
   329			aux->cec.adap = NULL;
   330			goto unlock;
   331		}
   332	
   333		if (cap & DP_CEC_SNOOPING_CAPABLE)
   334			cec_caps |= CEC_CAP_MONITOR_ALL;
   335		if (cap & DP_CEC_MULTIPLE_LA_CAPABLE)
   336			num_las = CEC_MAX_LOG_ADDRS;
   337	
   338		if (aux->cec.adap) {
   339			if (aux->cec.adap->capabilities == cec_caps &&
   340			    aux->cec.adap->available_log_addrs == num_las) {
   341				/* Unchanged, so just set the phys addr */
 > 342				cec_s_phys_addr(adap, source_physical_address, false);
   343				goto unlock;
   344			}
   345			/*
   346			 * The capabilities changed, so unregister the old
   347			 * adapter first.
   348			 */
   349			cec_unregister_adapter(aux->cec.adap);
   350		}
   351	
   352		/* Create a new adapter */
   353		aux->cec.adap = cec_allocate_adapter(&drm_dp_cec_adap_ops,
   354						     aux, connector->name, cec_caps,
   355						     num_las);
   356		if (IS_ERR(aux->cec.adap)) {
   357			aux->cec.adap = NULL;
   358			goto unlock;
   359		}
   360	
   361		cec_fill_conn_info_from_drm(&conn_info, connector);
   362		cec_s_conn_info(aux->cec.adap, &conn_info);
   363	
   364		if (cec_register_adapter(aux->cec.adap, connector->dev->dev)) {
   365			cec_delete_adapter(aux->cec.adap);
   366			aux->cec.adap = NULL;
   367		} else {
   368			/*
   369			 * Update the phys addr for the new CEC adapter. When called
   370			 * from drm_dp_cec_register_connector() edid == NULL, so in
   371			 * that case the phys addr is just invalidated.
   372			 */
   373			cec_s_phys_addr(adap, source_physical_address, false);
   374		}
   375	unlock:
   376		mutex_unlock(&aux->cec.lock);
   377	}
   378	EXPORT_SYMBOL(drm_dp_cec_attach);
   379	
   380	/*
   381	 * Note: Prefer calling drm_dp_cec_attach() with
   382	 * connector->display_info.source_physical_address if possible.
   383	 */
   384	void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
   385	{
   386		u16 source_physical_address = CEC_PHYS_ADDR_INVALID;
   387	
 > 388		if (edid && edid->extensions)
 > 389			pa = cec_get_edid_phys_addr((const u8 *)edid,
 > 390						    EDID_LENGTH * (edid->extensions + 1), NULL);
   391	
   392		drm_dp_cec_attach(aux, source_physical_address);
   393	}
   394	EXPORT_SYMBOL(drm_dp_cec_set_edid);
   395
kernel test robot Aug. 25, 2023, 11:23 a.m. UTC | #2
Hi Jani,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm/drm-next next-20230825]
[cannot apply to drm-intel/for-linux-next-fixes drm-misc/drm-misc-next linus/master v6.5-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-edid-add-drm_edid_is_digital/20230824-220926
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/f8ed9b38fd2ebcd8344a1889a6c0f288969454ea.1692884619.git.jani.nikula%40intel.com
patch subject: [Intel-gfx] [PATCH 4/6] drm/cec: add drm_dp_cec_attach() as the non-edid version of set edid
config: i386-buildonly-randconfig-001-20230824 (https://download.01.org/0day-ci/archive/20230825/202308251944.9tpk0wma-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230825/202308251944.9tpk0wma-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308251944.9tpk0wma-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gpu/drm/display/drm_dp_cec.c: In function 'drm_dp_cec_attach':
   drivers/gpu/drm/display/drm_dp_cec.c:342:20: error: 'adap' undeclared (first use in this function)
     342 |    cec_s_phys_addr(adap, source_physical_address, false);
         |                    ^~~~
   drivers/gpu/drm/display/drm_dp_cec.c:342:20: note: each undeclared identifier is reported only once for each function it appears in
   drivers/gpu/drm/display/drm_dp_cec.c: In function 'drm_dp_cec_set_edid':
>> drivers/gpu/drm/display/drm_dp_cec.c:388:18: error: dereferencing pointer to incomplete type 'const struct edid'
     388 |  if (edid && edid->extensions)
         |                  ^~
   drivers/gpu/drm/display/drm_dp_cec.c:389:3: error: 'pa' undeclared (first use in this function)
     389 |   pa = cec_get_edid_phys_addr((const u8 *)edid,
         |   ^~
   drivers/gpu/drm/display/drm_dp_cec.c:390:10: error: 'EDID_LENGTH' undeclared (first use in this function)
     390 |          EDID_LENGTH * (edid->extensions + 1), NULL);
         |          ^~~~~~~~~~~


vim +388 drivers/gpu/drm/display/drm_dp_cec.c

   379	
   380	/*
   381	 * Note: Prefer calling drm_dp_cec_attach() with
   382	 * connector->display_info.source_physical_address if possible.
   383	 */
   384	void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
   385	{
   386		u16 source_physical_address = CEC_PHYS_ADDR_INVALID;
   387	
 > 388		if (edid && edid->extensions)
   389			pa = cec_get_edid_phys_addr((const u8 *)edid,
   390						    EDID_LENGTH * (edid->extensions + 1), NULL);
   391	
   392		drm_dp_cec_attach(aux, source_physical_address);
   393	}
   394	EXPORT_SYMBOL(drm_dp_cec_set_edid);
   395
Hans Verkuil Aug. 30, 2023, 9:57 a.m. UTC | #3
On 24/08/2023 15:46, Jani Nikula wrote:
> Connectors have source physical address available in display
> info. There's no need to parse the EDID again for this. Add
> drm_dp_cec_attach() to do this.
> 
> Seems like the set_edid/unset_edid naming is a bit specific now that
> there's no need to pass the EDID at all, so aim for attach/detach going
> forward.
> 
> Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/display/drm_dp_cec.c | 22 +++++++++++++++++++---
>  include/drm/display/drm_dp_helper.h  |  6 ++++++
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_dp_cec.c b/drivers/gpu/drm/display/drm_dp_cec.c
> index ae39dc794190..da7a7d357446 100644
> --- a/drivers/gpu/drm/display/drm_dp_cec.c
> +++ b/drivers/gpu/drm/display/drm_dp_cec.c
> @@ -297,7 +297,7 @@ static void drm_dp_cec_unregister_work(struct work_struct *work)
>   * were unchanged and just update the CEC physical address. Otherwise
>   * unregister the old CEC adapter and create a new one.
>   */
> -void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
> +void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
>  {
>  	struct drm_connector *connector = aux->cec.connector;
>  	u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD |
> @@ -339,7 +339,7 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>  		if (aux->cec.adap->capabilities == cec_caps &&
>  		    aux->cec.adap->available_log_addrs == num_las) {
>  			/* Unchanged, so just set the phys addr */
> -			cec_s_phys_addr_from_edid(aux->cec.adap, edid);
> +			cec_s_phys_addr(adap, source_physical_address, false);

As the kernel test robot indicated, this does not compile, this should
be aux->cec.adap.

>  			goto unlock;
>  		}
>  		/*
> @@ -370,11 +370,27 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>  		 * from drm_dp_cec_register_connector() edid == NULL, so in
>  		 * that case the phys addr is just invalidated.
>  		 */
> -		cec_s_phys_addr_from_edid(aux->cec.adap, edid);
> +		cec_s_phys_addr(adap, source_physical_address, false);
>  	}
>  unlock:
>  	mutex_unlock(&aux->cec.lock);
>  }
> +EXPORT_SYMBOL(drm_dp_cec_attach);
> +
> +/*
> + * Note: Prefer calling drm_dp_cec_attach() with
> + * connector->display_info.source_physical_address if possible.
> + */
> +void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
> +{
> +	u16 source_physical_address = CEC_PHYS_ADDR_INVALID;
> +
> +	if (edid && edid->extensions)

And this source needs to include <drm/drm_edid.h>, also as found by
the kernel test robot.

Regards,

	Hans

> +		pa = cec_get_edid_phys_addr((const u8 *)edid,
> +					    EDID_LENGTH * (edid->extensions + 1), NULL);
> +
> +	drm_dp_cec_attach(aux, source_physical_address);
> +}
>  EXPORT_SYMBOL(drm_dp_cec_set_edid);
>  
>  /*
> diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
> index 86f24a759268..3369104e2d25 100644
> --- a/include/drm/display/drm_dp_helper.h
> +++ b/include/drm/display/drm_dp_helper.h
> @@ -699,6 +699,7 @@ void drm_dp_cec_irq(struct drm_dp_aux *aux);
>  void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
>  				   struct drm_connector *connector);
>  void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux);
> +void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address);
>  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);
>  #else
> @@ -716,6 +717,11 @@ static inline void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux)
>  {
>  }
>  
> +static inline void drm_dp_cec_attach(struct drm_dp_aux *aux,
> +				     u16 source_physical_address)
> +{
> +}
> +
>  static inline void drm_dp_cec_set_edid(struct drm_dp_aux *aux,
>  				       const struct edid *edid)
>  {
Jani Nikula Aug. 30, 2023, 10:23 a.m. UTC | #4
On Wed, 30 Aug 2023, Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
> On 24/08/2023 15:46, Jani Nikula wrote:
>> Connectors have source physical address available in display
>> info. There's no need to parse the EDID again for this. Add
>> drm_dp_cec_attach() to do this.
>> 
>> Seems like the set_edid/unset_edid naming is a bit specific now that
>> there's no need to pass the EDID at all, so aim for attach/detach going
>> forward.
>> 
>> Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>> Cc: linux-media@vger.kernel.org
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/display/drm_dp_cec.c | 22 +++++++++++++++++++---
>>  include/drm/display/drm_dp_helper.h  |  6 ++++++
>>  2 files changed, 25 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/display/drm_dp_cec.c b/drivers/gpu/drm/display/drm_dp_cec.c
>> index ae39dc794190..da7a7d357446 100644
>> --- a/drivers/gpu/drm/display/drm_dp_cec.c
>> +++ b/drivers/gpu/drm/display/drm_dp_cec.c
>> @@ -297,7 +297,7 @@ static void drm_dp_cec_unregister_work(struct work_struct *work)
>>   * were unchanged and just update the CEC physical address. Otherwise
>>   * unregister the old CEC adapter and create a new one.
>>   */
>> -void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>> +void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
>>  {
>>  	struct drm_connector *connector = aux->cec.connector;
>>  	u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD |
>> @@ -339,7 +339,7 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>>  		if (aux->cec.adap->capabilities == cec_caps &&
>>  		    aux->cec.adap->available_log_addrs == num_las) {
>>  			/* Unchanged, so just set the phys addr */
>> -			cec_s_phys_addr_from_edid(aux->cec.adap, edid);
>> +			cec_s_phys_addr(adap, source_physical_address, false);
>
> As the kernel test robot indicated, this does not compile, this should
> be aux->cec.adap.
>
>>  			goto unlock;
>>  		}
>>  		/*
>> @@ -370,11 +370,27 @@ void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>>  		 * from drm_dp_cec_register_connector() edid == NULL, so in
>>  		 * that case the phys addr is just invalidated.
>>  		 */
>> -		cec_s_phys_addr_from_edid(aux->cec.adap, edid);
>> +		cec_s_phys_addr(adap, source_physical_address, false);
>>  	}
>>  unlock:
>>  	mutex_unlock(&aux->cec.lock);
>>  }
>> +EXPORT_SYMBOL(drm_dp_cec_attach);
>> +
>> +/*
>> + * Note: Prefer calling drm_dp_cec_attach() with
>> + * connector->display_info.source_physical_address if possible.
>> + */
>> +void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
>> +{
>> +	u16 source_physical_address = CEC_PHYS_ADDR_INVALID;
>> +
>> +	if (edid && edid->extensions)
>
> And this source needs to include <drm/drm_edid.h>, also as found by
> the kernel test robot.

Yes, very embarrassing, I sent the v2 in reply [1].

BR,
Jani.

[1] https://patchwork.freedesktop.org/patch/msgid/20230825130120.1250089-1-jani.nikula@intel.com


>
> Regards,
>
> 	Hans
>
>> +		pa = cec_get_edid_phys_addr((const u8 *)edid,
>> +					    EDID_LENGTH * (edid->extensions + 1), NULL);
>> +
>> +	drm_dp_cec_attach(aux, source_physical_address);
>> +}
>>  EXPORT_SYMBOL(drm_dp_cec_set_edid);
>>  
>>  /*
>> diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
>> index 86f24a759268..3369104e2d25 100644
>> --- a/include/drm/display/drm_dp_helper.h
>> +++ b/include/drm/display/drm_dp_helper.h
>> @@ -699,6 +699,7 @@ void drm_dp_cec_irq(struct drm_dp_aux *aux);
>>  void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
>>  				   struct drm_connector *connector);
>>  void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux);
>> +void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address);
>>  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);
>>  #else
>> @@ -716,6 +717,11 @@ static inline void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux)
>>  {
>>  }
>>  
>> +static inline void drm_dp_cec_attach(struct drm_dp_aux *aux,
>> +				     u16 source_physical_address)
>> +{
>> +}
>> +
>>  static inline void drm_dp_cec_set_edid(struct drm_dp_aux *aux,
>>  				       const struct edid *edid)
>>  {
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/display/drm_dp_cec.c b/drivers/gpu/drm/display/drm_dp_cec.c
index ae39dc794190..da7a7d357446 100644
--- a/drivers/gpu/drm/display/drm_dp_cec.c
+++ b/drivers/gpu/drm/display/drm_dp_cec.c
@@ -297,7 +297,7 @@  static void drm_dp_cec_unregister_work(struct work_struct *work)
  * were unchanged and just update the CEC physical address. Otherwise
  * unregister the old CEC adapter and create a new one.
  */
-void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
+void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
 {
 	struct drm_connector *connector = aux->cec.connector;
 	u32 cec_caps = CEC_CAP_DEFAULTS | CEC_CAP_NEEDS_HPD |
@@ -339,7 +339,7 @@  void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
 		if (aux->cec.adap->capabilities == cec_caps &&
 		    aux->cec.adap->available_log_addrs == num_las) {
 			/* Unchanged, so just set the phys addr */
-			cec_s_phys_addr_from_edid(aux->cec.adap, edid);
+			cec_s_phys_addr(adap, source_physical_address, false);
 			goto unlock;
 		}
 		/*
@@ -370,11 +370,27 @@  void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
 		 * from drm_dp_cec_register_connector() edid == NULL, so in
 		 * that case the phys addr is just invalidated.
 		 */
-		cec_s_phys_addr_from_edid(aux->cec.adap, edid);
+		cec_s_phys_addr(adap, source_physical_address, false);
 	}
 unlock:
 	mutex_unlock(&aux->cec.lock);
 }
+EXPORT_SYMBOL(drm_dp_cec_attach);
+
+/*
+ * Note: Prefer calling drm_dp_cec_attach() with
+ * connector->display_info.source_physical_address if possible.
+ */
+void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid)
+{
+	u16 source_physical_address = CEC_PHYS_ADDR_INVALID;
+
+	if (edid && edid->extensions)
+		pa = cec_get_edid_phys_addr((const u8 *)edid,
+					    EDID_LENGTH * (edid->extensions + 1), NULL);
+
+	drm_dp_cec_attach(aux, source_physical_address);
+}
 EXPORT_SYMBOL(drm_dp_cec_set_edid);
 
 /*
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index 86f24a759268..3369104e2d25 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -699,6 +699,7 @@  void drm_dp_cec_irq(struct drm_dp_aux *aux);
 void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
 				   struct drm_connector *connector);
 void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux);
+void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address);
 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);
 #else
@@ -716,6 +717,11 @@  static inline void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux)
 {
 }
 
+static inline void drm_dp_cec_attach(struct drm_dp_aux *aux,
+				     u16 source_physical_address)
+{
+}
+
 static inline void drm_dp_cec_set_edid(struct drm_dp_aux *aux,
 				       const struct edid *edid)
 {