* [PATCH 1/2] drm/dp: Export drm_dp_dpcd_access()
@ 2022-04-07 18:38 Imre Deak
2022-04-07 19:32 ` Jani Nikula
0 siblings, 1 reply; 3+ messages in thread
From: Imre Deak @ 2022-04-07 18:38 UTC (permalink / raw)
To: intel-gfx; +Cc: dri-devel
The next patch needs a way to read a DPCD register without the preceding
wake-up read in drm_dp_dpcd_read(). Export drm_dp_dpcd_access() to allow
this.
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/dp/drm_dp.c | 19 +++++++++++++++++--
include/drm/dp/drm_dp_helper.h | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
index 580016a1b9eb7..8b181314edcbe 100644
--- a/drivers/gpu/drm/dp/drm_dp.c
+++ b/drivers/gpu/drm/dp/drm_dp.c
@@ -470,8 +470,22 @@ drm_dp_dump_access(const struct drm_dp_aux *aux,
* Both native and I2C-over-AUX transactions are supported.
*/
-static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
- unsigned int offset, void *buffer, size_t size)
+/**
+ * drm_dp_dpcd_access() - read or write a series of bytes from/to the DPCD
+ * @aux: DisplayPort AUX channel (SST)
+ * @request: DP_AUX_NATIVE_READ or DP_AUX_NATIVE_WRITE
+ * @offset: address of the (first) register to read or write
+ * @buffer: buffer with the register values to write or the register values read
+ * @size: number of bytes in @buffer
+ *
+ * Returns the number of bytes transferred on success, or a negative error
+ * code on failure. This is a low-level function only for SST sinks and cases
+ * where calling drm_dp_dpcd_read()/write() is not possible (for instance due
+ * to the wake-up register read in drm_dp_dpcd_read()). For all other cases
+ * the latter functions should be used.
+ */
+int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
+ unsigned int offset, void *buffer, size_t size)
{
struct drm_dp_aux_msg msg;
unsigned int retry, native_reply;
@@ -526,6 +540,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
mutex_unlock(&aux->hw_mutex);
return ret;
}
+EXPORT_SYMBOL(drm_dp_dpcd_access);
/**
* drm_dp_dpcd_read() - read a series of bytes from the DPCD
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
index 1eccd97419436..7cf6e83434a8c 100644
--- a/include/drm/dp/drm_dp_helper.h
+++ b/include/drm/dp/drm_dp_helper.h
@@ -2053,6 +2053,8 @@ struct drm_dp_aux {
bool is_remote;
};
+int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
+ unsigned int offset, void *buffer, size_t size);
ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
void *buffer, size_t size);
ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] drm/dp: Export drm_dp_dpcd_access()
2022-04-07 18:38 [PATCH 1/2] drm/dp: Export drm_dp_dpcd_access() Imre Deak
@ 2022-04-07 19:32 ` Jani Nikula
2022-04-08 9:12 ` Imre Deak
0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2022-04-07 19:32 UTC (permalink / raw)
To: Imre Deak, intel-gfx; +Cc: dri-devel
On Thu, 07 Apr 2022, Imre Deak <imre.deak@intel.com> wrote:
> The next patch needs a way to read a DPCD register without the preceding
> wake-up read in drm_dp_dpcd_read(). Export drm_dp_dpcd_access() to allow
> this.
I think I'd rather you added a special "probe" function for this
specific purpose. I think drm_dp_dpcd_access() is a too generic low
level function to export, and runs the risk of complicating any
potential future refactoring of the DP AUX code.
Something like this:
ssize_t drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
And you could reuse that for the wakeup in drm_dp_dpcd_read() too.
BR,
Jani.
>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
> drivers/gpu/drm/dp/drm_dp.c | 19 +++++++++++++++++--
> include/drm/dp/drm_dp_helper.h | 2 ++
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
> index 580016a1b9eb7..8b181314edcbe 100644
> --- a/drivers/gpu/drm/dp/drm_dp.c
> +++ b/drivers/gpu/drm/dp/drm_dp.c
> @@ -470,8 +470,22 @@ drm_dp_dump_access(const struct drm_dp_aux *aux,
> * Both native and I2C-over-AUX transactions are supported.
> */
>
> -static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> - unsigned int offset, void *buffer, size_t size)
> +/**
> + * drm_dp_dpcd_access() - read or write a series of bytes from/to the DPCD
> + * @aux: DisplayPort AUX channel (SST)
> + * @request: DP_AUX_NATIVE_READ or DP_AUX_NATIVE_WRITE
> + * @offset: address of the (first) register to read or write
> + * @buffer: buffer with the register values to write or the register values read
> + * @size: number of bytes in @buffer
> + *
> + * Returns the number of bytes transferred on success, or a negative error
> + * code on failure. This is a low-level function only for SST sinks and cases
> + * where calling drm_dp_dpcd_read()/write() is not possible (for instance due
> + * to the wake-up register read in drm_dp_dpcd_read()). For all other cases
> + * the latter functions should be used.
> + */
> +int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> + unsigned int offset, void *buffer, size_t size)
> {
> struct drm_dp_aux_msg msg;
> unsigned int retry, native_reply;
> @@ -526,6 +540,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> mutex_unlock(&aux->hw_mutex);
> return ret;
> }
> +EXPORT_SYMBOL(drm_dp_dpcd_access);
>
> /**
> * drm_dp_dpcd_read() - read a series of bytes from the DPCD
> diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
> index 1eccd97419436..7cf6e83434a8c 100644
> --- a/include/drm/dp/drm_dp_helper.h
> +++ b/include/drm/dp/drm_dp_helper.h
> @@ -2053,6 +2053,8 @@ struct drm_dp_aux {
> bool is_remote;
> };
>
> +int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> + unsigned int offset, void *buffer, size_t size);
> ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
> void *buffer, size_t size);
> ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] drm/dp: Export drm_dp_dpcd_access()
2022-04-07 19:32 ` Jani Nikula
@ 2022-04-08 9:12 ` Imre Deak
0 siblings, 0 replies; 3+ messages in thread
From: Imre Deak @ 2022-04-08 9:12 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx, dri-devel
On Thu, Apr 07, 2022 at 10:32:11PM +0300, Jani Nikula wrote:
> On Thu, 07 Apr 2022, Imre Deak <imre.deak@intel.com> wrote:
> > The next patch needs a way to read a DPCD register without the preceding
> > wake-up read in drm_dp_dpcd_read(). Export drm_dp_dpcd_access() to allow
> > this.
>
> I think I'd rather you added a special "probe" function for this
> specific purpose. I think drm_dp_dpcd_access() is a too generic low
> level function to export, and runs the risk of complicating any
> potential future refactoring of the DP AUX code.
>
> Something like this:
>
> ssize_t drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
>
> And you could reuse that for the wakeup in drm_dp_dpcd_read() too.
Ok, makes sense, I'll change that.
> BR,
> Jani.
>
> >
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> > drivers/gpu/drm/dp/drm_dp.c | 19 +++++++++++++++++--
> > include/drm/dp/drm_dp_helper.h | 2 ++
> > 2 files changed, 19 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
> > index 580016a1b9eb7..8b181314edcbe 100644
> > --- a/drivers/gpu/drm/dp/drm_dp.c
> > +++ b/drivers/gpu/drm/dp/drm_dp.c
> > @@ -470,8 +470,22 @@ drm_dp_dump_access(const struct drm_dp_aux *aux,
> > * Both native and I2C-over-AUX transactions are supported.
> > */
> >
> > -static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> > - unsigned int offset, void *buffer, size_t size)
> > +/**
> > + * drm_dp_dpcd_access() - read or write a series of bytes from/to the DPCD
> > + * @aux: DisplayPort AUX channel (SST)
> > + * @request: DP_AUX_NATIVE_READ or DP_AUX_NATIVE_WRITE
> > + * @offset: address of the (first) register to read or write
> > + * @buffer: buffer with the register values to write or the register values read
> > + * @size: number of bytes in @buffer
> > + *
> > + * Returns the number of bytes transferred on success, or a negative error
> > + * code on failure. This is a low-level function only for SST sinks and cases
> > + * where calling drm_dp_dpcd_read()/write() is not possible (for instance due
> > + * to the wake-up register read in drm_dp_dpcd_read()). For all other cases
> > + * the latter functions should be used.
> > + */
> > +int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> > + unsigned int offset, void *buffer, size_t size)
> > {
> > struct drm_dp_aux_msg msg;
> > unsigned int retry, native_reply;
> > @@ -526,6 +540,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> > mutex_unlock(&aux->hw_mutex);
> > return ret;
> > }
> > +EXPORT_SYMBOL(drm_dp_dpcd_access);
> >
> > /**
> > * drm_dp_dpcd_read() - read a series of bytes from the DPCD
> > diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
> > index 1eccd97419436..7cf6e83434a8c 100644
> > --- a/include/drm/dp/drm_dp_helper.h
> > +++ b/include/drm/dp/drm_dp_helper.h
> > @@ -2053,6 +2053,8 @@ struct drm_dp_aux {
> > bool is_remote;
> > };
> >
> > +int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
> > + unsigned int offset, void *buffer, size_t size);
> > ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
> > void *buffer, size_t size);
> > ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
>
> --
> Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-08 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 18:38 [PATCH 1/2] drm/dp: Export drm_dp_dpcd_access() Imre Deak
2022-04-07 19:32 ` Jani Nikula
2022-04-08 9:12 ` Imre Deak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).