* [PATCH] drm: sysfs: Add to get current mode
@ 2020-08-05 8:36 Sandy Huang
2020-08-05 9:36 ` Daniel Vetter
0 siblings, 1 reply; 4+ messages in thread
From: Sandy Huang @ 2020-08-05 8:36 UTC (permalink / raw)
To: heiko, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter
Cc: huangtao, linux-kernel, Sandy Huang, dri-devel, kever.yang,
linux-rockchip, andy.yan
add this node to get the current true mode.
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
---
drivers/gpu/drm/drm_sysfs.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 939f0032aab1..f39bcd34853b 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_file.h>
#include <drm/drm_modes.h>
@@ -236,16 +237,45 @@ static ssize_t modes_show(struct device *device,
return written;
}
+static ssize_t current_mode_show(struct device *device,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_connector *connector = to_drm_connector(device);
+ struct drm_display_mode *mode;
+ struct drm_crtc_state *crtc_state;
+ bool interlaced;
+ int written = 0;
+
+ if (!connector->state || !connector->state->crtc)
+ return written;
+
+ crtc_state = connector->state->crtc->state;
+ if (!crtc_state)
+ return written;
+
+ mode = &crtc_state->mode;
+
+ interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
+ written += snprintf(buf + written, PAGE_SIZE - written, "%dx%d%s%d\n",
+ mode->hdisplay, mode->vdisplay,
+ interlaced ? "i" : "p", drm_mode_vrefresh(mode));
+
+ return written;
+}
+
static DEVICE_ATTR_RW(status);
static DEVICE_ATTR_RO(enabled);
static DEVICE_ATTR_RO(dpms);
static DEVICE_ATTR_RO(modes);
+static DEVICE_ATTR_RO(current_mode);
static struct attribute *connector_dev_attrs[] = {
&dev_attr_status.attr,
&dev_attr_enabled.attr,
&dev_attr_dpms.attr,
&dev_attr_modes.attr,
+ &dev_attr_current_mode.attr,
NULL
};
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sysfs: Add to get current mode
2020-08-05 8:36 [PATCH] drm: sysfs: Add to get current mode Sandy Huang
@ 2020-08-05 9:36 ` Daniel Vetter
2020-08-05 10:03 ` Huang Jiachai
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2020-08-05 9:36 UTC (permalink / raw)
To: Sandy Huang
Cc: Tao Huang, David Airlie, Kever Yang, Linux Kernel Mailing List,
open list:ARM/Rockchip SoC...,
dri-devel, Thomas Zimmermann, Andy Yan
On Wed, Aug 5, 2020 at 10:37 AM Sandy Huang <hjc@rock-chips.com> wrote:
>
> add this node to get the current true mode.
>
> Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Uh what's this for? Since it's sysfs, I guess there's something
parsing this, which means we'd kinda need to have that piece too.
If it's just for debugging purposes, then we already have this
information in debugfs, together with everything else that's in the
atomic modeset state.
-Daniel
> ---
> drivers/gpu/drm/drm_sysfs.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 939f0032aab1..f39bcd34853b 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -19,6 +19,7 @@
> #include <linux/slab.h>
>
> #include <drm/drm_connector.h>
> +#include <drm/drm_crtc.h>
> #include <drm/drm_device.h>
> #include <drm/drm_file.h>
> #include <drm/drm_modes.h>
> @@ -236,16 +237,45 @@ static ssize_t modes_show(struct device *device,
> return written;
> }
>
> +static ssize_t current_mode_show(struct device *device,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct drm_connector *connector = to_drm_connector(device);
> + struct drm_display_mode *mode;
> + struct drm_crtc_state *crtc_state;
> + bool interlaced;
> + int written = 0;
> +
> + if (!connector->state || !connector->state->crtc)
> + return written;
> +
> + crtc_state = connector->state->crtc->state;
> + if (!crtc_state)
> + return written;
> +
> + mode = &crtc_state->mode;
> +
> + interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
> + written += snprintf(buf + written, PAGE_SIZE - written, "%dx%d%s%d\n",
> + mode->hdisplay, mode->vdisplay,
> + interlaced ? "i" : "p", drm_mode_vrefresh(mode));
> +
> + return written;
> +}
> +
> static DEVICE_ATTR_RW(status);
> static DEVICE_ATTR_RO(enabled);
> static DEVICE_ATTR_RO(dpms);
> static DEVICE_ATTR_RO(modes);
> +static DEVICE_ATTR_RO(current_mode);
>
> static struct attribute *connector_dev_attrs[] = {
> &dev_attr_status.attr,
> &dev_attr_enabled.attr,
> &dev_attr_dpms.attr,
> &dev_attr_modes.attr,
> + &dev_attr_current_mode.attr,
> NULL
> };
>
> --
> 2.17.1
>
>
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sysfs: Add to get current mode
2020-08-05 9:36 ` Daniel Vetter
@ 2020-08-05 10:03 ` Huang Jiachai
2020-08-05 11:26 ` daniel
0 siblings, 1 reply; 4+ messages in thread
From: Huang Jiachai @ 2020-08-05 10:03 UTC (permalink / raw)
To: Daniel Vetter
Cc: Tao Huang, David Airlie, Kever Yang, Linux Kernel Mailing List,
open list:ARM/Rockchip SoC...,
dri-devel, Thomas Zimmermann, Andy Yan
Hi Daniel
在 2020/8/5 17:36, Daniel Vetter 写道:
> On Wed, Aug 5, 2020 at 10:37 AM Sandy Huang <hjc@rock-chips.com> wrote:
>> add this node to get the current true mode.
>>
>> Signed-off-by: Sandy Huang <hjc@rock-chips.com>
> Uh what's this for? Since it's sysfs, I guess there's something
> parsing this, which means we'd kinda need to have that piece too.
>
> If it's just for debugging purposes, then we already have this
> information in debugfs, together with everything else that's in the
> atomic modeset state.
> -Daniel
yes, this is just for debug;
and i get the information what i need from cat
/sys/kernel/debug/dri/0/state, thanks.
>> ---
>> drivers/gpu/drm/drm_sysfs.c | 30 ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
>> index 939f0032aab1..f39bcd34853b 100644
>> --- a/drivers/gpu/drm/drm_sysfs.c
>> +++ b/drivers/gpu/drm/drm_sysfs.c
>> @@ -19,6 +19,7 @@
>> #include <linux/slab.h>
>>
>> #include <drm/drm_connector.h>
>> +#include <drm/drm_crtc.h>
>> #include <drm/drm_device.h>
>> #include <drm/drm_file.h>
>> #include <drm/drm_modes.h>
>> @@ -236,16 +237,45 @@ static ssize_t modes_show(struct device *device,
>> return written;
>> }
>>
>> +static ssize_t current_mode_show(struct device *device,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + struct drm_connector *connector = to_drm_connector(device);
>> + struct drm_display_mode *mode;
>> + struct drm_crtc_state *crtc_state;
>> + bool interlaced;
>> + int written = 0;
>> +
>> + if (!connector->state || !connector->state->crtc)
>> + return written;
>> +
>> + crtc_state = connector->state->crtc->state;
>> + if (!crtc_state)
>> + return written;
>> +
>> + mode = &crtc_state->mode;
>> +
>> + interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
>> + written += snprintf(buf + written, PAGE_SIZE - written, "%dx%d%s%d\n",
>> + mode->hdisplay, mode->vdisplay,
>> + interlaced ? "i" : "p", drm_mode_vrefresh(mode));
>> +
>> + return written;
>> +}
>> +
>> static DEVICE_ATTR_RW(status);
>> static DEVICE_ATTR_RO(enabled);
>> static DEVICE_ATTR_RO(dpms);
>> static DEVICE_ATTR_RO(modes);
>> +static DEVICE_ATTR_RO(current_mode);
>>
>> static struct attribute *connector_dev_attrs[] = {
>> &dev_attr_status.attr,
>> &dev_attr_enabled.attr,
>> &dev_attr_dpms.attr,
>> &dev_attr_modes.attr,
>> + &dev_attr_current_mode.attr,
>> NULL
>> };
>>
>> --
>> 2.17.1
>>
>>
>>
>
--
Best Regard
黄家钗
Sandy Huang
Addr: 福州市鼓楼区铜盘路软件大道89号福州软件园A区21号楼(350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
Tel:+86 0591-87884919 8690
E-mail:hjc@rock-chips.com
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sysfs: Add to get current mode
2020-08-05 10:03 ` Huang Jiachai
@ 2020-08-05 11:26 ` daniel
0 siblings, 0 replies; 4+ messages in thread
From: daniel @ 2020-08-05 11:26 UTC (permalink / raw)
Cc: Tao Huang, David Airlie, Kever Yang, Linux Kernel Mailing List,
open list:ARM/Rockchip SoC...,
dri-devel, Thomas Zimmermann, Andy Yan
On Wed, Aug 05, 2020 at 06:03:15PM +0800, Huang Jiachai wrote:
> Hi Daniel
>
> 在 2020/8/5 17:36, Daniel Vetter 写道:
> > On Wed, Aug 5, 2020 at 10:37 AM Sandy Huang <hjc@rock-chips.com> wrote:
> > > add this node to get the current true mode.
> > >
> > > Signed-off-by: Sandy Huang <hjc@rock-chips.com>
> > Uh what's this for? Since it's sysfs, I guess there's something
> > parsing this, which means we'd kinda need to have that piece too.
> >
> > If it's just for debugging purposes, then we already have this
> > information in debugfs, together with everything else that's in the
> > atomic modeset state.
> > -Daniel
>
> yes, this is just for debug;
>
> and i get the information what i need from cat
> /sys/kernel/debug/dri/0/state, thanks.
Cool, sounds like this is resolved. And if you need any additional debug
information about display state, then best to extend that file. It comes
with driver hooks, so that you can include any additional driver stuff, or
outright read out registers and everything.
Cheers, Daniel
>
> > > ---
> > > drivers/gpu/drm/drm_sysfs.c | 30 ++++++++++++++++++++++++++++++
> > > 1 file changed, 30 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > > index 939f0032aab1..f39bcd34853b 100644
> > > --- a/drivers/gpu/drm/drm_sysfs.c
> > > +++ b/drivers/gpu/drm/drm_sysfs.c
> > > @@ -19,6 +19,7 @@
> > > #include <linux/slab.h>
> > >
> > > #include <drm/drm_connector.h>
> > > +#include <drm/drm_crtc.h>
> > > #include <drm/drm_device.h>
> > > #include <drm/drm_file.h>
> > > #include <drm/drm_modes.h>
> > > @@ -236,16 +237,45 @@ static ssize_t modes_show(struct device *device,
> > > return written;
> > > }
> > >
> > > +static ssize_t current_mode_show(struct device *device,
> > > + struct device_attribute *attr,
> > > + char *buf)
> > > +{
> > > + struct drm_connector *connector = to_drm_connector(device);
> > > + struct drm_display_mode *mode;
> > > + struct drm_crtc_state *crtc_state;
> > > + bool interlaced;
> > > + int written = 0;
> > > +
> > > + if (!connector->state || !connector->state->crtc)
> > > + return written;
> > > +
> > > + crtc_state = connector->state->crtc->state;
> > > + if (!crtc_state)
> > > + return written;
> > > +
> > > + mode = &crtc_state->mode;
> > > +
> > > + interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
> > > + written += snprintf(buf + written, PAGE_SIZE - written, "%dx%d%s%d\n",
> > > + mode->hdisplay, mode->vdisplay,
> > > + interlaced ? "i" : "p", drm_mode_vrefresh(mode));
> > > +
> > > + return written;
> > > +}
> > > +
> > > static DEVICE_ATTR_RW(status);
> > > static DEVICE_ATTR_RO(enabled);
> > > static DEVICE_ATTR_RO(dpms);
> > > static DEVICE_ATTR_RO(modes);
> > > +static DEVICE_ATTR_RO(current_mode);
> > >
> > > static struct attribute *connector_dev_attrs[] = {
> > > &dev_attr_status.attr,
> > > &dev_attr_enabled.attr,
> > > &dev_attr_dpms.attr,
> > > &dev_attr_modes.attr,
> > > + &dev_attr_current_mode.attr,
> > > NULL
> > > };
> > >
> > > --
> > > 2.17.1
> > >
> > >
> > >
> >
> --
> Best Regard
>
> 黄家钗
> Sandy Huang
> Addr: 福州市鼓楼区铜盘路软件大道89号福州软件园A区21号楼(350003)
> No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
> Tel:+86 0591-87884919 8690
> E-mail:hjc@rock-chips.com
>
>
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-06 11:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 8:36 [PATCH] drm: sysfs: Add to get current mode Sandy Huang
2020-08-05 9:36 ` Daniel Vetter
2020-08-05 10:03 ` Huang Jiachai
2020-08-05 11:26 ` daniel
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).