building mxc_hdmi as a kernel module instead of a built-in

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

building mxc_hdmi as a kernel module instead of a built-in

Jump to solution
3,729 Views
rob_mclean
Contributor IV

I'm trying to configure a 4.18 Linux Kernel so that the mxc_hdmi driver is a kernel module instead of a built-in, like so: CONFIG_FB_MXC_HDMI=m instead of CONFIG_FB_MXC_HDMI=y.

When I did that I got these errors:

In file included from drivers/video/fbdev/mxc/mxcfb_hx8369_wvga.c:34:
drivers/video/fbdev/mxc/mipi_dsi.h:138:2: error: #error "Please configure MIPI LCD panel, we cannot find one!"
#error "Please configure MIPI LCD panel, we cannot find one!"
^~~~~
make[4]: *** [scripts/Makefile.build:321: drivers/video/fbdev/mxc/mxcfb_hx8369_wvga.o] Error 1
make[4]: *** Waiting for unfinished jobs....
In file included from drivers/video/fbdev/mxc/mipi_dsi.c:35:
drivers/video/fbdev/mxc/mipi_dsi.h:138:2: error: #error "Please configure MIPI LCD panel, we cannot find one!"
#error "Please configure MIPI LCD panel, we cannot find one!"
^~~~~
make[4]: *** [scripts/Makefile.build:321: drivers/video/fbdev/mxc/mipi_dsi.o] Error 1
In file included from drivers/video/fbdev/mxc/mxc_hdmi.c:21:
./include/linux/module.h:130:42: error: redefinition of ‘__inittest’
static inline initcall_t __maybe_unused __inittest(void) \
^~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2986:1: note: in expansion of macro ‘module_init’
module_init(mxc_hdmi_i2c_init);
^~~~~~~~~~~
./include/linux/module.h:130:42: note: previous definition of ‘__inittest’ was here
static inline initcall_t __maybe_unused __inittest(void) \
^~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2922:1: note: in expansion of macro ‘module_init’
module_init(mxc_hdmi_init);
^~~~~~~~~~~
./include/linux/module.h:132:6: error: redefinition of ‘init_module’
int init_module(void) __attribute__((alias(#initfn)));
^~~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2986:1: note: in expansion of macro ‘module_init’
module_init(mxc_hdmi_i2c_init);
^~~~~~~~~~~
./include/linux/module.h:132:6: note: previous definition of ‘init_module’ was here
int init_module(void) __attribute__((alias(#initfn)));
^~~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2922:1: note: in expansion of macro ‘module_init’
module_init(mxc_hdmi_init);
^~~~~~~~~~~
./include/linux/module.h:136:42: error: redefinition of ‘__exittest’
static inline exitcall_t __maybe_unused __exittest(void) \
^~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2987:1: note: in expansion of macro ‘module_exit’
module_exit(mxc_hdmi_i2c_exit);
^~~~~~~~~~~
./include/linux/module.h:136:42: note: previous definition of ‘__exittest’ was here
static inline exitcall_t __maybe_unused __exittest(void) \
^~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2935:1: note: in expansion of macro ‘module_exit’
module_exit(mxc_hdmi_exit);
^~~~~~~~~~~
./include/linux/module.h:138:7: error: redefinition of ‘cleanup_module’
void cleanup_module(void) __attribute__((alias(#exitfn)));
^~~~~~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2987:1: note: in expansion of macro ‘module_exit’
module_exit(mxc_hdmi_i2c_exit);
^~~~~~~~~~~
./include/linux/module.h:138:7: note: previous definition of ‘cleanup_module’ was here
void cleanup_module(void) __attribute__((alias(#exitfn)));
^~~~~~~~~~~~~~
drivers/video/fbdev/mxc/mxc_hdmi.c:2935:1: note: in expansion of macro ‘module_exit’
module_exit(mxc_hdmi_exit);
^~~~~~~~~~~

The "redefinition" of "module_init" and "module_exit" pointed me at the file drivers/video/fbdev/mxc/mxc_hdmi.c which contains 2 driver modules in the source file.  Those 2 drivers are "mxc_hdmi " and "mxc_hdmi_i2c".

From what I read of the module.h include file, I think there can only be one call to "module_init" and "module_exit" per source code file.

That brings me to my question...

Were the mxc_hdmi and mxc_hdmi_i2c drivers never intended to be built as kernel modules, or am I just the first one to ever try doing this?

If there is no larger problem with building these drivers as kernel modules, I was planning to either pull the "mxc_hdmi_i2c" driver functions into a separate source file and add that to the build, or combine the 2 drivers into the mxc_hdmi driver since the i2c driver doesn't seem to be doing much.

Labels (3)
0 Kudos
Reply
1 Solution
3,677 Views
rob_mclean
Contributor IV

I've been testing the attached patch to my 4.18.45 kernel for a few days now.  It built properly, produced the .ko files I wanted.  The kernel modules works the same as the built-in drivers did, and it has worked on several different copies of the same HW design that I've tested it with.

These changes are part of several other changes, and I haven't tested the changes on the unmodified versions of the files.  But I think they provided enough proof to me that splitting out the mxc_hdmi_i2c driver from the mxc_hdmi.c source code can be done, and does allow the driver to be built as a kernel module instead of as a built-in driver.

BTW I did need to add these lines to my /etc/system/modules-load.d/modules.conf file to get the modules to load.  I expected that, but documenting it here might help people get a jump start on using this patch if they were unaware of it.

mxc_hdmi_i2c
mxc_hdmi
mxc_hdmi-cec
ldb
mxc_ipuv3_fb

 

View solution in original post

0 Kudos
Reply
3 Replies
3,705 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

FB_MXC_HDMI depends on FB_MXC_SYNC_PANEL, MXC_IPU_V3 ,I2C

You need using make menuconfig  to open  FB_MXC_SYNC_PANEL, MXC_IPU_V3(default is n)

Then you can select it to Y

0 Kudos
Reply
3,699 Views
rob_mclean
Contributor IV

What you've suggested is what I have been doing for quite a while.  The driver builds and HDMI works just fine that way.  What I want to do now is build the drivers you've identified (and several others that are related) as kernel modules by selecting "M" instead of "Y" from make menuconfig.

What I discovered when I tried to do it that way is that the hdmi driver can not be built that way because there are 2 kernel drivers inside the mxc_hdmi.c file (see the error messages for more details).

I suspect that this limitation of those drivers that can be fixed by pulling the i2c driver out of the mxc_hdmi.c file and creating a new .c file with that code.  I don't know the history of this code, so there might have been a good reason for putting that i2c driver in with the HDMI driver, or this might be something wrong with the rest of my development environment.  So I'm left wondering...

  • Has anyone else succeeded in doing this?
  • Was there a good reason to combine those drivers in the same source file?
0 Kudos
Reply
3,678 Views
rob_mclean
Contributor IV

I've been testing the attached patch to my 4.18.45 kernel for a few days now.  It built properly, produced the .ko files I wanted.  The kernel modules works the same as the built-in drivers did, and it has worked on several different copies of the same HW design that I've tested it with.

These changes are part of several other changes, and I haven't tested the changes on the unmodified versions of the files.  But I think they provided enough proof to me that splitting out the mxc_hdmi_i2c driver from the mxc_hdmi.c source code can be done, and does allow the driver to be built as a kernel module instead of as a built-in driver.

BTW I did need to add these lines to my /etc/system/modules-load.d/modules.conf file to get the modules to load.  I expected that, but documenting it here might help people get a jump start on using this patch if they were unaware of it.

mxc_hdmi_i2c
mxc_hdmi
mxc_hdmi-cec
ldb
mxc_ipuv3_fb

 

0 Kudos
Reply