Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VGA with VGA/USB 3.0 adapter to USB 2.0 !! #99

Open
Leogiamminola opened this issue Jan 4, 2025 · 4 comments
Open

VGA with VGA/USB 3.0 adapter to USB 2.0 !! #99

Leogiamminola opened this issue Jan 4, 2025 · 4 comments

Comments

@Leogiamminola
Copy link

Hello everyone!
Thank you in advance for the space to share and solve the problems and for your time in reading them.

I'm just starting out in programming and I'm trying something (which I understand isn't possible at the moment) but I'm sharing my doubts in case there's someone else out there with the same problem (or solution).

I am trying to connect an extra 3rd screen (in extension mode) to my HP 15ay notebook with Kali Linux as operating system (it only has one HDMI port to which I have a 2nd screen connected that works correctly and I only have USB 2.0 ports available...It also doesn't have USB C ports), via a VGA/USB 3.0 connector, knowing their incompatibilities and limitations...

The adapter is (lsusb) "Bus 002 Device 002: ID 1d5c:2000 Fresco Logic FL2000/FL2000DX VGA/DVI/HDMI Adapter" (which I understand is compatible with Kali Linux but I have problems with the drivers).

I installed the Driver for Fresco Logic FL2000, downloaded and installed the necessary dependencies

sudo apt update
sudo apt install git build-essential dkms linux-headers-linux-headers-6.11.2-rt-amd64

I cloned the driver repository

git clone https://github.com/FrescoLogic/FL2000.git

but it doesn't recognize the monitor and I can't compile...

I installed and edited the Kernel headers and the "Makefile" file

nano Makefile
KERNEL_PATH = /usr/src/linux-headers-linux-headers-6.11.2-rt-amd64

and when compiling the Kernel module and trying to load the module by running "make", it does not generate the file called fl2000.ko.
I understand It is necessary to adjust the driver code to be compatible with my kernel version...

After being able to solve almost all the errors (EXCEPT ONE!) with the help of chatgpt (such as problems associated with the get_user_pages, mmap_sem, vm_map_ram functions), modifying the fl2000_surface.c file, I understand that the problem I need to solve is with the "flags" (vm_flags) that are not defined or available in my kernel version...yet!

I wanted to know if there is an updated version of the driver code (FL2000) compatible with my kernel (since I don't want to compile it with an older version..)

So this is the error I get when running "make":

home/kali/FL2000/src/fl2000_fops.c: In function ‘set_vm_flags’:
/home/kali/FL2000/src/fl2000_fops.c:136:19: error: assignment of read-only member ‘vm_flags’
136 | vma->vm_flags = old_flags | flags;
| ^
/home/kali/FL2000/src/fl2000_fops.c: In function ‘clear_vm_flags’:
/home/kali/FL2000/src/fl2000_fops.c:141:19: error: assignment of read-only member ‘vm_flags’
141 | vma->vm_flags = old_flags & ~flags;
| ^
make[3]: *** [/usr/src/linux-headers-6.11.2-common-rt/scripts/Makefile.build:249: /home/kali/FL2000/src/fl2000_fops.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.11.2-common-rt/Makefile:1951: /home/kali/FL2000/src] Error 2
make[1]: *** [/usr/src/linux-headers-6.11.2-common-rt/Makefile:236: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.11.2-rt-amd64'
make: *** [Makefile:42: all] Error 2

And this is how I got the file "fl2000_fops.c :

// fl2000_fops.c
//
// (c)Copyright 2017, Fresco Logic, Incorporated.
//
// Purpose:
//

#include "fl2000_include.h"

#define USE_VM_INSERT_PFN 0

int fl2000_open(struct inode * inode, struct file * file)
{
int const minor = iminor(inode);
struct usb_interface * interface;
struct dev_ctx * dev_ctx;
int ret_val;
uint32_t open_count;

    ret_val = 0;
    interface = usb_find_interface(&fl2000_driver, minor);
    if (!interface) {
            dbg_msg(TRACE_LEVEL_ERROR, DBG_PNP,
                    "no interface?.");
            ret_val = -ENODEV;
            goto exit;
    }

    dev_ctx = usb_get_intfdata(interface);
    if (!dev_ctx) {
            dbg_msg(TRACE_LEVEL_ERROR, DBG_PNP,
                    "no dev_ctx?.");
            ret_val = -ENODEV;

goto exit;
}

    open_count = InterlockedIncrement(&dev_ctx->open_count);

    if (open_count > 1) {
            dbg_msg(TRACE_LEVEL_ERROR, DBG_PNP,
                    "open_count(%u) exceeds 1?", open_count);
            InterlockedDecrement(&dev_ctx->open_count);
            ret_val = -EBUSY;
            goto exit;
    }

    dbg_msg(TRACE_LEVEL_INFO, DBG_PNP, "open_count(%u)", open_count);
    dbg_msg(TRACE_LEVEL_INFO, DBG_PNP,
            "render_ctx: free(%u), ready(%u), busy(%u), surface(%u)",
            dev_ctx->render.free_list_count,
            dev_ctx->render.ready_list_count,
            dev_ctx->render.busy_list_count,
            dev_ctx->render.surface_list_count
            );

    file->private_data = dev_ctx;
    kref_get(&dev_ctx->kref);

exit:
return ret_val;
}

int fl2000_release(struct inode * inode, struct file * file)
{
struct dev_ctx * const dev_ctx = file->private_data;
struct render_ctx * render_ctx;
uint32_t i;
uint32_t open_count;

    if (dev_ctx == NULL)
            return -ENODEV;

    // wake up any sleeping process.
    //
    if (waitqueue_active(&dev_ctx->ioctl_wait_q)) {
            dbg_msg(TRACE_LEVEL_INFO, DBG_PNP,
                    "wake up pending process");
            wake_up_interruptible(&dev_ctx->ioctl_wait_q);
    }

    fl2000_render_stop(dev_ctx);
    fl2000_dongle_stop(dev_ctx);
    fl2000_surface_destroy_all(dev_ctx);

    /*
     * bug12414: on customer's platform, the underlying stack(eg. Asmed>
     * failed to complete the previously sent URB. We re-initialize
     * the render_ctx into default state during client file close opera>
     */
    if (dev_ctx->render.ready_list_count != 0) {
            dbg_msg(TRACE_LEVEL_INFO, DBG_PNP,
                    "ready_list_count(%u)",
                    dev_ctx->render.ready_list_count);
    }

    INIT_LIST_HEAD(&dev_ctx->render.free_list);
    spin_lock_init(&dev_ctx->render.free_list_lock);
    dev_ctx->render.free_list_count = 0;

    INIT_LIST_HEAD(&dev_ctx->render.ready_list);

spin_lock_init(&dev_ctx->render.ready_list_lock);
dev_ctx->render.ready_list_count = 0;

    INIT_LIST_HEAD(&dev_ctx->render.busy_list);
    spin_lock_init(&dev_ctx->render.busy_list_lock);
    dev_ctx->render.busy_list_count = 0;

    for (i = 0; i < NUM_OF_RENDER_CTX; i++) {
            render_ctx = &dev_ctx->render.render_ctx[i];

            INIT_LIST_HEAD(&render_ctx->list_entry);
            render_ctx->dev_ctx = dev_ctx;
            render_ctx->pending_count = 0;

            list_add_tail(&render_ctx->list_entry,
                    &dev_ctx->render.free_list);

            InterlockedIncrement(&dev_ctx->render.free_list_count);
    }
    open_count = InterlockedDecrement(&dev_ctx->open_count);
    dbg_msg(TRACE_LEVEL_INFO, DBG_PNP, "open_count(%u)", open_count);

    kref_put(&dev_ctx->kref, fl2000_module_free);

    return 0;

}

/*

  • this function is triggered from vm_mmap() in fl2000_ioctl_test_alloc_sur>
  • finish the last step of mapping system ram.
  • treat the memory as device ram.
    */
    #include <linux/mm.h> // Incluye las definiciones para estructuras de memor>

static void set_vm_flags(struct vm_area_struct *vma, unsigned long flags) {
unsigned long old_flags = vma->vm_flags;
vma->vm_flags = old_flags | flags;
}

static void clear_vm_flags(struct vm_area_struct *vma, unsigned long flags)>
unsigned long old_flags = vma->vm_flags;
vma->vm_flags = old_flags & ~flags;
}

#include <linux/fs.h>
#include <linux/kernel.h> // Para usar pr_info y pr_err

// Función auxiliar para configurar las banderas
static void fl2000_configure_vm_flags(struct vm_area_struct *vma, unsigned >
// Crear una copia temporal de vm_flags
unsigned long temp_flags = vma->vm_flags;

// Modificar la copia temporal
temp_flags |= set_flags;   // Establecer las banderas indicadas
temp_flags &= ~clear_flags; // Limpiar las banderas indicadas

// Reasignar al campo original (indirectamente, si es posible)
// Dependiendo de las restricciones del kernel, podrías necesitar un pa>
vma->vm_flags = temp_flags;

}

int fl2000_mmap(struct file *file, struct vm_area_struct *vma)
{
struct dev_ctx *const dev_ctx = file->private_data;
unsigned long len = vma->vm_end - vma->vm_start;
unsigned long num_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
unsigned int ret_val = 0;
unsigned int i;

pr_info("vm_start(0x%lx), vm_end(0x%lx), num_pages(0x%lx)\n",
        vma->vm_start, vma->vm_end, num_pages);

vma->vm_private_data = dev_ctx;

// Establecer las banderas manualmente en vma->vm_flags
static int fl2000_mmap(struct file *file, struct vm_area_struct *vma) {
// Otras operaciones de mmap
...
// Configurar las banderas
fl2000_configure_vm_flags(vma, VM_DONTEXPAND | VM_DONTDUMP, VM_PFNMAP);

// Continuar con el resto de la función
...
return 0;

}

for (i = 0; i < num_pages; i++) {
    unsigned long usr_addr = vma->vm_start + (i << PAGE_SHIFT);
    struct page *page = dev_ctx->start_page + i;

    ret_val = vm_insert_page(vma, usr_addr, page);
    if (ret_val) {
        pr_err("vm_insert_page(usr_addr 0x%lx), page_count(%u) failed %>
               usr_addr, page_count(page), ret_val);
        break;
    }
}

pr_info("vm_flags(0x%lx)\n", vma->vm_flags);
return ret_val;
}

Thank you very much in advance and I hope the problem can be understood and I would appreciate the solution just to know that it is possible!

Otherwise I will buy a DockStation or another PC, which is what I am trying to avoid, haha, thanks, greetings!

@Leogiamminola Leogiamminola changed the title VGA with VGA/USB 3.0 to USB 2.0 !! VGA with VGA/USB 3.0 adapter to USB 2.0 !! Jan 4, 2025
@CanNuhlar
Copy link

CanNuhlar commented Jan 4, 2025 via email

@CanNuhlar
Copy link

CanNuhlar commented Jan 4, 2025 via email

@Leogiamminola
Copy link
Author

:/ Ok I understand, then I will look for other possible solutions
thank you very much for the prompt and accurate response,
Thank you for your time and knowledge 😌​🙏​

@ulli-kroll
Copy link

I hope this helps, to understand the multiple issues,
on the hardware side with this deivce

#12

At this time, I had a working prov of DRM

The biggest limiting part is bandwith

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants