Re: [PATCH xserver v2] dpms: Add support for DPMSInfoNotify event

2018-10-02 Thread Александр Волков

Patch for xcb-proto and a test program are applied.
The test program can be compiled by gcc -o dpmsnotify dpmsnotify.c -lxcb 
-lxcb-dpms
>From 00f7947121181fc98cb09e4b86e14bd4738958d0 Mon Sep 17 00:00:00 2001
From: Alexander Volkov 
Date: Mon, 1 Oct 2018 19:41:18 +0300
Subject: [PATCH] dpms: Add DPMSInfoNotify event

See the description in xorgproto repository.

Signed-off-by: Alexander Volkov 
---
 src/dpms.xml | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/dpms.xml b/src/dpms.xml
index 5581284..814a14e 100644
--- a/src/dpms.xml
+++ b/src/dpms.xml
@@ -26,7 +26,8 @@ sale, use or other dealings in this Software without prior written
 authorization from the authors.
 -->
 
+major-version="1" minor-version="2">
+  xproto
   
 
 
@@ -84,4 +85,20 @@ authorization from the authors.
   
 
   
+
+  
+ 0 
+  
+
+  
+
+  
+
+  
+
+
+
+
+
+  
 
-- 
2.17.0

#include 
#include 

#include 
#include 

int main()
{
xcb_connection_t*c;
xcb_generic_event_t *e;

/* Open the connection to the X server */
c = xcb_connect (NULL, NULL);

const struct xcb_query_extension_reply_t *dpms = xcb_get_extension_data(c, _dpms_id);
fprintf(stdout, "dpms present %d\n", dpms->present);

xcb_dpms_get_version_cookie_t version_cookie = xcb_dpms_get_version(c, XCB_DPMS_MAJOR_VERSION, XCB_DPMS_MINOR_VERSION);
xcb_dpms_get_version_reply_t *version_reply = xcb_dpms_get_version_reply(c, version_cookie, NULL);
fprintf(stdout, "dpms version %d.%d\n", version_reply->server_major_version, version_reply->server_minor_version);
free(version_reply);

xcb_dpms_select_input(c, XCB_DPMS_EVENT_MASK_INFO_NOTIFY);

xcb_flush (c);

while ((e = xcb_wait_for_event (c))) {
uint8_t response_type = e->response_type & ~0x80;
if (response_type == XCB_GE_GENERIC) {
xcb_dpms_info_notify_event_t *info = (xcb_dpms_info_notify_event_t *)e;
if (info->extension == dpms->major_opcode && info->event_type == XCB_DPMS_INFO_NOTIFY)
fprintf(stdout, "dpms state %d, power level %d\n", info->state, info->power_level);
}
free (e);
}

return 0;
}
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] [RFC] modesetting: add zaphod support (v2)

2015-11-23 Thread Александр Волков

27.07.2015 02:43, Dave Airlie пишет:

+modesettingEntPtr ms_ent_priv(ScrnInfoPtr scrn)
+{
+DevUnion *pPriv;
+modesettingPtr ms = modesettingPTR(scrn);
+pPriv = xf86GetEntityPrivate(ms->pEnt->index,
+ ms_entity_index);
+return pPriv->ptr;
+}



@@ -596,19 +626,25 @@ FreeRec(ScrnInfoPtr pScrn)
  pScrn->driverPrivate = NULL;
  
  if (ms->fd > 0) {

+modesettingEntPtr ms_ent;
  int ret;
  
-if (ms->pEnt->location.type == BUS_PCI)

-ret = drmClose(ms->fd);
-else
+ms_ent = ms_ent_priv(pScrn);
prefer_shadow);



diff --git a/hw/xfree86/drivers/modesetting/driver.h 
b/hw/xfree86/drivers/modesetting/driver.h
...
  
  #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))


Calling ms_ent_priv() after setting pScrn->driverPrivate to NULL causes 
a segfault, because modesettingPTR() in ms_ent_priv() returns NULL.

For example, the segfault happens after unplugging a USB card.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel