Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Kazinsal
Dec 13, 2011
if I had a time machine I'd go back to 1982 and reimplement unix for the 5150 just to head off all that USL v. everyone bullshit at the pass so we never got to a point where linux had a reason to be used by startups and dial-up ISPs in the 90s

also because I have a brain disease that makes that kind of thing fun

Adbot
ADBOT LOVES YOU

Beeftweeter
Jun 28, 2005

OFFICIAL #1 GNOME FAN

Kazinsal posted:

if I had a time machine I'd go back to 1982 and reimplement unix for the 5150 just to head off all that USL v. everyone bullshit at the pass so we never got to a point where linux had a reason to be used by startups and dial-up ISPs in the 90s

also because I have a brain disease that makes that kind of thing fun

great now we know who to blame if we're all suddenly using microsoft xenix on AT&T workstations

e: reconstitute the bell system while you're at it

Beeftweeter fucked around with this message at 14:26 on May 14, 2024

shackleford
Sep 4, 2006

alternatively this has already happened multiple times where time travelers keep going back to the '80s to start unix ports in order to dethrone Linux but all they succeed in doing is providing the necessary conditions for the commercial unix wars of the '90s which creates the space for Linux to dominate

like how time travelers keep going back in time to kill Hitler and keep failing

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

shackleford posted:

alternatively this has already happened multiple times where time travelers keep going back to the '80s to start unix ports in order to dethrone Linux but all they succeed in doing is providing the necessary conditions for the commercial unix wars of the '90s which creates the space for Linux to dominate

like how time travelers keep going back in time to kill Hitler and keep failing

there are no scenarios in which the unix wars do not happen

Sapozhnik
Jan 2, 2005

Nap Ghost
dudun dun dudun
dudun dun dudun
dudun dun dudun
dudun dun dudun

BlankSystemDaemon
Mar 13, 2009




Sapozhnik posted:

dudun dun dudun
dudun dun dudun
dudun dun dudun
dudun dun dudun

do do do, do do doooo
do do do, do do doooo dooooo

ryanrs
Jul 12, 2011

I installed Zoneminder on my little RockPro64 ARM server, and it seems to be doing fine, though the system isn't fully setup. It'll be capturing 1080p15 from 1 or 2 security cameras, which shouldn't be too demanding.

Here's the next part: I want to make a little Chromecast / Firestick device, an HDMI dongle, that displays the video feed from the zoneminder server. I want to do this with a Raspberry Pi Zero 2 W (quad core Cortex-A52 1 GHz, 512 MB RAM).

The Zero 2 W doesn't have the RAM to run Chrome in kiosk mode streaming video. Instead, it'll fetch jpgs and throw them up on HDMI using the kernel framebuffer (so no X Windows). So it'll be more like a slideshow, maybe 1 pic/second. Kinda like a digital picture frame of my garage.


But I can't do anything until tomorrow when my mini-HDMI cable arrives. So until then, I guess throw out suggestions and/or reasons this will suck.


For example, one thing that would be neat would be to tie Zoneminder's event system (motion detection) to an audio output on HDMI. Basically chime when motion is detected. Or maybe the live audio stream from the camera?

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
if I had a time machine, I would go back in time and standardize all OSes on \n-terminated lines

other than that I would change nothing

Perplx
Jun 26, 2004


Best viewed on Orgasma Plasma
Lipstick Apathy
null terminated strings are worse
also skip ascii and go straight to unicode

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

if I had a time machine, I would go back in time and standardize all OSes on \n-terminated lines

other than that I would change nothing

I would change all line endings to \n\r just to gently caress with everyone. :colbert:

ryanrs
Jul 12, 2011

ryanrs posted:

Here's the next part: I want to make a little Chromecast / Firestick device, an HDMI dongle, that displays the video feed from the zoneminder server. I want to do this with a Raspberry Pi Zero 2 W (quad core Cortex-A52 1 GHz, 512 MB RAM).

First enable the kernel framebuffer in config.txt.

code:
/boot/firmware/config.txt

Comment out to disable videocore. Needed for /dev/fb0
#dtoverlay=vc4-kms-v3d

Add stuff to make the framebuffer 32 bits/pixel (default is 16-bit color)
[all]
hdmi_pixel_encoding=2
hdmi_blanking=1
hdmi_drive=2
hdmi_group=2
hdmi_mode=69
Grab the most recent frame from Zonemonitor as a jpeg.
$ curl -so /tmp/frame.jpg 'http://192.168.5.30/cgi-bin/nph-zms?mode=single&monitor=1'

Use ImageMagick to convert to RGBX and copy to the framebuffer.
$ convert -resize 1920x1200 -background black -gravity center -extent 1920x1200 /tmp/frame.jpg bgra:/dev/fb0


This works and was really easy! The only downside is the speed: it takes about 0.75 seconds.

code:
time curl -so /tmp/frame.jpg 'http://192.168.5.30/cgi-bin/nph-zms?mode=single&monitor=1' && time convert -resize 1920x1200 -background black -gravity center -extent 1920x1200 /tmp/frame.jpg bgra:/tmp/frame.raw; time cat /tmp/frame.raw >/dev/fb0

real	0m0.227s
user	0m0.044s
sys	0m0.024s

real	0m0.486s
user	0m0.901s
sys	0m0.118s

real	0m0.022s
user	0m0.000s
sys	0m0.023s
0.277s to fetch the jpeg

0.486 to decode/resize the jpeg (this seems very slow)

0.022 to copy to the framebuffer

I copied that 'convert' command from some random webpage. Guess I need to look up exactly what it's doing, because 0.9 cpu-seconds sounds like a really long time to be decoding a single jpeg. It looks like it's even using two cores, ha ha.


So maybe ImageMagick is doing more work than I thought? Or maybe I need to turn the GPU back on and use that for jpoeg decoding? 0.9s seems so slow as to be broken, tho.

FAT32 SHAMER
Aug 16, 2012



speaking of zoneminder, I’ve been reading up on Shinobi and it seems neat. I’m not sure if I’d want to run it native or risk giving a dockerised version a go (they recommend the native installer over a docker instance). I have a 1070 next to my desk that could be handy for object detection, but given the video install walkthrough used a 3070 I’m worried a 1070 won’t cut it. I also haven’t looked any further into this yet lol

sb hermit
Dec 13, 2016





Without doing a lot of work and deep analysis, I would probably look at the following maybe:

  • See if a more lightweight data transfer mechanism is available than http
  • Try to do all the work in memory (maybe a tempfs) rather than saving things to disk (the sync might be taking precious time)
  • See if converting to bgra before doing image operations can help latency

saving things to disk is my best guess as to why there is so much latency

sb hermit
Dec 13, 2016





zoneminder just works, but it totally has engineer UI and I really wish it had an API that was more composable in order to allow me to jury-rig a better interface

maybe it’s improved since I last used it

FAT32 SHAMER
Aug 16, 2012



i saw a relatively recent post on reddit that said they gave zoneminder another try and was pleasantly surprised. I also saw a guide video for it of unknown age that showed a UI that was convoluted on purpose

spankmeister
Jun 15, 2008






FlapYoJacks posted:

I would change all line endings to \n\r just to gently caress with everyone. :colbert:

it's kind of wild that Windows ended up with CRLF line endings since itself and DOS and its ancestors before that even never had support for output to a teletype afaik.

sb hermit
Dec 13, 2016





I used an older deployment of zoneminder from a few years ago and everything is very logical.

I should have also put in a motion detection sensor because zoneminder’s system sees changing light levels (due to the natural movement of the sun) as movement so it took awhile to address that issue.

outhole surfer
Mar 18, 2003

i use frigate.

it has pretty dece object detection with a tpu. i got all kinds of kitty cat videos

also integrates nicely with home assistant

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

spankmeister posted:

it's kind of wild that Windows ended up with CRLF line endings since itself and DOS and its ancestors before that even never had support for output to a teletype afaik.

they did though

MS-DOS was originally QDOS, a very direct CP/M knockoff for 8086

and CP/M supported pretty much any serial terminal including teletypes because they were cheap, and also because the DEC operating systems it was modeled on supported teletypes and generally used CRLF too

UNIX also started out with teletype support, but it implemented things like automatic CR generation in the line discipline, which is part of why UNIX serial has “raw” and “cooked” modes

Kazinsal
Dec 13, 2011
yeah I think the original intellec that CP/M was written for was a dev box that intel said "just hook any ol ASCII terminal up to it, she'll be right" so CP/M just naturally assumed that any terminal I/O would need CR+LF

ryanrs
Jul 12, 2011

sb hermit posted:

I should have also put in a motion detection sensor because zoneminder’s system sees changing light levels (due to the natural movement of the sun) as movement so it took awhile to address that issue.

OK, remember back when I got USB working on the Aruba AP? That was to hook up my homemade motion sensor (search forums for "bear radar"). It combines passive thermal and active radar sensors to minimize false alarms. The Bear Radar will talk over USB to a monitoring program on the Aruba AP, which will hook up to zmtrigger somehow. But yes, I have thought of this and I have a homebrew motion detector with sensor fusion ready to go!


In jpeg decode news, I came across the promisingly-named libjpeg-turbo.
code:
ryan@raspberrypi:~ $ time djpeg -rgb /tmp/frame.jpg >/dev/fb0 

real	0m0.109s
user	0m0.097s
sys	0m0.012s
That's more like it! Though I think I'll write my own C program to call into libjpeg-turbo, because I want to do some trivial cropping and byte swizzling.


The framebuffer is shared with the console login. Which is actually great, since you can still plug in a keyboard and log in; you aren't locked out of the console. That will be handy a year from now when I've forgotten how this thing works.

For example, both of these commands will clear the screen. Physicists refer to this as tty-fb duality.
code:
dd if=/dev/zero of=/dev/fb0 

clear >/dev/console 


e: Looks like I'll be able to mmap /dev/fb0 and have libjpeg-turbo write to it as the output buffer. Though this is probably also the time to look at using Linux DRM instead of fbdev.

ryanrs fucked around with this message at 07:54 on May 16, 2024

ryanrs
Jul 12, 2011

code:
ryan@raspberrypi:~ $ time ./console-jpeg 
jpeg: 1920x1080 2 1

real	0m0.092s
user	0m0.063s
sys	0m0.029s
That's more reasonable for displaying a jpeg on the screen, although still not fast. But at least it's not slower than the network.

I wonder why ImageMagick was running 2 cores flat-out for 500ms when decoding my Zoneminder jpegs? How can their decoder be so poo poo, but also multithreaded? It's not blocking on i/o while trawling the filesystem for plugins, or sleeping. It is burning real user cpu-seconds some computation.

e: I guess it is the resizing? Stripping out the resize and centering improves the speed a lot.
code:
ryan@raspberrypi:~ $ time convert /tmp/frame.jpg bgra:/dev/fb0 

real	0m0.245s
user	0m0.183s
sys	0m0.061s
My program is still more than twice as fast, so I'll stick with it.

ryanrs fucked around with this message at 19:26 on May 16, 2024

spankmeister
Jun 15, 2008






seems like a waste to do all those exec's

why not write a little program in rust or something to do everything? heck even python (possibly with pypy) should be faster

ryanrs
Jul 12, 2011

spankmeister posted:

why not write a little program in C

:hmmyes:

Sapozhnik
Jan 2, 2005

Nap Ghost
https://archie.serialport.org/

somebody found a copy of the archie ftp search engine's source code and posted it online. they also host an instance, one would hope on a vm that is very heavily locked down.

BlankSystemDaemon
Mar 13, 2009




Sapozhnik posted:

https://archie.serialport.org/

somebody found a copy of the archie ftp search engine's source code and posted it online. they also host an instance, one would hope on a vm that is very heavily locked down.
i want them to add oscollect

ryanrs
Jul 12, 2011

fbdev vs drm

Linux Direct Rendering seems like it will take 3-5x as much C code, and run half the speed of the deprecated fbdev API. There is a LOT of boilerplate setting up memory buffers. The API is designed to support modern GPUs with separate RAM that needs to be DMAed back and forth across PCIexpress, which makes it very complicated. My ARM SoC does not have separate GPU RAM, but I gotta deal with this clumsy API anyway.

I think if I had several frames to display, then I wouldn't incur all the setup work every frame, and the runtime would be similar to fbdev. For a single frame, drm will probably never be as fast as fbdev.

That all sounds fairly terrible, but here is what DRM does better:
- 24-bit color using stock config.txt
- double buffering and vsync, no frame tearing
- multi-monitor support
- better cooperation with cnsole login, X windows

I will develop the DRM code a bit more. Maybe I'll start to like it.

shackleford
Sep 4, 2006

why not use SDL with the kmsdrm driver?

Sapozhnik
Jan 2, 2005

Nap Ghost
ehh i'm not an expert but i'm pretty sure you can mmap a drm buffer object just fine, the only difference between pcie and main memory buffers would be access latency. the boilerplate is certainly true but that's a consequence of a bunch of hardware complexity: you potentially have a bunch of displays, connectors, and signal generators connected to a graphics device connected in surprisingly diverse and constrained ways.

take a look at what plymouth does.

https://gitlab.freedesktop.org/plymouth/plymouth/-/blob/main/src/plugins/renderers/drm/plugin.c

Sapozhnik fucked around with this message at 01:28 on May 17, 2024

ryanrs
Jul 12, 2011

Plymouth's drm memory buffer boilerplate looks a lot like my own drm memory buffer boilerplate: ioctls, dumb buffers, mmap, drmModeAddFB, etc.

FlapYoJacks
Feb 12, 2009
Me: I understand this conversation! :woop:
Also me: I understand this conversation. :smith:

ryanrs
Jul 12, 2011

Goddamn, this DRM API is lacking some extremely basic documentation, like what the functions do and what their return values mean. For example:

quote:

Only a DRM master is allowed to perform mode-setting or modify core state and only one user can be DRM master at a time. See drmSetMaster(3) for information on how to become DRM master and what the limitations are.

But the drmSetMaster() man page hasn't been written yet. There are no comments in libdrm, either in the header or the source. I'm guessing it returns 0 on success and hopefully sets errno if something bad happens. Plymouth doesn't check the return value and Nvidia treats it like a nop.

I even checked to see if maybe the API was released recently, but no, it's been around for over a decade. Is there some other place I should be looking for docs?


Currently my program doesn't call drmSetMaster() at all, and the kernel seems happy to let me draw on the console as a non-root user on ssh. Maybe nobody implements this functionality?

Sapozhnik
Jan 2, 2005

Nap Ghost
I think it got replaced by the "render nodes" concept, it's mostly a legacy thing that xorg cares about at this point. I think.

These days you can have hardware that can scanout but not render and vice versa. So DRM is stuck being an api for two almost totally unrelated hardware blocks that have nothing in common other than passing buffers between each other, possibly via dma-buf wrapped in some other api like Wayland or whatever.

The mode setting /dev node requires privileged access (on desktop I believe systemd-logind passes fds to user processes and can forcefully revoke those fds using the new revoke system call) and the rendering /dev node or nodes plural do not require special access. Both kinds of dev node can be opened using libdrm although render nodes will be opened by hardware specific Mesa graphics drivers and not by applications directly. These access control mechanisms obsolete the old DRM master concept.

Disclaimer the above might be complete bullshit but this is my understanding of it

ryanrs
Jul 12, 2011

lol, once again lead astray by out-of-date docs and examples

Thanks, that does explain things re drmSetMaster(). The DRM example I copied causes heap corruption (double free), so I was looking to understand the API fundamentals a bit more, rather than guessing.

The drm-memory man page looks nice, so hopefully there's enough there to workout the bugs.

pseudorandom name
May 6, 2007

why are you writing a graphics driver?

FAT32 SHAMER
Aug 16, 2012



I enjoy reading their posts and then spending a lot of time on Google. I’m learning a lot more than I was while not RTFM’ing

mila kunis
Jun 10, 2011

pseudorandom name posted:

why are you writing a graphics driver?

why aren't you?

FAT32 SHAMER
Aug 16, 2012



last weekend I uninstalled Bazzite and went back to windows after having dumb issues with Helldivers 2. did some reading over the week while experiencing new and exciting issues with the game, this time on windows, and realised I need to see if I have the same issues in a different distro or image and then potentially dehumanise myself and face to Win11. installed Nobara tonight, mostly since it’s a low-touch gaming distro that had a handy welcome app that installed a bunch of crap that I hadn’t bothered to try yet (like proton ge since it made the steam window dance around and have weird onClick positioning). then it installed Nvidia drivers for me, with the latest version. I installed HD2 and squad and both ran better than on Bazzite, which already ran games better than on windows. and there was even my beloved gnome variant :3:

once work starts slowing down I’d like to tweak around a bit more with stuff and straight up keep windows off the new machine I’m building

edit: I don’t actually remember if it had been established that the other thread was the Linux gaming thread or not

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
Baziite
Nobara

what

Adbot
ADBOT LOVES YOU

FAT32 SHAMER
Aug 16, 2012



Bazzite is a fedora silverblue image, and Nobara is a fedora fork? flavour?, and both come out of the box ready for gaming, and do a pretty impressive job doing it

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply