M+ & H bugs with Milestone Movements WW17
Stephen Jolley
All,
Thanks,
Stephen K. Jolley Yocto Project Program Manager ( Cell: (208) 244-4460 * Email: sjolley.yp.pm@...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Enhancements/Bugs closed WW17
Stephen Jolley
All,
Thanks,
Stephen K. Jolley Yocto Project Program Manager ( Cell: (208) 244-4460 * Email: sjolley.yp.pm@...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Current high bug count owners for Yocto Project 4.1
Stephen Jolley
All,
Thanks,
Stephen K. Jolley Yocto Project Program Manager ( Cell: (208) 244-4460 * Email: sjolley.yp.pm@...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: have busybox prompt for password in initramfs boot
Embedded 1
On 4/23/22 22:56, Embedded 1 wrote:oh, I see. thanks!when I boot my initramfs and run init=/bin/sh I'm not prompted for a
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Yocto Project Newcomer & Unassigned Bugs - Help Needed
Stephen Jolley
All,
The triage team is starting to try and collect up and classify bugs which a newcomer to the project would be able to work on in a way which means people can find them. They're being listed on the triage page under the appropriate heading: https://wiki.yoctoproject.org/wiki/Bug_Triage#Newcomer_Bugs Also please review: https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded and how to create a bugzilla account at: https://bugzilla.yoctoproject.org/createaccount.cgi The idea is these bugs should be straight forward for a person to help work on who doesn't have deep experience with the project. If anyone can help, please take ownership of the bug and send patches! If anyone needs help/advice there are people on irc who can likely do so, or some of the more experienced contributors will likely be happy to help too.
Also, the triage team meets weekly and does its best to handle the bugs reported into the Bugzilla. The number of people attending that meeting has fallen, as have the number of people available to help fix bugs. One of the things we hear users report is they don't know how to help. We (the triage team) are therefore going to start reporting out the currently 421 unassigned or newcomer bugs.
We're hoping people may be able to spare some time now and again to help out with these. Bugs are split into two types, "true bugs" where things don't work as they should and "enhancements" which are features we'd want to add to the system. There are also roughly four different "priority" classes right now, “3.5, “3.6”, "3.99" and "Future", the more pressing/urgent issues being in "4.1" and then “4.2”.
Please review this link and if a bug is something you would be able to help with either take ownership of the bug, or send me (sjolley.yp.pm@...) an e-mail with the bug number you would like and I will assign it to you (please make sure you have a Bugzilla account). The list is at: https://wiki.yoctoproject.org/wiki/Bug_Triage_Archive#Unassigned_or_Newcomer_Bugs
Thanks,
Stephen K. Jolley Yocto Project Program Manager ( Cell: (208) 244-4460 * Email: sjolley.yp.pm@...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [meta-cgl][PATCH] cgl-init-build-env: Use new variable LICENSE_FLAGS_ACCEPTED
Merged, thanks.
toggle quoted messageShow quoted text
On 4/23/2022 8:09 PM, Yu, Mingli wrote:
From: Mingli Yu <mingli.yu@...>
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [meta-cgl][PATCH 1/1] LICENSE: update to standard SPDX names
Merged, thanks.
toggle quoted messageShow quoted text
On 4/13/2022 1:59 PM, Joe Slater wrote:
Use convert-spdx-licenses.py to change LICENSE in two recipes.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [PATCH yocto-autobuilder-helper v8] Add a banner on the old documentation docs.
Abongwa Amahnui Bonalais
Hardcoding numbers like this isn’t a great idea. If the intention is to add the warning on all versions earlier than 3.2, then the regex approach that is commented out would be better. It most likely didn’t work as regex matching isn’t like shell/windows matching:pattern = r”^3\.1.*"A good solution would be to use packaging.version.parse, but that’s not a built-in module so would need to be added to the build. That can wait, the regex solution should be good.Hi Ross, I tried out the regex solution but I did not work and I also noticed that the 3.1.x doc versions on the documentation website already contains the banner I thought from 3.1.2 above were not outdate to, I am a little bit confused about which version is the latest.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[PATCH yocto-autobuilder-helper] config.json: test only command line images with x32
Alexander Kanavin
There has been a persistent stream of graphical failures on x32,
and there is doubt about whether x32 is at all used by anyone nowadays - let's reduce the scope of x32 QA, and perhaps later drop it altogether. Signed-off-by: Alexander Kanavin <alex.kanavin@...> --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 8893695..b571f25 100644 --- a/config.json +++ b/config.json @@ -529,11 +529,11 @@ "baselib = \"${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE', True) or 'INVALID'), True) or 'lib'}\"" ], "step1" : { - "BBTARGETS" : "core-image-minimal core-image-sato", + "BBTARGETS" : "core-image-minimal core-image-full-cmdline", "SANITYTARGETS" : "core-image-minimal:do_testimage" }, "step2" : { - "SANITYTARGETS" : "core-image-sato:do_testimage", + "SANITYTARGETS" : "core-image-full-cmdline:do_testimage", "extravars" : [ "TEST_SUITES:append = ' x32lib'" ] -- 2.35.1
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[meta-zephyr][PATCH] zephyr-openthread-rcp: Enable Thread 1.2 capabilities in RCP build
Stefan Schmidt
From: Stefan Schmidt <stefan.schmidt@...>
When running an up-to-date userspace component, like otbr-agent or ot-daemon, with Thread 1.2 enabled we need a firmware matching this capabilities. Signed-off-by: Stefan Schmidt <stefan.schmidt@...> --- .../recipes-kernel/zephyr-kernel/zephyr-openthread-rcp.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-openthr= ead-rcp.bb b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-openthr= ead-rcp.bb index 708e56a..6d3f860 100644 --- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-openthread-rcp= .bb +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-openthread-rcp= .bb @@ -2,7 +2,7 @@ include zephyr-sample.inc =20 ZEPHYR_SRC_DIR =3D "${S}/samples/net/openthread/coprocessor" =20 -EXTRA_OECMAKE +=3D "-DCONF_FILE=3D"prj.conf overlay-rcp.conf overlay-usb= -nrf-br.conf" -DDTC_OVERLAY_FILE=3D"usb.overlay"" +EXTRA_OECMAKE +=3D "-DCONF_FILE=3D"prj.conf overlay-rcp.conf overlay-usb= -nrf-br.conf" -DDTC_OVERLAY_FILE=3D"usb.overlay" -DCONFIG_OPENTHREAD_THRE= AD_VERSION_1_2=3Dy" =20 # The overlay config and OpenThread itself imposes some specific require= ments # towards the boards (e.g. flash layout and ieee802154 radio) so we need= to --=20 2.35.1
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: QA notification for completed autobuilder build (yocto-3.3.6.rc1)
Teoh, Jay Shen
Hello everyone,
toggle quoted messageShow quoted text
This is the full report for yocto-3.3.6.rc1: https://git.yoctoproject.org/cgit/cgit.cgi/yocto-testresults-contrib/tree/?h=intel-yocto-testresults ======= Summary ======== No high milestone defects. No new issue found. Thanks, Jay
-----Original Message-----
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: have busybox prompt for password in initramfs boot
Michael Opdenacker
Hello
On 4/23/22 22:56, Embedded 1 wrote: when I boot my initramfs and run init=/bin/sh I'm not prompted for a That's what you get when you use /bin/sh as the init process. Instead, you could use the normal init program built in your image (which one it is, Systemd or BusyBox init?), and get it to run the getty program instead to get a login prompt. Cheers Michael. -- Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [PATCH yocto-autobuilder-helper v8] Add a banner on the old documentation docs.
Quentin Schulz
Hi Ross,
On 4/25/22 10:43, Ross Burton wrote: To be fair, the list of impacted versions for dunfell is finite, since we're talking about old docs that aren't regenerated anymore. Dunfell was migrated to Sphinx (and is thus regenerated by run-docs-build script) in 3.1.5. (So I think we're missing 3.1.4 in there.)+from logging import rootThe logging and re imports are unused, remove these. For Dunfell, this message will ultimately be replaced with the obsolete message common to all other old docs, in 2 years from now, when it's obsolete. Just to give more context, I'm not particularly pushing for anything here. Cheers, Quentin
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [PATCH yocto-autobuilder-helper v8] Add a banner on the old documentation docs.
+from logging import rootThe logging and re imports are unused, remove these. +Add a comment explaining why you need to add a <div> wrapping the main content. + # pattern = '^3.1*'Hardcoding numbers like this isn’t a great idea. If the intention is to add the warning on all versions earlier than 3.2, then the regex approach that is commented out would be better. It most likely didn’t work as regex matching isn’t like shell/windows matching: pattern = r”^3\.1.*" A good solution would be to use packaging.version.parse, but that’s not a built-in module so would need to be added to the build. That can wait, the regex solution should be good. A comment here explaining what the exclusion is for, and why 3.1, would be good. + dirs[:] = list(filter(lambda x: not x in exclude, dirs))No need for obvious comments + if filename.endswith('.html'):Obvious comment, again, and several times below. Ross IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: [psplash][RFC PATCH 00/14] Implement DRM backend
Alexander Kanavin
Hello Vasyl,
can you explain how this was tested? Is it possible to automate with qemu targets? Alex On Mon, 25 Apr 2022 at 10:00, Vasyl Vavrychuk <Vasyl.Vavrychuk@...> wrote:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[psplash][RFC PATCH 14/14] psplash-drm.c: Implement double buffering
Vasyl Vavrychuk
Based on
https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-double-buffered.c Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@...> --- psplash-drm.c | 176 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 140 insertions(+), 36 deletions(-) diff --git a/psplash-drm.c b/psplash-drm.c index 5e56286..fcb7507 100644 --- a/psplash-drm.c +++ b/psplash-drm.c @@ -29,6 +29,7 @@ #include <errno.h> #include <fcntl.h> #include <stdint.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -41,10 +42,12 @@ #define MIN(a,b) ((a) < (b) ? (a) : (b)) +struct modeset_buf; struct modeset_dev; static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); -static int modeset_create_fb(int fd, struct modeset_dev *dev); +static int modeset_create_fb(int fd, struct modeset_buf *buf); +static void modeset_destroy_fb(int fd, struct modeset_buf *buf); static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); static int modeset_open(int *out, const char *node); @@ -144,18 +147,45 @@ static int modeset_open(int *out, const char *node) * } */ -struct modeset_dev { - struct modeset_dev *next; +/* + * Previously, we used the modeset_dev objects to hold buffer informations, too. + * Technically, we could have split them but avoided this to make the + * example simpler. + * However, in this example we need 2 buffers. One back buffer and one front + * buffer. So we introduce a new structure modeset_buf which contains everything + * related to a single buffer. Each device now gets an array of two of these + * buffers. + * Each buffer consists of width, height, stride, size, handle, map and fb-id. + * They have the same meaning as before. + * + * Each device also gets a new integer field: front_buf. This field contains the + * index of the buffer that is currently used as front buffer / scanout buffer. + * In our example it can be 0 or 1. We flip it by using XOR: + * dev->front_buf ^= dev->front_buf + * + * Everything else stays the same. + */ +struct modeset_buf { uint32_t width; uint32_t height; uint32_t stride; uint32_t size; uint32_t handle; void *map; + uint32_t fb; +}; + +struct modeset_dev { + struct modeset_dev *next; + + uint32_t width; + uint32_t height; + + unsigned int front_buf; + struct modeset_buf bufs[2]; drmModeModeInfo mode; - uint32_t fb; uint32_t conn; uint32_t crtc; drmModeCrtc *saved_crtc; @@ -292,10 +322,15 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, return -EFAULT; } - /* copy the mode information into our device structure */ + /* copy the mode information into our device structure and into both + * buffers */ memcpy(&dev->mode, &conn->modes[0], sizeof(dev->mode)); dev->width = conn->modes[0].hdisplay; dev->height = conn->modes[0].vdisplay; + dev->bufs[0].width = dev->width; + dev->bufs[0].height = dev->height; + dev->bufs[1].width = dev->width; + dev->bufs[1].height = dev->height; fprintf(stderr, "mode for connector %u is %ux%u\n", conn->connector_id, dev->width, dev->height); @@ -307,14 +342,30 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, return ret; } - /* create a framebuffer for this CRTC */ - ret = modeset_create_fb(fd, dev); + /* create framebuffer #1 for this CRTC */ + ret = modeset_create_fb(fd, &dev->bufs[0]); if (ret) { fprintf(stderr, "cannot create framebuffer for connector %u\n", conn->connector_id); return ret; } + /* create framebuffer #2 for this CRTC */ + ret = modeset_create_fb(fd, &dev->bufs[1]); + if (ret) { + fprintf(stderr, "cannot create framebuffer for connector %u\n", + conn->connector_id); + modeset_destroy_fb(fd, &dev->bufs[0]); + return ret; + } + + if (dev->bufs[0].size != dev->bufs[1].size) { + fprintf(stderr, "front buffer size %" PRIu32 " does not match " + "back buffer size %" PRIu32 "\n", + dev->bufs[0].size, dev->bufs[1].size); + return -1; + } + return 0; } @@ -441,7 +492,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, * memory directly via the dev->map memory map. */ -static int modeset_create_fb(int fd, struct modeset_dev *dev) +static int modeset_create_fb(int fd, struct modeset_buf *buf) { struct drm_mode_create_dumb creq; struct drm_mode_destroy_dumb dreq; @@ -450,8 +501,8 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) /* create dumb buffer */ memset(&creq, 0, sizeof(creq)); - creq.width = dev->width; - creq.height = dev->height; + creq.width = buf->width; + creq.height = buf->height; creq.bpp = 32; ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq); if (ret < 0) { @@ -459,13 +510,13 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) errno); return -errno; } - dev->stride = creq.pitch; - dev->size = creq.size; - dev->handle = creq.handle; + buf->stride = creq.pitch; + buf->size = creq.size; + buf->handle = creq.handle; /* create framebuffer object for the dumb-buffer */ - ret = drmModeAddFB(fd, dev->width, dev->height, 24, 32, dev->stride, - dev->handle, &dev->fb); + ret = drmModeAddFB(fd, buf->width, buf->height, 24, 32, buf->stride, + buf->handle, &buf->fb); if (ret) { fprintf(stderr, "cannot create framebuffer (%d): %m\n", errno); @@ -475,7 +526,7 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) /* prepare buffer for memory mapping */ memset(&mreq, 0, sizeof(mreq)); - mreq.handle = dev->handle; + mreq.handle = buf->handle; ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq); if (ret) { fprintf(stderr, "cannot map dumb buffer (%d): %m\n", @@ -485,9 +536,9 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) } /* perform actual memory mapping */ - dev->map = mmap(0, dev->size, PROT_READ | PROT_WRITE, MAP_SHARED, + buf->map = mmap(0, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mreq.offset); - if (dev->map == MAP_FAILED) { + if (buf->map == MAP_FAILED) { fprintf(stderr, "cannot mmap dumb buffer (%d): %m\n", errno); ret = -errno; @@ -495,23 +546,73 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) } /* clear the framebuffer to 0 */ - memset(dev->map, 0, dev->size); + memset(buf->map, 0, buf->size); return 0; err_fb: - drmModeRmFB(fd, dev->fb); + drmModeRmFB(fd, buf->fb); err_destroy: memset(&dreq, 0, sizeof(dreq)); - dreq.handle = dev->handle; + dreq.handle = buf->handle; drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); return ret; } +/* + * modeset_destroy_fb() is a new function. It does exactly the reverse of + * modeset_create_fb() and destroys a single framebuffer. The modeset.c example + * used to do this directly in modeset_cleanup(). + * We simply unmap the buffer, remove the drm-FB and destroy the memory buffer. + */ + +static void modeset_destroy_fb(int fd, struct modeset_buf *buf) +{ + struct drm_mode_destroy_dumb dreq; + + /* unmap buffer */ + munmap(buf->map, buf->size); + + /* delete framebuffer */ + drmModeRmFB(fd, buf->fb); + + /* delete dumb buffer */ + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = buf->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); +} + static void psplash_drm_flip(PSplashCanvas *canvas, int sync) { - (void)canvas; + PSplashDRM *drm = canvas->priv; + struct modeset_buf *buf; + int ret; + (void)sync; + + /* pick a back buffer */ + buf = &modeset_list->bufs[modeset_list->front_buf ^ 1]; + + /* set back buffer as a front buffer */ + ret = drmModeSetCrtc(drm->fd, modeset_list->crtc, buf->fb, 0, 0, + &modeset_list->conn, 1, &modeset_list->mode); + if (ret) { + fprintf(stderr, "cannot flip CRTC for connector %u (%d): %m\n", + modeset_list->conn, errno); + return; + } + + /* update front buffer index */ + modeset_list->front_buf ^= 1; + + /* update back buffer pointer */ + drm->canvas.data = modeset_list->bufs[modeset_list->front_buf ^ 1].map; + + /* Sync new front to new back when requested */ + if (sync) + memcpy(modeset_list->bufs[modeset_list->front_buf ^ 1].map, + modeset_list->bufs[modeset_list->front_buf].map, + modeset_list->bufs[0].size); } /* @@ -555,6 +656,7 @@ PSplashDRM* psplash_drm_new(int angle, int dev_id) int ret; char card[] = "/dev/dri/card0"; struct modeset_dev *iter; + struct modeset_buf *buf; if ((drm = malloc(sizeof(*drm))) == NULL) { perror("malloc"); @@ -583,18 +685,28 @@ PSplashDRM* psplash_drm_new(int angle, int dev_id) /* perform actual modesetting on each found connector+CRTC */ for (iter = modeset_list; iter; iter = iter->next) { iter->saved_crtc = drmModeGetCrtc(drm->fd, iter->crtc); - ret = drmModeSetCrtc(drm->fd, iter->crtc, iter->fb, 0, 0, + buf = &iter->bufs[iter->front_buf]; + ret = drmModeSetCrtc(drm->fd, iter->crtc, buf->fb, 0, 0, &iter->conn, 1, &iter->mode); if (ret) fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", iter->conn, errno); } - drm->canvas.data = modeset_list->map; + drm->canvas.data = modeset_list->bufs[modeset_list->front_buf ^ 1].map; drm->canvas.width = modeset_list->width; drm->canvas.height = modeset_list->height; drm->canvas.bpp = 32; - drm->canvas.stride = modeset_list->stride; + + if (modeset_list->bufs[0].stride != modeset_list->bufs[1].stride) { + fprintf(stderr, "front buffer stride %" PRIu32 " does not match" + " back buffer stride %" PRIu32 "\n", + modeset_list->bufs[0].stride, + modeset_list->bufs[1].stride); + goto error; + } + drm->canvas.stride = modeset_list->bufs[0].stride; + drm->canvas.angle = angle; drm->canvas.rgbmode = RGB888; @@ -614,7 +726,6 @@ error: void psplash_drm_destroy(PSplashDRM *drm) { struct modeset_dev *iter; - struct drm_mode_destroy_dumb dreq; if (!drm) return; @@ -635,16 +746,9 @@ void psplash_drm_destroy(PSplashDRM *drm) &iter->saved_crtc->mode); drmModeFreeCrtc(iter->saved_crtc); - /* unmap buffer */ - munmap(iter->map, iter->size); - - /* delete framebuffer */ - drmModeRmFB(drm->fd, iter->fb); - - /* delete dumb buffer */ - memset(&dreq, 0, sizeof(dreq)); - dreq.handle = iter->handle; - drmIoctl(drm->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + /* destroy framebuffers */ + modeset_destroy_fb(drm->fd, &iter->bufs[1]); + modeset_destroy_fb(drm->fd, &iter->bufs[0]); /* free allocated memory */ free(iter); -- 2.30.2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[psplash][RFC PATCH 09/14] Rework flip as function pointer
Vasyl Vavrychuk
It allows making parse_command and psplash_main independent of FB.
Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@...> --- psplash-draw.h | 3 +++ psplash-fb.c | 8 +++++--- psplash-fb.h | 3 --- psplash.c | 16 ++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/psplash-draw.h b/psplash-draw.h index 44546b0..292ddd9 100644 --- a/psplash-draw.h +++ b/psplash-draw.h @@ -36,6 +36,9 @@ typedef struct PSplashCanvas int green_length; int blue_offset; int blue_length; + + void *priv; + void (*flip)(struct PSplashCanvas *canvas, int sync); } PSplashCanvas; diff --git a/psplash-fb.c b/psplash-fb.c index dd50a5a..d41c477 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -18,9 +18,10 @@ psplash_wait_for_vsync(PSplashFB *fb) fprintf(stderr, "Error, FB vsync ioctl [%d]\n", err); } -void -psplash_fb_flip(PSplashFB *fb, int sync) +static void +psplash_fb_flip(PSplashCanvas *canvas, int sync) { + PSplashFB *fb = canvas->priv; char *tmp; if (fb->double_buffering) { @@ -154,7 +155,8 @@ psplash_fb_new (int angle, int fbdev_id) } memset (fb, 0, sizeof(PSplashFB)); - + fb->canvas.priv = fb; + fb->canvas.flip = psplash_fb_flip; fb->fd = -1; if ((fb->fd = open (fbdev, O_RDWR)) < 0) diff --git a/psplash-fb.h b/psplash-fb.h index 1b16bd5..979d23a 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -40,7 +40,4 @@ psplash_fb_destroy (PSplashFB *fb); PSplashFB* psplash_fb_new (int angle, int fbdev_id); -void -psplash_fb_flip(PSplashFB *fb, int sync); - #endif diff --git a/psplash.c b/psplash.c index c234d46..036dfb1 100644 --- a/psplash.c +++ b/psplash.c @@ -100,7 +100,7 @@ psplash_draw_progress(PSplashCanvas *canvas, int value) #endif /* PSPLASH_SHOW_PROGRESS_BAR */ static int -parse_command (PSplashFB *fb, char *string) +parse_command(PSplashCanvas *canvas, char *string) { char *command; @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_msg(&fb->canvas, arg); + psplash_draw_msg(canvas, arg); } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) @@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_progress(&fb->canvas, atoi(arg)); + psplash_draw_progress(canvas, atoi(arg)); } #endif else if (!strcmp(command,"QUIT")) @@ -132,12 +132,12 @@ parse_command (PSplashFB *fb, char *string) return 1; } - psplash_fb_flip(fb, 0); + canvas->flip(canvas, 0); return 0; } void -psplash_main (PSplashFB *fb, int pipe_fd, int timeout) +psplash_main(PSplashCanvas *canvas, int pipe_fd, int timeout) { int err; ssize_t length = 0; @@ -200,7 +200,7 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) continue; } - if (parse_command(fb, cmd)) + if (parse_command(canvas, cmd)) return; length -= cmdlen; @@ -345,9 +345,9 @@ main (int argc, char** argv) * text and progress bar change which overwrite the specific areas with every * update. */ - psplash_fb_flip(fb, 1); + canvas->flip(canvas, 1); - psplash_main (fb, pipe_fd, 0); + psplash_main(canvas, pipe_fd, 0); psplash_fb_destroy (fb); -- 2.30.2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[psplash][RFC PATCH 00/14] Implement DRM backend
Vasyl Vavrychuk
It is needed in case display does not support FB.
The missing part is drawing splash screen over all connected displays. I think there should be loop somewhere for this, but I am not sure which level is the best to put it. https://github.com/r1mikey/psplash-drm/blob/drm/implement-drm/psplash-draw.c has psplash_draw_initial(_one), psplash_draw_msg(_one) and psplash_draw_progress(_one) implementing loop over scanouts. I am think about doing the same. Vasyl Vavrychuk (14): Trim trailing spaces Fix 'unused-result' warnings Remove unused save_termios Remove 'psplash-fb.h' from 'psplash.h' Extract plot pixel from psplash-fb Extract draw rect/image from psplash-fb Extract draw font from psplash-fb psplash.c: Make psplash_draw_{msg,progress} independent of FB Rework flip as function pointer Import drm-howto modeset.c as psplash-drm.c Implement drm backend Reverse modeset_list psplash-drm.c: Allocate resources only for the first connector psplash-drm.c: Implement double buffering Makefile.am | 15 +- configure.ac | 9 + psplash-console.c | 34 +- psplash-console.h | 8 +- psplash-draw.c | 295 +++++++++++++++++ psplash-draw.h | 81 +++++ psplash-drm.c | 787 ++++++++++++++++++++++++++++++++++++++++++++++ psplash-drm.h | 17 + psplash-fb.c | 371 +++------------------- psplash-fb.h | 74 +---- psplash-systemd.c | 36 ++- psplash-write.c | 37 ++- psplash.c | 186 ++++++----- psplash.h | 7 +- 14 files changed, 1446 insertions(+), 511 deletions(-) create mode 100644 psplash-draw.c create mode 100644 psplash-draw.h create mode 100644 psplash-drm.c create mode 100644 psplash-drm.h -- 2.30.2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[psplash][RFC PATCH 10/14] Import drm-howto modeset.c as psplash-drm.c
Vasyl Vavrychuk
Imported as is from
repo: https://github.com/dvdhrm/docs.git branch: master commit: fc5c63f path: drm-howto/modeset.c Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@...> --- psplash-drm.c | 735 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 735 insertions(+) create mode 100644 psplash-drm.c diff --git a/psplash-drm.c b/psplash-drm.c new file mode 100644 index 0000000..c9a9f5c --- /dev/null +++ b/psplash-drm.c @@ -0,0 +1,735 @@ +/* + * modeset - DRM Modesetting Example + * + * Written 2012 by David Rheinsberg <david.rheinsberg@...> + * Dedicated to the Public Domain. + */ + +/* + * DRM Modesetting Howto + * This document describes the DRM modesetting API. Before we can use the DRM + * API, we have to include xf86drm.h and xf86drmMode.h. Both are provided by + * libdrm which every major distribution ships by default. It has no other + * dependencies and is pretty small. + * + * Please ignore all forward-declarations of functions which are used later. I + * reordered the functions so you can read this document from top to bottom. If + * you reimplement it, you would probably reorder the functions to avoid all the + * nasty forward declarations. + * + * For easier reading, we ignore all memory-allocation errors of malloc() and + * friends here. However, we try to correctly handle all other kinds of errors + * that may occur. + * + * All functions and global variables are prefixed with "modeset_*" in this + * file. So it should be clear whether a function is a local helper or if it is + * provided by some external library. + */ + +#define _GNU_SOURCE +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <time.h> +#include <unistd.h> +#include <xf86drm.h> +#include <xf86drmMode.h> + +struct modeset_dev; +static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev); +static int modeset_create_fb(int fd, struct modeset_dev *dev); +static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev); +static int modeset_open(int *out, const char *node); +static int modeset_prepare(int fd); +static void modeset_draw(void); +static void modeset_cleanup(int fd); + +/* + * When the linux kernel detects a graphics-card on your machine, it loads the + * correct device driver (located in kernel-tree at ./drivers/gpu/drm/<xy>) and + * provides two character-devices to control it. Udev (or whatever hotplugging + * application you use) will create them as: + * /dev/dri/card0 + * /dev/dri/controlID64 + * We only need the first one. You can hard-code this path into your application + * like we do here, but it is recommended to use libudev with real hotplugging + * and multi-seat support. However, this is beyond the scope of this document. + * Also note that if you have multiple graphics-cards, there may also be + * /dev/dri/card1, /dev/dri/card2, ... + * + * We simply use /dev/dri/card0 here but the user can specify another path on + * the command line. + * + * modeset_open(out, node): This small helper function opens the DRM device + * which is given as @node. The new fd is stored in @out on success. On failure, + * a negative error code is returned. + * After opening the file, we also check for the DRM_CAP_DUMB_BUFFER capability. + * If the driver supports this capability, we can create simple memory-mapped + * buffers without any driver-dependent code. As we want to avoid any radeon, + * nvidia, intel, etc. specific code, we depend on DUMB_BUFFERs here. + */ + +static int modeset_open(int *out, const char *node) +{ + int fd, ret; + uint64_t has_dumb; + + fd = open(node, O_RDWR | O_CLOEXEC); + if (fd < 0) { + ret = -errno; + fprintf(stderr, "cannot open '%s': %m\n", node); + return ret; + } + + if (drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0 || + !has_dumb) { + fprintf(stderr, "drm device '%s' does not support dumb buffers\n", + node); + close(fd); + return -EOPNOTSUPP; + } + + *out = fd; + return 0; +} + +/* + * As a next step we need to find our available display devices. libdrm provides + * a drmModeRes structure that contains all the needed information. We can + * retrieve it via drmModeGetResources(fd) and free it via + * drmModeFreeResources(res) again. + * + * A physical connector on your graphics card is called a "connector". You can + * plug a monitor into it and control what is displayed. We are definitely + * interested in what connectors are currently used, so we simply iterate + * through the list of connectors and try to display a test-picture on each + * available monitor. + * However, this isn't as easy as it sounds. First, we need to check whether the + * connector is actually used (a monitor is plugged in and turned on). Then we + * need to find a CRTC that can control this connector. CRTCs are described + * later on. After that we create a framebuffer object. If we have all this, we + * can mmap() the framebuffer and draw a test-picture into it. Then we can tell + * the DRM device to show the framebuffer on the given CRTC with the selected + * connector. + * + * As we want to draw moving pictures on the framebuffer, we actually have to + * remember all these settings. Therefore, we create one "struct modeset_dev" + * object for each connector+crtc+framebuffer pair that we successfully + * initialized and push it into the global device-list. + * + * Each field of this structure is described when it is first used. But as a + * summary: + * "struct modeset_dev" contains: { + * - @next: points to the next device in the single-linked list + * + * - @width: width of our buffer object + * - @height: height of our buffer object + * - @stride: stride value of our buffer object + * - @size: size of the memory mapped buffer + * - @handle: a DRM handle to the buffer object that we can draw into + * - @map: pointer to the memory mapped buffer + * + * - @mode: the display mode that we want to use + * - @fb: a framebuffer handle with our buffer object as scanout buffer + * - @conn: the connector ID that we want to use with this buffer + * - @crtc: the crtc ID that we want to use with this connector + * - @saved_crtc: the configuration of the crtc before we changed it. We use it + * so we can restore the same mode when we exit. + * } + */ + +struct modeset_dev { + struct modeset_dev *next; + + uint32_t width; + uint32_t height; + uint32_t stride; + uint32_t size; + uint32_t handle; + uint8_t *map; + + drmModeModeInfo mode; + uint32_t fb; + uint32_t conn; + uint32_t crtc; + drmModeCrtc *saved_crtc; +}; + +static struct modeset_dev *modeset_list = NULL; + +/* + * So as next step we need to actually prepare all connectors that we find. We + * do this in this little helper function: + * + * modeset_prepare(fd): This helper function takes the DRM fd as argument and + * then simply retrieves the resource-info from the device. It then iterates + * through all connectors and calls other helper functions to initialize this + * connector (described later on). + * If the initialization was successful, we simply add this object as new device + * into the global modeset device list. + * + * The resource-structure contains a list of all connector-IDs. We use the + * helper function drmModeGetConnector() to retrieve more information on each + * connector. After we are done with it, we free it again with + * drmModeFreeConnector(). + * Our helper modeset_setup_dev() returns -ENOENT if the connector is currently + * unused and no monitor is plugged in. So we can ignore this connector. + */ + +static int modeset_prepare(int fd) +{ + drmModeRes *res; + drmModeConnector *conn; + unsigned int i; + struct modeset_dev *dev; + int ret; + + /* retrieve resources */ + res = drmModeGetResources(fd); + if (!res) { + fprintf(stderr, "cannot retrieve DRM resources (%d): %m\n", + errno); + return -errno; + } + + /* iterate all connectors */ + for (i = 0; i < res->count_connectors; ++i) { + /* get information for each connector */ + conn = drmModeGetConnector(fd, res->connectors[i]); + if (!conn) { + fprintf(stderr, "cannot retrieve DRM connector %u:%u (%d): %m\n", + i, res->connectors[i], errno); + continue; + } + + /* create a device structure */ + dev = malloc(sizeof(*dev)); + memset(dev, 0, sizeof(*dev)); + dev->conn = conn->connector_id; + + /* call helper function to prepare this connector */ + ret = modeset_setup_dev(fd, res, conn, dev); + if (ret) { + if (ret != -ENOENT) { + errno = -ret; + fprintf(stderr, "cannot setup device for connector %u:%u (%d): %m\n", + i, res->connectors[i], errno); + } + free(dev); + drmModeFreeConnector(conn); + continue; + } + + /* free connector data and link device into global list */ + drmModeFreeConnector(conn); + dev->next = modeset_list; + modeset_list = dev; + } + + /* free resources again */ + drmModeFreeResources(res); + return 0; +} + +/* + * Now we dig deeper into setting up a single connector. As described earlier, + * we need to check several things first: + * * If the connector is currently unused, that is, no monitor is plugged in, + * then we can ignore it. + * * We have to find a suitable resolution and refresh-rate. All this is + * available in drmModeModeInfo structures saved for each crtc. We simply + * use the first mode that is available. This is always the mode with the + * highest resolution. + * A more sophisticated mode-selection should be done in real applications, + * though. + * * Then we need to find an CRTC that can drive this connector. A CRTC is an + * internal resource of each graphics-card. The number of CRTCs controls how + * many connectors can be controlled indepedently. That is, a graphics-cards + * may have more connectors than CRTCs, which means, not all monitors can be + * controlled independently. + * There is actually the possibility to control multiple connectors via a + * single CRTC if the monitors should display the same content. However, we + * do not make use of this here. + * So think of connectors as pipelines to the connected monitors and the + * CRTCs are the controllers that manage which data goes to which pipeline. + * If there are more pipelines than CRTCs, then we cannot control all of + * them at the same time. + * * We need to create a framebuffer for this connector. A framebuffer is a + * memory buffer that we can write XRGB32 data into. So we use this to + * render our graphics and then the CRTC can scan-out this data from the + * framebuffer onto the monitor. + */ + +static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev) +{ + int ret; + + /* check if a monitor is connected */ + if (conn->connection != DRM_MODE_CONNECTED) { + fprintf(stderr, "ignoring unused connector %u\n", + conn->connector_id); + return -ENOENT; + } + + /* check if there is at least one valid mode */ + if (conn->count_modes == 0) { + fprintf(stderr, "no valid mode for connector %u\n", + conn->connector_id); + return -EFAULT; + } + + /* copy the mode information into our device structure */ + memcpy(&dev->mode, &conn->modes[0], sizeof(dev->mode)); + dev->width = conn->modes[0].hdisplay; + dev->height = conn->modes[0].vdisplay; + fprintf(stderr, "mode for connector %u is %ux%u\n", + conn->connector_id, dev->width, dev->height); + + /* find a crtc for this connector */ + ret = modeset_find_crtc(fd, res, conn, dev); + if (ret) { + fprintf(stderr, "no valid crtc for connector %u\n", + conn->connector_id); + return ret; + } + + /* create a framebuffer for this CRTC */ + ret = modeset_create_fb(fd, dev); + if (ret) { + fprintf(stderr, "cannot create framebuffer for connector %u\n", + conn->connector_id); + return ret; + } + + return 0; +} + +/* + * modeset_find_crtc(fd, res, conn, dev): This small helper tries to find a + * suitable CRTC for the given connector. We have actually have to introduce one + * more DRM object to make this more clear: Encoders. + * Encoders help the CRTC to convert data from a framebuffer into the right + * format that can be used for the chosen connector. We do not have to + * understand any more of these conversions to make use of it. However, you must + * know that each connector has a limited list of encoders that it can use. And + * each encoder can only work with a limited list of CRTCs. So what we do is + * trying each encoder that is available and looking for a CRTC that this + * encoder can work with. If we find the first working combination, we are happy + * and write it into the @dev structure. + * But before iterating all available encoders, we first try the currently + * active encoder+crtc on a connector to avoid a full modeset. + * + * However, before we can use a CRTC we must make sure that no other device, + * that we setup previously, is already using this CRTC. Remember, we can only + * drive one connector per CRTC! So we simply iterate through the "modeset_list" + * of previously setup devices and check that this CRTC wasn't used before. + * Otherwise, we continue with the next CRTC/Encoder combination. + */ + +static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev) +{ + drmModeEncoder *enc; + unsigned int i, j; + int32_t crtc; + struct modeset_dev *iter; + + /* first try the currently conected encoder+crtc */ + if (conn->encoder_id) + enc = drmModeGetEncoder(fd, conn->encoder_id); + else + enc = NULL; + + if (enc) { + if (enc->crtc_id) { + crtc = enc->crtc_id; + for (iter = modeset_list; iter; iter = iter->next) { + if (iter->crtc == crtc) { + crtc = -1; + break; + } + } + + if (crtc >= 0) { + drmModeFreeEncoder(enc); + dev->crtc = crtc; + return 0; + } + } + + drmModeFreeEncoder(enc); + } + + /* If the connector is not currently bound to an encoder or if the + * encoder+crtc is already used by another connector (actually unlikely + * but lets be safe), iterate all other available encoders to find a + * matching CRTC. */ + for (i = 0; i < conn->count_encoders; ++i) { + enc = drmModeGetEncoder(fd, conn->encoders[i]); + if (!enc) { + fprintf(stderr, "cannot retrieve encoder %u:%u (%d): %m\n", + i, conn->encoders[i], errno); + continue; + } + + /* iterate all global CRTCs */ + for (j = 0; j < res->count_crtcs; ++j) { + /* check whether this CRTC works with the encoder */ + if (!(enc->possible_crtcs & (1 << j))) + continue; + + /* check that no other device already uses this CRTC */ + crtc = res->crtcs[j]; + for (iter = modeset_list; iter; iter = iter->next) { + if (iter->crtc == crtc) { + crtc = -1; + break; + } + } + + /* we have found a CRTC, so save it and return */ + if (crtc >= 0) { + drmModeFreeEncoder(enc); + dev->crtc = crtc; + return 0; + } + } + + drmModeFreeEncoder(enc); + } + + fprintf(stderr, "cannot find suitable CRTC for connector %u\n", + conn->connector_id); + return -ENOENT; +} + +/* + * modeset_create_fb(fd, dev): After we have found a crtc+connector+mode + * combination, we need to actually create a suitable framebuffer that we can + * use with it. There are actually two ways to do that: + * * We can create a so called "dumb buffer". This is a buffer that we can + * memory-map via mmap() and every driver supports this. We can use it for + * unaccelerated software rendering on the CPU. + * * We can use libgbm to create buffers available for hardware-acceleration. + * libgbm is an abstraction layer that creates these buffers for each + * available DRM driver. As there is no generic API for this, each driver + * provides its own way to create these buffers. + * We can then use such buffers to create OpenGL contexts with the mesa3D + * library. + * We use the first solution here as it is much simpler and doesn't require any + * external libraries. However, if you want to use hardware-acceleration via + * OpenGL, it is actually pretty easy to create such buffers with libgbm and + * libEGL. But this is beyond the scope of this document. + * + * So what we do is requesting a new dumb-buffer from the driver. We specify the + * same size as the current mode that we selected for the connector. + * Then we request the driver to prepare this buffer for memory mapping. After + * that we perform the actual mmap() call. So we can now access the framebuffer + * memory directly via the dev->map memory map. + */ + +static int modeset_create_fb(int fd, struct modeset_dev *dev) +{ + struct drm_mode_create_dumb creq; + struct drm_mode_destroy_dumb dreq; + struct drm_mode_map_dumb mreq; + int ret; + + /* create dumb buffer */ + memset(&creq, 0, sizeof(creq)); + creq.width = dev->width; + creq.height = dev->height; + creq.bpp = 32; + ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq); + if (ret < 0) { + fprintf(stderr, "cannot create dumb buffer (%d): %m\n", + errno); + return -errno; + } + dev->stride = creq.pitch; + dev->size = creq.size; + dev->handle = creq.handle; + + /* create framebuffer object for the dumb-buffer */ + ret = drmModeAddFB(fd, dev->width, dev->height, 24, 32, dev->stride, + dev->handle, &dev->fb); + if (ret) { + fprintf(stderr, "cannot create framebuffer (%d): %m\n", + errno); + ret = -errno; + goto err_destroy; + } + + /* prepare buffer for memory mapping */ + memset(&mreq, 0, sizeof(mreq)); + mreq.handle = dev->handle; + ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq); + if (ret) { + fprintf(stderr, "cannot map dumb buffer (%d): %m\n", + errno); + ret = -errno; + goto err_fb; + } + + /* perform actual memory mapping */ + dev->map = mmap(0, dev->size, PROT_READ | PROT_WRITE, MAP_SHARED, + fd, mreq.offset); + if (dev->map == MAP_FAILED) { + fprintf(stderr, "cannot mmap dumb buffer (%d): %m\n", + errno); + ret = -errno; + goto err_fb; + } + + /* clear the framebuffer to 0 */ + memset(dev->map, 0, dev->size); + + return 0; + +err_fb: + drmModeRmFB(fd, dev->fb); +err_destroy: + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = dev->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + return ret; +} + +/* + * Finally! We have a connector with a suitable CRTC. We know which mode we want + * to use and we have a framebuffer of the correct size that we can write to. + * There is nothing special left to do. We only have to program the CRTC to + * connect each new framebuffer to each selected connector for each combination + * that we saved in the global modeset_list. + * This is done with a call to drmModeSetCrtc(). + * + * So we are ready for our main() function. First we check whether the user + * specified a DRM device on the command line, otherwise we use the default + * /dev/dri/card0. Then we open the device via modeset_open(). modeset_prepare() + * prepares all connectors and we can loop over "modeset_list" and call + * drmModeSetCrtc() on every CRTC/connector combination. + * + * But printing empty black pages is boring so we have another helper function + * modeset_draw() that draws some colors into the framebuffer for 5 seconds and + * then returns. And then we have all the cleanup functions which correctly free + * all devices again after we used them. All these functions are described below + * the main() function. + * + * As a side note: drmModeSetCrtc() actually takes a list of connectors that we + * want to control with this CRTC. We pass only one connector, though. As + * explained earlier, if we used multiple connectors, then all connectors would + * have the same controlling framebuffer so the output would be cloned. This is + * most often not what you want so we avoid explaining this feature here. + * Furthermore, all connectors will have to run with the same mode, which is + * also often not guaranteed. So instead, we only use one connector per CRTC. + * + * Before calling drmModeSetCrtc() we also save the current CRTC configuration. + * This is used in modeset_cleanup() to restore the CRTC to the same mode as was + * before we changed it. + * If we don't do this, the screen will stay blank after we exit until another + * application performs modesetting itself. + */ + +int main(int argc, char **argv) +{ + int ret, fd; + const char *card; + struct modeset_dev *iter; + + /* check which DRM device to open */ + if (argc > 1) + card = argv[1]; + else + card = "/dev/dri/card0"; + + fprintf(stderr, "using card '%s'\n", card); + + /* open the DRM device */ + ret = modeset_open(&fd, card); + if (ret) + goto out_return; + + /* prepare all connectors and CRTCs */ + ret = modeset_prepare(fd); + if (ret) + goto out_close; + + /* perform actual modesetting on each found connector+CRTC */ + for (iter = modeset_list; iter; iter = iter->next) { + iter->saved_crtc = drmModeGetCrtc(fd, iter->crtc); + ret = drmModeSetCrtc(fd, iter->crtc, iter->fb, 0, 0, + &iter->conn, 1, &iter->mode); + if (ret) + fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", + iter->conn, errno); + } + + /* draw some colors for 5seconds */ + modeset_draw(); + + /* cleanup everything */ + modeset_cleanup(fd); + + ret = 0; + +out_close: + close(fd); +out_return: + if (ret) { + errno = -ret; + fprintf(stderr, "modeset failed with error %d: %m\n", errno); + } else { + fprintf(stderr, "exiting\n"); + } + return ret; +} + +/* + * A short helper function to compute a changing color value. No need to + * understand it. + */ + +static uint8_t next_color(bool *up, uint8_t cur, unsigned int mod) +{ + uint8_t next; + + next = cur + (*up ? 1 : -1) * (rand() % mod); + if ((*up && next < cur) || (!*up && next > cur)) { + *up = !*up; + next = cur; + } + + return next; +} + +/* + * modeset_draw(): This draws a solid color into all configured framebuffers. + * Every 100ms the color changes to a slightly different color so we get some + * kind of smoothly changing color-gradient. + * + * The color calculation can be ignored as it is pretty boring. So the + * interesting stuff is iterating over "modeset_list" and then through all lines + * and width. We then set each pixel individually to the current color. + * + * We do this 50 times as we sleep 100ms after each redraw round. This makes + * 50*100ms = 5000ms = 5s so it takes about 5seconds to finish this loop. + * + * Please note that we draw directly into the framebuffer. This means that you + * will see flickering as the monitor might refresh while we redraw the screen. + * To avoid this you would need to use two framebuffers and a call to + * drmModeSetCrtc() to switch between both buffers. + * You can also use drmModePageFlip() to do a vsync'ed pageflip. But this is + * beyond the scope of this document. + */ + +static void modeset_draw(void) +{ + uint8_t r, g, b; + bool r_up, g_up, b_up; + unsigned int i, j, k, off; + struct modeset_dev *iter; + + srand(time(NULL)); + r = rand() % 0xff; + g = rand() % 0xff; + b = rand() % 0xff; + r_up = g_up = b_up = true; + + for (i = 0; i < 50; ++i) { + r = next_color(&r_up, r, 20); + g = next_color(&g_up, g, 10); + b = next_color(&b_up, b, 5); + + for (iter = modeset_list; iter; iter = iter->next) { + for (j = 0; j < iter->height; ++j) { + for (k = 0; k < iter->width; ++k) { + off = iter->stride * j + k * 4; + *(uint32_t*)&iter->map[off] = + (r << 16) | (g << 8) | b; + } + } + } + + usleep(100000); + } +} + +/* + * modeset_cleanup(fd): This cleans up all the devices we created during + * modeset_prepare(). It resets the CRTCs to their saved states and deallocates + * all memory. + * It should be pretty obvious how all of this works. + */ + +static void modeset_cleanup(int fd) +{ + struct modeset_dev *iter; + struct drm_mode_destroy_dumb dreq; + + while (modeset_list) { + /* remove from global list */ + iter = modeset_list; + modeset_list = iter->next; + + /* restore saved CRTC configuration */ + drmModeSetCrtc(fd, + iter->saved_crtc->crtc_id, + iter->saved_crtc->buffer_id, + iter->saved_crtc->x, + iter->saved_crtc->y, + &iter->conn, + 1, + &iter->saved_crtc->mode); + drmModeFreeCrtc(iter->saved_crtc); + + /* unmap buffer */ + munmap(iter->map, iter->size); + + /* delete framebuffer */ + drmModeRmFB(fd, iter->fb); + + /* delete dumb buffer */ + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = iter->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + + /* free allocated memory */ + free(iter); + } +} + +/* + * I hope this was a short but easy overview of the DRM modesetting API. The DRM + * API offers much more capabilities including: + * - double-buffering or tripple-buffering (or whatever you want) + * - vsync'ed page-flips + * - hardware-accelerated rendering (for example via OpenGL) + * - output cloning + * - graphics-clients plus authentication + * - DRM planes/overlays/sprites + * - ... + * If you are interested in these topics, I can currently only redirect you to + * existing implementations, including: + * - plymouth (which uses dumb-buffers like this example; very easy to understand) + * - kmscon (which uses libuterm to do this) + * - wayland (very sophisticated DRM renderer; hard to understand fully as it + * uses more complicated techniques like DRM planes) + * - xserver (very hard to understand as it is split across many files/projects) + * + * But understanding how modesetting (as described in this document) works, is + * essential to understand all further DRM topics. + * + * Any feedback is welcome. Feel free to use this code freely for your own + * documentation or projects. + * + * - Hosted on http://github.com/dvdhrm/docs + * - Written by David Rheinsberg <david.rheinsberg@...> + */ -- 2.30.2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[psplash][RFC PATCH 03/14] Remove unused save_termios
Vasyl Vavrychuk
Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@...>
--- psplash-fb.h | 1 - psplash.h | 1 - 2 files changed, 2 deletions(-) diff --git a/psplash-fb.h b/psplash-fb.h index eafa293..6c4599c 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -22,7 +22,6 @@ typedef struct PSplashFB { int fd; struct fb_var_screeninfo fb_var; - struct termios save_termios; int type; int visual; int width, height; diff --git a/psplash.h b/psplash.h index 3739ca3..8e68b7b 100644 --- a/psplash.h +++ b/psplash.h @@ -32,7 +32,6 @@ #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> -#include <termios.h> #include <unistd.h> typedef uint8_t uint8; -- 2.30.2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|