FedeDP / Clightd

A linux bus interface that lets you change screen brightness, compute captured webcam frames brightness and change screen temperature.
GNU General Public License v3.0
81 stars 10 forks source link

[FEATURE REQ] Support for NV12 sensor format #113

Open dxwil opened 4 months ago

dxwil commented 4 months ago

Hi, I downloaded clight and through another issue found out that only 3 video formats are supported for the sensor. I'm running linux on an M1 Macbook Air and the built-in camera reports NV12 as the format. Is there any way for me to use clight with this built-in camera. Thanks

Driver Info: Driver name : apple-isp Card type : FaceTime HD Camera Bus info : platform:22a000000.isp Driver version : 6.8.7 Capabilities : 0x84200001 Video Capture Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format Priority: 2 Video input : 0 (apple-isp: ok) Format Video Capture: Width/Height : 1280/720 Pixel Format : 'NV12' (Y/UV 4:2:0) Field : None Bytes per Line : 1280 Size Image : 1382400 Colorspace : Rec. 709 Transfer Function : Rec. 709 YCbCr/HSV Encoding: Rec. 709 Quantization : Default (maps to Limited Range) Flags : Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (7680/256) Read buffers : 2

FedeDP commented 4 months ago

Hi! Thanks for opening this feat req! I will move this one to Clightd repo, since it belongs there :)

It should not be much work to support NV12, i can arrange that; would you be willing to help me test the implementation?

dxwil commented 4 months ago

Hi, totally missed your reply. Yes, I could definitely help test it.

dxwil commented 3 months ago

Good evening, not to rush or anything but are there any updates on this so far :)

FedeDP commented 3 months ago

I just opened https://github.com/FedeDP/Clightd/pull/115 :) can you test it?

dxwil commented 3 months ago

Installed it and this is the output, weirdly enough it doesn't even mention the sensor

clight --verbose Clightd found, version: 5.10-1cfe352. Disarmed timerfd on fd 9. AC screen backlight curve: y = -0.024825 + 0.191641x + -0.008928x^2 BL ^ ** ** * * * *
*
*
*---------->BR BATT screen backlight curve: y = -0.010629 + 0.153844x + -0.007284x^2 BL ^
***
**
*
*
*
*
*
*---------->BR Set timeout of 30s 0ns on fd 16. Keyboard backlight calibration supported. AC keyboard backlight curve: y = 0.998811 + -0.013086x + -0.008928x^2 BL ^ ** ** * * * *
*
*
+---------*>BR BATT keyboard backlight curve: y = 0.799371 + -0.008156x + -0.007284x^2 BL ^

** * * * *
*

+---------*>BR init(): Failed to get screen temperature. Failed to init. Killing module. Failed to create org.freedesktop.ScreenSaver dbus interface: Unknown error -1 Monitoring requests to org.freedesktop.ScreenSaver name owner. Disarmed timerfd on fd 40. AC cable disconnected. Laptop lid opened. Emitting 'AcState' property Disarmed timerfd on fd 43. Pausing SCREEN: TIMEOUT Emitting 'LidState' property Could not find location cache file.`

FedeDP commented 3 months ago

You can also quickly test through clightd dbus api: busctl call org.clightd.clightd /org/clightd/clightd/Sensor/Camera org.clightd.clightd.Sensor Capture "sis" "" 5 ""

dxwil commented 3 months ago

I get Call failed: Connection timed out

Also interesting: {gamma.c:61} Failed to init. Killing module.

dxwil commented 3 months ago

Mora logs, this time what clightd reports back when launching clight:

May 14 17:47:40 asahi systemd[1]: Starting clightd.service - Bus service to manage various screen related properties (gamma, dpms, backlight)... May 14 17:47:40 asahi systemd[1]: Started clightd.service - Bus service to manage various screen related properties (gamma, dpms, backlight). May 14 17:47:40 asahi clightd[6478]: ddca_get_display_info_list2 called before ddca_init2() or ddca_init() May 14 17:47:40 asahi libddcutil[6478]: Initializing libddcutil. ddcutil version: 2.1.2, shared library: /usr/lib64/libddcutil.so.5.1.1 May 14 17:47:40 asahi libddcutil[6478]: Library initialization complete. May 14 17:47:40 asahi clightd[6478]: failed to set gamma table May 14 17:47:40 asahi clightd[6478]: failed to create gamma table

dxwil commented 3 months ago

You can also quickly test through clightd dbus api: busctl call org.clightd.clightd /org/clightd/clightd/Sensor/Camera org.clightd.clightd.Sensor Capture "sis" "" 5 ""

Actually now, after a reboot, I'm getting a new message: Call failed: No such device

dxwil commented 3 months ago

Good evening, any news on this? I really want to get it to work.

FedeDP commented 3 months ago

Hi! Sorry, haven't had the time to look into it :/

Actually now, after a reboot, I'm getting a new message:

Are you sure you are running Clightd from the HEAD of the linked PR now?

FedeDP commented 3 months ago

Anyway, reading https://stackoverflow.com/tags/nv12-nv21/info and https://paulbourke.net/dataformats/nv12/ it seems like NV12 should be very similar yo yuyv, already supported (considering Clightd only cares about intensity).

dxwil commented 3 months ago

Hi! Sorry, haven't had the time to look into it :/

Actually now, after a reboot, I'm getting a new message: Are you sure you are running Clightd from the HEAD of the linked PR now?

In the clight log it shows the clightd version and commit, which is the same as the one in that branch. At this point I have no idea what's going on. When I launch clight it says absolutely nothing about a sensor, I've looked at other people's logs and there's always something to do with a sensor, and I also remember the old version said that my sensor is not detected or something like that. Now there's simply nothing.

FedeDP commented 3 months ago

In the clight log it shows the clightd version and commit,

Yes i saw that! I thought that perhaps after the reboot the original Clightd was running instead of the one from the PR head. Never mind :)

Can you share the whole Clight log file (https://github.com/FedeDP/Clight/wiki/FAQ#where-is-clight-log) ?

dxwil commented 3 months ago

(W)[10:55:06]{config.c:408} Config file /home/dxwil/.config/clight.conf not found.

Clight

Starting options:

GENERIC

BACKLIGHT

SENSOR

KEYBOARD

GAMMA

DAYTIME

DIMMER

DPMS

SCREEN

INHIBIT

(I)[10:55:06]{main.c:145} Clightd found, version: 5.10-1cfe352. (I)[10:55:06]{keyboard.c:159} Keyboard backlight calibration supported. (W)[10:55:06]{gamma.c:61} Failed to init. Killing module. (I)[10:55:06]{interface.c:176} Monitoring requests to org.freedesktop.ScreenSaver name owner. (I)[10:55:06]{upower.c:55} AC cable disconnected. (I)[10:55:06]{upower.c:66} Laptop lid opened. (I)[10:55:06]{location.c:107} New location received: 48.11, 11.61. (I)[10:55:06]{daytime.c:197} Next alarm due to: Mon May 20 20:19:00 2024

And then after that last message it hangs