sc0710 icon indicating copy to clipboard operation
sc0710 copied to clipboard

Adding support for kernel version >= 6.5.0

Open Darthbob opened this issue 1 year ago • 24 comments

So I'm completely new to driver development and working with C. I added the old videobuf-api to this project. I was able to compile on kernel v6.5.0 and v6.8.0. I also had to make some adjustments to the timestamp conversion. Fortunately, there are some helper functions. Compiling and adding the driver to the kernel works fine. When my Elgato card arrives, I can test whether it works.

Darthbob avatar Sep 12 '24 13:09 Darthbob

Hey,

were you able to test it? Because it seems not to work for me. I can see the device in OBS but it seems that there is no output

BlatrixFB avatar Oct 07 '24 16:10 BlatrixFB

Hi! Yes, I was able to get it running. But as far as I know you're only able to get it work with software like ffmpeg. In the Makefile are some example commands to get an output. I think the driver is not including all needed api's of v4l2. So that's why software like OBS cannot work with it. Sadly I was only getting a very low framerate with ffmpeg. The driver doesn't work for me as expected. Even after setting up a linux machine with the official supported kernel version, I had the same results.

Darthbob avatar Oct 07 '24 18:10 Darthbob

Hi, I am looking to spend time into this, is there anything I should be aware of other than HDR10 and V4L2?

lightspeed3m avatar Sep 17 '25 16:09 lightspeed3m

I haven't looked at a 6.x kernel, because most of my time is spent with RHEL kernels..... So I can't say for certain what you'll find.

I haven't worked on the project for a long time, so I don't recall what the story is with HDR metadata (needed) and obtaining that from the underlying hardware (of possible). I'd expect it to be available in the HDMI chip register map by default.

Don't break back compat with earlier kernels please, otherwise you're patches are welcome.

  • Steve

On Wed, Sep 17, 2025 at 12:53 PM Bassam @.***> wrote:

lightspeed3m left a comment (stoth68000/sc0710#22) https://github.com/stoth68000/sc0710/pull/22#issuecomment-3303832296

Hi, I am looking to spend time into this, is there anything I should be aware of other than HDR10 and V4L2?

— Reply to this email directly, view it on GitHub https://github.com/stoth68000/sc0710/pull/22#issuecomment-3303832296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEERBC6RFG345MWGOPKM633TGG2HAVCNFSM6AAAAACGY5RYPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMBTHAZTEMRZGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Steven Toth - Kernel Labs http://www.kernellabs.com

stoth68000 avatar Sep 17 '25 17:09 stoth68000

I haven't looked at a 6.x kernel, because most of my time is spent with RHEL kernels..... So I can't say for certain what you'll find. I haven't worked on the project for a long time, so I don't recall what the story is with HDR metadata (needed) and obtaining that from the underlying hardware (of possible). I'd expect it to be available in the HDMI chip register map by default. Don't break back compat with earlier kernels please, otherwise you're patches are welcome. - Steve On Wed, Sep 17, 2025 at 12:53 PM Bassam @.> wrote: lightspeed3m left a comment (stoth68000/sc0710#22) <#22 (comment)> Hi, I am looking to spend time into this, is there anything I should be aware of other than HDR10 and V4L2? — Reply to this email directly, view it on GitHub <#22 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEERBC6RFG345MWGOPKM633TGG2HAVCNFSM6AAAAACGY5RYPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMBTHAZTEMRZGY . You are receiving this because you are subscribed to this thread.Message ID: @.> -- Steven Toth - Kernel Labs http://www.kernellabs.com

Thank you for your reply. I will keep in mind to account for the existing kernel calls.

lightspeed3m avatar Sep 17 '25 18:09 lightspeed3m

I'm unable to get this to build, at least on 6.16.

~/os/sc0710) make
make -C /lib/modules/6.16.8-arch3-1/build M=/home/dusda/os/sc0710 modules
make[1]: Entering directory '/usr/lib/modules/6.16.8-arch3-1/build'
make[2]: Entering directory '/home/dusda/os/sc0710'
  CC [M]  sc0710-cards.o
  CC [M]  sc0710-core.o
sc0710-core.c:75:6: warning: no previous prototype for ‘sc_andor’ [-Wmissing-prototypes]
   75 | void sc_andor(struct sc0710_dev *dev, int bar, u32 reg, u32 mask, u32 value)
      |      ^~~~~~~~
  CC [M]  sc0710-i2c.o
sc0710-i2c.c: In function ‘sc0710_i2c_read_hdmi_status’:
sc0710-i2c.c:177:13: warning: unused variable ‘i’ [-Wunused-variable]
  177 |         int i;
      |             ^
  CC [M]  sc0710-dma-channel.o
  CC [M]  sc0710-dma-channels.o
  CC [M]  sc0710-dma-chains.o
  CC [M]  sc0710-dma-chain.o
  CC [M]  sc0710-things-per-second.o
  CC [M]  sc0710-video.o
sc0710-video.c: In function ‘vidioc_streamoff’:
sc0710-video.c:498:9: error: implicit declaration of function ‘del_timer’; did you mean ‘add_timer’? [-Wimplicit-function-declaration]
  498 |         del_timer(&ch->timeout);
      |         ^~~~~~~~~
      |         add_timer
sc0710-video.c: At top level:
sc0710-video.c:512:6: warning: no previous prototype for ‘sc0710_dma_free’ [-Wmissing-prototypes]
  512 | void sc0710_dma_free(struct videobuf_queue *q, struct sc0710_dma_channel *ch, struct sc0710_buffer *buf)
      |      ^~~~~~~~~~~~~~~
sc0710-video.c: In function ‘sc0710_vid_timeout’:
sc0710-video.c:826:41: error: implicit declaration of function ‘from_timer’; did you mean ‘mod_timer’? [-Wimplicit-function-declaration]
  826 |         struct sc0710_dma_channel *ch = from_timer(ch, t, timeout);
      |                                         ^~~~~~~~~~
      |                                         mod_timer
sc0710-video.c:826:59: error: ‘timeout’ undeclared (first use in this function); did you mean ‘timer_t’?
  826 |         struct sc0710_dma_channel *ch = from_timer(ch, t, timeout);
      |                                                           ^~~~~~~
      |                                                           timer_t
sc0710-video.c:826:59: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [/usr/lib/modules/6.16.8-arch3-1/build/scripts/Makefile.build:287: sc0710-video.o] Error 1
make[3]: *** [/usr/lib/modules/6.16.8-arch3-1/build/Makefile:2003: .] Error 2
make[2]: *** [/usr/lib/modules/6.16.8-arch3-1/build/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/home/dusda/os/sc0710'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.16.8-arch3-1/build'
make: *** [Makefile:14: all] Error 2

dusda avatar Sep 25 '25 23:09 dusda

@dusda On 6.17 I had to rename a few functions that had their names changed to get this compiled. Maybe if you do the same thing, it might work for you too?

diff --git a/sc0710-video.c b/sc0710-video.c
index 3f79cae..ff6768a 100644
--- a/sc0710-video.c
+++ b/sc0710-video.c
@@ -495,7 +495,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
                tm6200_capture_disconnect(chip->capture_pcm_substream);
 #endif
 
-       del_timer(&ch->timeout);
+       timer_delete(&ch->timeout);
 
        sc0710_dma_channels_stop(dev);
 
@@ -823,7 +823,7 @@ static void sc0710_vid_timeout(unsigned long data)
 #else
 static void sc0710_vid_timeout(struct timer_list *t)
 {
-       struct sc0710_dma_channel *ch = from_timer(ch, t, timeout);
+       struct sc0710_dma_channel *ch = timer_container_of(ch, t, timeout);
 #endif
        struct sc0710_dev *dev = ch->dev;
        struct sc0710_buffer *buf;

Archenoth avatar Nov 22 '25 00:11 Archenoth

@dusda On 6.17 I had to rename a few functions that had their names changed to get this compiled. Maybe if you do the same thing, it might work for you too?

diff --git a/sc0710-video.c b/sc0710-video.c
index 3f79cae..ff6768a 100644
--- a/sc0710-video.c
+++ b/sc0710-video.c
@@ -495,7 +495,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
                tm6200_capture_disconnect(chip->capture_pcm_substream);
 #endif
 
-       del_timer(&ch->timeout);
+       timer_delete(&ch->timeout);
 
        sc0710_dma_channels_stop(dev);
 
@@ -823,7 +823,7 @@ static void sc0710_vid_timeout(unsigned long data)
 #else
 static void sc0710_vid_timeout(struct timer_list *t)
 {
-       struct sc0710_dma_channel *ch = from_timer(ch, t, timeout);
+       struct sc0710_dma_channel *ch = timer_container_of(ch, t, timeout);
 #endif
        struct sc0710_dev *dev = ch->dev;
        struct sc0710_buffer *buf;

Is it fully working with this?

VixiKitsune avatar Nov 22 '25 01:11 VixiKitsune

@VixiKitsune Honestly, I'm not sure?

I was able to compile and load the module fine! (Since those two functions in my diff were just renames)

But I had to manually specify what my card was in my insmod (which indicates to me that the driver didn't really recognize my card) Your board isn't known (yet) to the driver.
Try to pick one of the existing card configs via card=n insmod option. 
Updating to the latest version might help as well.
Here is a list of valid choices for the card=n insmod option:
card=0: UNKNOWN/GENERIC
card=1: Elgato 4k60 Pro mk.2

And even after doing that, I haven't managed to get it to work!

But according to my box, my 4k pro was made in 2024, which was after the last commit in this repo, so I'm not sure if there's something broken in the code, or if there was another hardware revision and I just got unlucky (I notice the "mk.2" in the output above, but I don't see any indication of a revision on either the card or my box; lshw not giving any hints either)

tl;dr - this all could be a "me" problem

That all said, it you wanted to try it out yourself, the Makefile has the steps to load the module! (And some example ffmpeg commands to test with; which you can do while watching journalctl -f)

Archenoth avatar Nov 22 '25 01:11 Archenoth

Hi @Archenoth I'm in more or less the same boat as you. Can get it compiling, but not working. Some things of note - this driver is for the 4K60 Pro Mk. 2, but judging from the subsystem info (lcfa:0012), we both have the 4K Pro, which while confusingly named, is the successor to the 4K60 Pro Mk. 2. The 4K Pro could very well use different data structures to the 4K60 Pro Mk. 2, though being new to the Linux ecosystem I wouldn't even know where or how to start investigating this.

SaahilNZ avatar Nov 23 '25 06:11 SaahilNZ

The driver is for the Mk2. The Mk1 is a different chip.

VixiKitsune avatar Nov 23 '25 08:11 VixiKitsune