diff mbox

[16/20] drm: add function to read vendor OUI

Message ID 1499685528-6926-17-git-send-email-shashank.sharma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sharma, Shashank July 10, 2017, 11:18 a.m. UTC
This patch adds a helper function in DP dual mode layer to
read the vendor's IEEE OUI signature from a Dual mode adapter.
This will be used to differentiate between different LSPCON
vendors, to address their custom programming requirements.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
---
 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 24 ++++++++++++++++++++++++
 include/drm/drm_dp_dual_mode_helper.h     |  4 +++-
 2 files changed, 27 insertions(+), 1 deletion(-)

Comments

Ville Syrjala July 12, 2017, 5:15 p.m. UTC | #1
On Mon, Jul 10, 2017 at 04:48:44PM +0530, Shashank Sharma wrote:
> This patch adds a helper function in DP dual mode layer to
> read the vendor's IEEE OUI signature from a Dual mode adapter.
> This will be used to differentiate between different LSPCON
> vendors, to address their custom programming requirements.

Can't we just read it from DPCD instead?

> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_dual_mode_helper.c | 24 ++++++++++++++++++++++++
>  include/drm/drm_dp_dual_mode_helper.h     |  4 +++-
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> index 80e62f6..0b890dc 100644
> --- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> +++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> @@ -396,6 +396,30 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
>  EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
>  
>  /**
> + * drm_lspcon_get_vendor_oui: match vendor OUI signature
> + * @adapter: i2c adapter under action
> + * @vendor_id = 3 bytes of vendor OUI signature, LSB=lower byte
> + *
> + * Returns:
> + * Vendor OUI id if got one, 0 if not
> + */
> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter)
> +{
> +	uint8_t sign[3] = {0, };
> +	uint32_t oui = 0;
> +
> +	if (drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_OUI_OFFSET,
> +						sign, 3)) {
> +		DRM_ERROR("Can't identify vendor sign\n");
> +		return 0;
> +	}
> +
> +	oui = (sign[0] << 16) | (sign[1] << 8) | sign[2];
> +	return oui;
> +}
> +EXPORT_SYMBOL(drm_lspcon_get_vendor_oui);
> +
> +/**
>   * drm_lspcon_get_mode: Get LSPCON's current mode of operation by
>   * reading offset (0x80, 0x41)
>   * @adapter: I2C-over-aux adapter
> diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
> index 4c42db8..f81b526 100644
> --- a/include/drm/drm_dp_dual_mode_helper.h
> +++ b/include/drm/drm_dp_dual_mode_helper.h
> @@ -60,7 +60,8 @@
>  /* LSPCON specific registers, defined by MCA */
>  #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
>  #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
> -#define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
> +#define DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
> +#define DP_DUAL_MODE_LSPCON_OUI_OFFSET			0x11
>  
>  struct i2c_adapter;
>  
> @@ -116,4 +117,5 @@ int drm_lspcon_get_mode(struct i2c_adapter *adapter,
>  			enum drm_lspcon_mode *current_mode);
>  int drm_lspcon_set_mode(struct i2c_adapter *adapter,
>  			enum drm_lspcon_mode reqd_mode);
> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter);
>  #endif
> -- 
> 2.7.4
Sharma, Shashank July 13, 2017, 5:04 a.m. UTC | #2
Regads

Shashank


On 7/12/2017 10:45 PM, Ville Syrjälä wrote:
> On Mon, Jul 10, 2017 at 04:48:44PM +0530, Shashank Sharma wrote:
>> This patch adds a helper function in DP dual mode layer to
>> read the vendor's IEEE OUI signature from a Dual mode adapter.
>> This will be used to differentiate between different LSPCON
>> vendors, to address their custom programming requirements.
> Can't we just read it from DPCD instead?
You are right, as we have DPCD cached, we can do it from DPCD too, and 
in fact that was my first implementation.
But then I thought what if some driver doesn't cache DPCD, so thought it 
would be good to have a helper function
to check this out.
If you think DPCD would be a better idea, I need not to touch DRM layer 
at all, and this will be only I915 implementation.

- Shashank
>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Cc: Imre Deak <imre.deak@intel.com>
>> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
>> ---
>>   drivers/gpu/drm/drm_dp_dual_mode_helper.c | 24 ++++++++++++++++++++++++
>>   include/drm/drm_dp_dual_mode_helper.h     |  4 +++-
>>   2 files changed, 27 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>> index 80e62f6..0b890dc 100644
>> --- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>> +++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>> @@ -396,6 +396,30 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
>>   EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
>>   
>>   /**
>> + * drm_lspcon_get_vendor_oui: match vendor OUI signature
>> + * @adapter: i2c adapter under action
>> + * @vendor_id = 3 bytes of vendor OUI signature, LSB=lower byte
>> + *
>> + * Returns:
>> + * Vendor OUI id if got one, 0 if not
>> + */
>> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter)
>> +{
>> +	uint8_t sign[3] = {0, };
>> +	uint32_t oui = 0;
>> +
>> +	if (drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_OUI_OFFSET,
>> +						sign, 3)) {
>> +		DRM_ERROR("Can't identify vendor sign\n");
>> +		return 0;
>> +	}
>> +
>> +	oui = (sign[0] << 16) | (sign[1] << 8) | sign[2];
>> +	return oui;
>> +}
>> +EXPORT_SYMBOL(drm_lspcon_get_vendor_oui);
>> +
>> +/**
>>    * drm_lspcon_get_mode: Get LSPCON's current mode of operation by
>>    * reading offset (0x80, 0x41)
>>    * @adapter: I2C-over-aux adapter
>> diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
>> index 4c42db8..f81b526 100644
>> --- a/include/drm/drm_dp_dual_mode_helper.h
>> +++ b/include/drm/drm_dp_dual_mode_helper.h
>> @@ -60,7 +60,8 @@
>>   /* LSPCON specific registers, defined by MCA */
>>   #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
>>   #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
>> -#define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
>> +#define DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
>> +#define DP_DUAL_MODE_LSPCON_OUI_OFFSET			0x11
>>   
>>   struct i2c_adapter;
>>   
>> @@ -116,4 +117,5 @@ int drm_lspcon_get_mode(struct i2c_adapter *adapter,
>>   			enum drm_lspcon_mode *current_mode);
>>   int drm_lspcon_set_mode(struct i2c_adapter *adapter,
>>   			enum drm_lspcon_mode reqd_mode);
>> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter);
>>   #endif
>> -- 
>> 2.7.4
Ville Syrjala July 13, 2017, 12:37 p.m. UTC | #3
On Thu, Jul 13, 2017 at 10:34:26AM +0530, Sharma, Shashank wrote:
> Regads
> 
> Shashank
> 
> 
> On 7/12/2017 10:45 PM, Ville Syrjälä wrote:
> > On Mon, Jul 10, 2017 at 04:48:44PM +0530, Shashank Sharma wrote:
> >> This patch adds a helper function in DP dual mode layer to
> >> read the vendor's IEEE OUI signature from a Dual mode adapter.
> >> This will be used to differentiate between different LSPCON
> >> vendors, to address their custom programming requirements.
> > Can't we just read it from DPCD instead?
> You are right, as we have DPCD cached, we can do it from DPCD too, and 
> in fact that was my first implementation.
> But then I thought what if some driver doesn't cache DPCD, so thought it 
> would be good to have a helper function
> to check this out.
> If you think DPCD would be a better idea, I need not to touch DRM layer 
> at all, and this will be only I915 implementation.

Yeah, less code seems like a good thing. I think we might even have that
OUI stuff already read out and cached for other purposes.

> 
> - Shashank
> >
> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> Cc: Imre Deak <imre.deak@intel.com>
> >> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> >> ---
> >>   drivers/gpu/drm/drm_dp_dual_mode_helper.c | 24 ++++++++++++++++++++++++
> >>   include/drm/drm_dp_dual_mode_helper.h     |  4 +++-
> >>   2 files changed, 27 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> >> index 80e62f6..0b890dc 100644
> >> --- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> >> +++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> >> @@ -396,6 +396,30 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
> >>   EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
> >>   
> >>   /**
> >> + * drm_lspcon_get_vendor_oui: match vendor OUI signature
> >> + * @adapter: i2c adapter under action
> >> + * @vendor_id = 3 bytes of vendor OUI signature, LSB=lower byte
> >> + *
> >> + * Returns:
> >> + * Vendor OUI id if got one, 0 if not
> >> + */
> >> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter)
> >> +{
> >> +	uint8_t sign[3] = {0, };
> >> +	uint32_t oui = 0;
> >> +
> >> +	if (drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_OUI_OFFSET,
> >> +						sign, 3)) {
> >> +		DRM_ERROR("Can't identify vendor sign\n");
> >> +		return 0;
> >> +	}
> >> +
> >> +	oui = (sign[0] << 16) | (sign[1] << 8) | sign[2];
> >> +	return oui;
> >> +}
> >> +EXPORT_SYMBOL(drm_lspcon_get_vendor_oui);
> >> +
> >> +/**
> >>    * drm_lspcon_get_mode: Get LSPCON's current mode of operation by
> >>    * reading offset (0x80, 0x41)
> >>    * @adapter: I2C-over-aux adapter
> >> diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
> >> index 4c42db8..f81b526 100644
> >> --- a/include/drm/drm_dp_dual_mode_helper.h
> >> +++ b/include/drm/drm_dp_dual_mode_helper.h
> >> @@ -60,7 +60,8 @@
> >>   /* LSPCON specific registers, defined by MCA */
> >>   #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
> >>   #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
> >> -#define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
> >> +#define DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
> >> +#define DP_DUAL_MODE_LSPCON_OUI_OFFSET			0x11
> >>   
> >>   struct i2c_adapter;
> >>   
> >> @@ -116,4 +117,5 @@ int drm_lspcon_get_mode(struct i2c_adapter *adapter,
> >>   			enum drm_lspcon_mode *current_mode);
> >>   int drm_lspcon_set_mode(struct i2c_adapter *adapter,
> >>   			enum drm_lspcon_mode reqd_mode);
> >> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter);
> >>   #endif
> >> -- 
> >> 2.7.4
Sharma, Shashank July 13, 2017, 12:50 p.m. UTC | #4
Regards

Shashank


On 7/13/2017 6:07 PM, Ville Syrjälä wrote:
> On Thu, Jul 13, 2017 at 10:34:26AM +0530, Sharma, Shashank wrote:
>> Regads
>>
>> Shashank
>>
>>
>> On 7/12/2017 10:45 PM, Ville Syrjälä wrote:
>>> On Mon, Jul 10, 2017 at 04:48:44PM +0530, Shashank Sharma wrote:
>>>> This patch adds a helper function in DP dual mode layer to
>>>> read the vendor's IEEE OUI signature from a Dual mode adapter.
>>>> This will be used to differentiate between different LSPCON
>>>> vendors, to address their custom programming requirements.
>>> Can't we just read it from DPCD instead?
>> You are right, as we have DPCD cached, we can do it from DPCD too, and
>> in fact that was my first implementation.
>> But then I thought what if some driver doesn't cache DPCD, so thought it
>> would be good to have a helper function
>> to check this out.
>> If you think DPCD would be a better idea, I need not to touch DRM layer
>> at all, and this will be only I915 implementation.
> Yeah, less code seems like a good thing. I think we might even have that
> OUI stuff already read out and cached for other purposes.
Sure, then, I will extract OUI and cache it in a variable.
- Shashank
>> - Shashank
>>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>> Cc: Imre Deak <imre.deak@intel.com>
>>>> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
>>>> ---
>>>>    drivers/gpu/drm/drm_dp_dual_mode_helper.c | 24 ++++++++++++++++++++++++
>>>>    include/drm/drm_dp_dual_mode_helper.h     |  4 +++-
>>>>    2 files changed, 27 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>>>> index 80e62f6..0b890dc 100644
>>>> --- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>>>> +++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
>>>> @@ -396,6 +396,30 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
>>>>    EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
>>>>    
>>>>    /**
>>>> + * drm_lspcon_get_vendor_oui: match vendor OUI signature
>>>> + * @adapter: i2c adapter under action
>>>> + * @vendor_id = 3 bytes of vendor OUI signature, LSB=lower byte
>>>> + *
>>>> + * Returns:
>>>> + * Vendor OUI id if got one, 0 if not
>>>> + */
>>>> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter)
>>>> +{
>>>> +	uint8_t sign[3] = {0, };
>>>> +	uint32_t oui = 0;
>>>> +
>>>> +	if (drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_OUI_OFFSET,
>>>> +						sign, 3)) {
>>>> +		DRM_ERROR("Can't identify vendor sign\n");
>>>> +		return 0;
>>>> +	}
>>>> +
>>>> +	oui = (sign[0] << 16) | (sign[1] << 8) | sign[2];
>>>> +	return oui;
>>>> +}
>>>> +EXPORT_SYMBOL(drm_lspcon_get_vendor_oui);
>>>> +
>>>> +/**
>>>>     * drm_lspcon_get_mode: Get LSPCON's current mode of operation by
>>>>     * reading offset (0x80, 0x41)
>>>>     * @adapter: I2C-over-aux adapter
>>>> diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
>>>> index 4c42db8..f81b526 100644
>>>> --- a/include/drm/drm_dp_dual_mode_helper.h
>>>> +++ b/include/drm/drm_dp_dual_mode_helper.h
>>>> @@ -60,7 +60,8 @@
>>>>    /* LSPCON specific registers, defined by MCA */
>>>>    #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
>>>>    #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
>>>> -#define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
>>>> +#define DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
>>>> +#define DP_DUAL_MODE_LSPCON_OUI_OFFSET			0x11
>>>>    
>>>>    struct i2c_adapter;
>>>>    
>>>> @@ -116,4 +117,5 @@ int drm_lspcon_get_mode(struct i2c_adapter *adapter,
>>>>    			enum drm_lspcon_mode *current_mode);
>>>>    int drm_lspcon_set_mode(struct i2c_adapter *adapter,
>>>>    			enum drm_lspcon_mode reqd_mode);
>>>> +uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter);
>>>>    #endif
>>>> -- 
>>>> 2.7.4
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
index 80e62f6..0b890dc 100644
--- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
+++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
@@ -396,6 +396,30 @@  const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
 EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
 
 /**
+ * drm_lspcon_get_vendor_oui: match vendor OUI signature
+ * @adapter: i2c adapter under action
+ * @vendor_id = 3 bytes of vendor OUI signature, LSB=lower byte
+ *
+ * Returns:
+ * Vendor OUI id if got one, 0 if not
+ */
+uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter)
+{
+	uint8_t sign[3] = {0, };
+	uint32_t oui = 0;
+
+	if (drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_OUI_OFFSET,
+						sign, 3)) {
+		DRM_ERROR("Can't identify vendor sign\n");
+		return 0;
+	}
+
+	oui = (sign[0] << 16) | (sign[1] << 8) | sign[2];
+	return oui;
+}
+EXPORT_SYMBOL(drm_lspcon_get_vendor_oui);
+
+/**
  * drm_lspcon_get_mode: Get LSPCON's current mode of operation by
  * reading offset (0x80, 0x41)
  * @adapter: I2C-over-aux adapter
diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
index 4c42db8..f81b526 100644
--- a/include/drm/drm_dp_dual_mode_helper.h
+++ b/include/drm/drm_dp_dual_mode_helper.h
@@ -60,7 +60,8 @@ 
 /* LSPCON specific registers, defined by MCA */
 #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
 #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
-#define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
+#define DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
+#define DP_DUAL_MODE_LSPCON_OUI_OFFSET			0x11
 
 struct i2c_adapter;
 
@@ -116,4 +117,5 @@  int drm_lspcon_get_mode(struct i2c_adapter *adapter,
 			enum drm_lspcon_mode *current_mode);
 int drm_lspcon_set_mode(struct i2c_adapter *adapter,
 			enum drm_lspcon_mode reqd_mode);
+uint32_t drm_lspcon_get_vendor_oui(struct i2c_adapter *adapter);
 #endif