lcd framebuffer screen
This commit is contained in:
parent
fb900d2d40
commit
26d5529e2d
@ -3889,6 +3889,11 @@ CONFIG_imagefeature-hwcodecs=y
|
||||
# CONFIG_Init-manager-systemd is not set
|
||||
CONFIG_Init-manager-sysvinit=y
|
||||
|
||||
#
|
||||
# modules
|
||||
#
|
||||
CONFIG_tinylcd=y
|
||||
|
||||
#
|
||||
# user packages
|
||||
#
|
||||
|
@ -3,3 +3,4 @@
|
||||
|
||||
CONFIG_gpio-demo
|
||||
CONFIG_peekpoke
|
||||
CONFIG_tinylcd
|
||||
|
@ -106,8 +106,14 @@
|
||||
};
|
||||
};
|
||||
|
||||
&lcd_vtc {
|
||||
/* force to use gpu/drm/xlnx/xlnx_vtc.c rather than media/platform/xilinx/xilinx-vtc.c, which is used by TPG */
|
||||
compatible = "xlnx,bridge-v-tc-6.1";
|
||||
&amba_pl {
|
||||
lcd0: tinylcd {
|
||||
compatible = "tinysoc,tinylcd";
|
||||
xlnx,vtc = <&lcd_vtc>;
|
||||
dmas = <&lcd_vdma 0>;
|
||||
dma-names = "lcd-vdma";
|
||||
lcd-backlight = <&gpio0 67 GPIO_ACTIVE_HIGH>;
|
||||
lcd-reset = <&gpio0 61 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,79 @@
|
||||
CONFIG_VT_HW_CONSOLE_BINDING=y
|
||||
# CONFIG_VIDEO_XILINX_CFA is not set
|
||||
# CONFIG_VIDEO_XILINX_CRESAMPLE is not set
|
||||
# CONFIG_VIDEO_XILINX_REMAPPER is not set
|
||||
# CONFIG_VIDEO_XILINX_RGB2YUV is not set
|
||||
# CONFIG_VIDEO_XILINX_SCALER is not set
|
||||
# CONFIG_VIDEO_XILINX_SWITCH is not set
|
||||
# CONFIG_VIDEO_XILINX_TPG is not set
|
||||
CONFIG_DRM_FBDEV_EMULATION=y
|
||||
CONFIG_DRM_FBDEV_OVERALLOC=100
|
||||
# CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM is not set
|
||||
# CONFIG_DRM_XLNX is not set
|
||||
CONFIG_FB_NOTIFY=y
|
||||
CONFIG_FB=y
|
||||
# CONFIG_FIRMWARE_EDID is not set
|
||||
CONFIG_FB_CFB_FILLRECT=y
|
||||
CONFIG_FB_CFB_COPYAREA=y
|
||||
CONFIG_FB_CFB_IMAGEBLIT=y
|
||||
CONFIG_FB_SYS_FILLRECT=y
|
||||
CONFIG_FB_SYS_COPYAREA=y
|
||||
CONFIG_FB_SYS_IMAGEBLIT=y
|
||||
# CONFIG_FB_FOREIGN_ENDIAN is not set
|
||||
CONFIG_FB_SYS_FOPS=y
|
||||
CONFIG_FB_DEFERRED_IO=y
|
||||
# CONFIG_FB_MODE_HELPERS is not set
|
||||
# CONFIG_FB_TILEBLITTING is not set
|
||||
|
||||
#
|
||||
# Frame buffer hardware drivers
|
||||
#
|
||||
# CONFIG_FB_CIRRUS is not set
|
||||
# CONFIG_FB_PM2 is not set
|
||||
# CONFIG_FB_ARMCLCD is not set
|
||||
# CONFIG_FB_CYBER2000 is not set
|
||||
# CONFIG_FB_ASILIANT is not set
|
||||
# CONFIG_FB_IMSTT is not set
|
||||
# CONFIG_FB_UVESA is not set
|
||||
# CONFIG_FB_OPENCORES is not set
|
||||
# CONFIG_FB_S1D13XXX is not set
|
||||
# CONFIG_FB_NVIDIA is not set
|
||||
# CONFIG_FB_RIVA is not set
|
||||
# CONFIG_FB_I740 is not set
|
||||
# CONFIG_FB_MATROX is not set
|
||||
# CONFIG_FB_RADEON is not set
|
||||
# CONFIG_FB_ATY128 is not set
|
||||
# CONFIG_FB_ATY is not set
|
||||
# CONFIG_FB_S3 is not set
|
||||
# CONFIG_FB_SAVAGE is not set
|
||||
# CONFIG_FB_SIS is not set
|
||||
# CONFIG_FB_NEOMAGIC is not set
|
||||
# CONFIG_FB_KYRO is not set
|
||||
# CONFIG_FB_3DFX is not set
|
||||
# CONFIG_FB_VOODOO1 is not set
|
||||
# CONFIG_FB_VT8623 is not set
|
||||
# CONFIG_FB_TRIDENT is not set
|
||||
# CONFIG_FB_ARK is not set
|
||||
# CONFIG_FB_PM3 is not set
|
||||
# CONFIG_FB_CARMINE is not set
|
||||
# CONFIG_FB_SMSCUFX is not set
|
||||
# CONFIG_FB_UDL is not set
|
||||
# CONFIG_FB_IBM_GXT4500 is not set
|
||||
# CONFIG_FB_XILINX is not set
|
||||
# CONFIG_FB_VIRTUAL is not set
|
||||
# CONFIG_FB_METRONOME is not set
|
||||
# CONFIG_FB_MB862XX is not set
|
||||
# CONFIG_FB_SIMPLE is not set
|
||||
# CONFIG_FB_SSD1307 is not set
|
||||
# CONFIG_FB_SM712 is not set
|
||||
CONFIG_FRAMEBUFFER_CONSOLE=y
|
||||
# CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION is not set
|
||||
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
|
||||
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
|
||||
# CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is not set
|
||||
|
||||
# CONFIG_LOGO is not set
|
||||
CONFIG_FONT_SUPPORT=y
|
||||
# CONFIG_FONTS is not set
|
||||
CONFIG_FONT_8x8=y
|
||||
CONFIG_FONT_8x16=y
|
@ -0,0 +1,2 @@
|
||||
CONFIG_VIDEO_XILINX_VTC=y
|
||||
CONFIG_XILINX_DMA=y
|
@ -6,5 +6,7 @@ SRC_URI += "file://user_2023-02-14-13-57-00.cfg \
|
||||
file://user_2023-02-15-11-42-00.cfg \
|
||||
file://user_2023-02-15-13-53-00.cfg \
|
||||
file://user_2023-04-30-04-37-00.cfg \
|
||||
file://user_2023-05-02-05-08-00.cfg \
|
||||
file://user_2023-05-02-06-25-00.cfg \
|
||||
"
|
||||
|
||||
|
53
project-spec/meta-user/recipes-modules/tinylcd/README
Normal file
53
project-spec/meta-user/recipes-modules/tinylcd/README
Normal file
@ -0,0 +1,53 @@
|
||||
PetaLinux User Module Template
|
||||
===================================
|
||||
|
||||
This directory contains a PetaLinux kernel module created from a template.
|
||||
|
||||
If you are developing your module from scratch, simply start editing the
|
||||
file tinylcd.c.
|
||||
|
||||
You can easily import any existing module code by copying it into this
|
||||
directory, and editing the automatically generated Makefile as described below.
|
||||
|
||||
The "all:" target in the Makefile template will compile compile the module.
|
||||
|
||||
Before building the module, you will need to enable the module from
|
||||
PetaLinux menuconfig by running:
|
||||
"petalinux-config -c rootfs"
|
||||
You will see your module in the "modules --->" submenu.
|
||||
|
||||
To compile and install your module to the target file system copy on the host,
|
||||
simply run the command.
|
||||
"petalinux-build -c kernel" to build kernel first, and then run
|
||||
"petalinux-build -c tinylcd" to build the module
|
||||
|
||||
You will also need to rebuild PetaLinux bootable images so that the images
|
||||
is updated with the updated target filesystem copy, run this command:
|
||||
"petalinux-build -c rootfs"
|
||||
|
||||
You can also run one PetaLinux command to compile the module, install it
|
||||
to the target filesystem host copy and update the bootable images as follows:
|
||||
"petalinux-build"
|
||||
|
||||
If OF(OpenFirmware) is configured, you need to add the device node to the
|
||||
DTS(Device Tree Source) file so that the device can be probed when the module is
|
||||
loaded. Here is an example of the device node in the device tree:
|
||||
|
||||
tinylcd_instance: tinylcd@XXXXXXXX {
|
||||
compatible = "vendor,tinylcd";
|
||||
reg = <PHYSICAL_START_ADDRESS ADDRESS_RANGE>;
|
||||
interrupt-parent = <&INTR_CONTROLLER_INSTANCE>;
|
||||
interrupts = < INTR_NUM INTR_SENSITIVITY >;
|
||||
};
|
||||
Notes:
|
||||
* "tinylcd@XXXXXXXX" is the label of the device node, it is usually the "DEVICE_TYPE@PHYSICAL_START_ADDRESS". E.g. "tinylcd@89000000".
|
||||
* "compatible" needs to match one of the the compatibles in the module's compatible list.
|
||||
* "reg" needs to be pair(s) of the physical start address of the device and the address range.
|
||||
* If the device has interrupt, the "interrupt-parent" needs to be the interrupt controller which the interrupt connects to. and the "interrupts" need to be pair(s) of the interrupt ID and the interrupt sensitivity.
|
||||
|
||||
For more information about the the DTS file, please refer to this document in the Linux kernel: linux-2.6.x/Documentation/powerpc/booting-without-of.txt
|
||||
|
||||
|
||||
To add extra source code files (for example, to split a large module into
|
||||
multiple source files), add the relevant .o files to the list in the local
|
||||
Makefile where indicated.
|
340
project-spec/meta-user/recipes-modules/tinylcd/files/COPYING
Normal file
340
project-spec/meta-user/recipes-modules/tinylcd/files/COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
@ -0,0 +1,17 @@
|
||||
obj-m := tinylcd.o
|
||||
|
||||
MY_CFLAGS += -g -DDEBUG -fno-stack-protector
|
||||
ccflags-y += ${MY_CFLAGS}
|
||||
|
||||
SRC := $(shell pwd)
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
|
||||
rm -f Module.markers Module.symvers modules.order
|
||||
rm -rf .tmp_versions Modules.symvers
|
589
project-spec/meta-user/recipes-modules/tinylcd/files/tinylcd.c
Normal file
589
project-spec/meta-user/recipes-modules/tinylcd/files/tinylcd.c
Normal file
@ -0,0 +1,589 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_dma.h>
|
||||
|
||||
#include <video/videomode.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/dma/xilinx_dma.h>
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
#include "xilinx-vtc.h"
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Paul Pan");
|
||||
MODULE_DESCRIPTION("tinylcd - TFT LCD Framebuffer Driver for TinySoC");
|
||||
|
||||
#define DRIVER_NAME "tinylcd"
|
||||
|
||||
/* Parameters */
|
||||
|
||||
/* screen_type
|
||||
* 0: 4.3 480*272
|
||||
* 1: 4.3 800*480
|
||||
* 2: 7 800*480
|
||||
* 3: 7 1024*600
|
||||
* 4: 10 1280*800
|
||||
*/
|
||||
unsigned screen_type = 1;
|
||||
module_param(screen_type, uint, S_IRUGO);
|
||||
|
||||
unsigned screen_fps = 60;
|
||||
module_param(screen_fps, uint, S_IRUGO);
|
||||
|
||||
/* Tiny LCD Device Descriptor */
|
||||
|
||||
struct tinylcd_dev {
|
||||
struct fb_info *info;
|
||||
struct platform_device *pdev;
|
||||
struct dma_chan *vdma;
|
||||
struct xvtc_device *vtc;
|
||||
struct xvtc_config *vtc_cfg;
|
||||
int backlight_gpio;
|
||||
int reset_gpio;
|
||||
};
|
||||
|
||||
/* Framebuffer OPs */
|
||||
|
||||
#define RED_SHIFT 16
|
||||
#define GREEN_SHIFT 8
|
||||
#define BLUE_SHIFT 0
|
||||
#define BYTES_PER_PIXEL 3
|
||||
#define BITS_PER_PIXEL (BYTES_PER_PIXEL * 8)
|
||||
#define PALETTE_ENTRIES_NO 16
|
||||
|
||||
static int tinylcd_fb_setcolreg(unsigned int regno, unsigned int red,
|
||||
unsigned int green, unsigned int blue,
|
||||
unsigned int transp, struct fb_info *fbi)
|
||||
{
|
||||
u32 *palette = fbi->pseudo_palette;
|
||||
|
||||
if (regno >= PALETTE_ENTRIES_NO)
|
||||
return -EINVAL;
|
||||
|
||||
if (fbi->var.grayscale) {
|
||||
blue = (red * 77 + green * 151 + blue * 28 + 127) >> 8;
|
||||
green = blue;
|
||||
red = green;
|
||||
}
|
||||
|
||||
red >>= 8;
|
||||
green >>= 8;
|
||||
blue >>= 8;
|
||||
palette[regno] = (red << RED_SHIFT) | (green << GREEN_SHIFT) |
|
||||
(blue << BLUE_SHIFT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tinylcd_fb_check_var(struct fb_var_screeninfo *var,
|
||||
struct fb_info *fb_info)
|
||||
{
|
||||
struct fb_var_screeninfo *fb_var = &fb_info->var;
|
||||
memcpy(var, fb_var, sizeof(struct fb_var_screeninfo));
|
||||
pr_warn("tinylcd DO NOT support change mode\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct fb_ops tinylcd_fb_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.fb_setcolreg = tinylcd_fb_setcolreg,
|
||||
.fb_check_var = tinylcd_fb_check_var,
|
||||
.fb_fillrect = cfb_fillrect,
|
||||
.fb_copyarea = cfb_copyarea,
|
||||
.fb_imageblit = cfb_imageblit,
|
||||
};
|
||||
|
||||
static const struct fb_fix_screeninfo tinylcd_fb_fix = {
|
||||
.id = "Xilinx",
|
||||
.type = FB_TYPE_PACKED_PIXELS,
|
||||
.visual = FB_VISUAL_TRUECOLOR,
|
||||
.accel = FB_ACCEL_NONE
|
||||
};
|
||||
|
||||
static const struct fb_var_screeninfo tinylcd_fb_var = {
|
||||
.bits_per_pixel = BITS_PER_PIXEL,
|
||||
.red = { RED_SHIFT, 8, 0 },
|
||||
.green = { GREEN_SHIFT, 8, 0 },
|
||||
.blue = { BLUE_SHIFT, 8, 0 },
|
||||
.transp = { 0, 0, 0 },
|
||||
.activate = FB_ACTIVATE_NOW,
|
||||
.accel_flags = FB_ACCEL_NONE,
|
||||
};
|
||||
|
||||
/* Device */
|
||||
|
||||
#define SCREEN_4342 0
|
||||
#define SCREEN_4384 1
|
||||
#define SCREEN_7084 2
|
||||
#define SCREEN_7016 3
|
||||
#define SCREEN_1018 4
|
||||
|
||||
static struct videomode screen_timings[] = {
|
||||
[SCREEN_4342] = {
|
||||
.hactive = 480,
|
||||
.hfront_porch = 5,
|
||||
.hback_porch = 40,
|
||||
.hsync_len = 1,
|
||||
.vactive = 272,
|
||||
.vfront_porch = 8,
|
||||
.vback_porch = 8,
|
||||
.vsync_len = 1,
|
||||
},
|
||||
[SCREEN_4384] = {
|
||||
.hactive = 800,
|
||||
.hfront_porch = 40,
|
||||
.hback_porch = 88,
|
||||
.hsync_len = 48,
|
||||
.vactive = 480,
|
||||
.vfront_porch = 13,
|
||||
.vback_porch = 32,
|
||||
.vsync_len = 3,
|
||||
},
|
||||
[SCREEN_7084] = {
|
||||
.hactive = 800,
|
||||
.hfront_porch = 210,
|
||||
.hback_porch = 46,
|
||||
.hsync_len = 1,
|
||||
.vactive = 480,
|
||||
.vfront_porch = 22,
|
||||
.vback_porch = 23,
|
||||
.vsync_len = 1,
|
||||
},
|
||||
[SCREEN_7016] = {
|
||||
.hactive = 1024,
|
||||
.hfront_porch = 160,
|
||||
.hback_porch = 140,
|
||||
.hsync_len = 20,
|
||||
.vactive = 600,
|
||||
.vfront_porch = 12,
|
||||
.vback_porch = 20,
|
||||
.vsync_len = 3,
|
||||
},
|
||||
[SCREEN_1018] = {
|
||||
.hactive = 1280,
|
||||
.hfront_porch = 70,
|
||||
.hback_porch = 80,
|
||||
.hsync_len = 10,
|
||||
.vactive = 800,
|
||||
.vfront_porch = 10,
|
||||
.vback_porch = 10,
|
||||
.vsync_len = 3,
|
||||
}
|
||||
};
|
||||
|
||||
static int tinylcd_init_vmode_timings(struct videomode *vmode)
|
||||
{
|
||||
struct videomode *ref;
|
||||
|
||||
if (screen_type > SCREEN_1018)
|
||||
return -EINVAL;
|
||||
|
||||
ref = &screen_timings[screen_type];
|
||||
|
||||
vmode->hactive = ref->hactive;
|
||||
vmode->hfront_porch = ref->hfront_porch;
|
||||
vmode->hback_porch = ref->hback_porch;
|
||||
vmode->hsync_len = ref->hsync_len;
|
||||
|
||||
vmode->vactive = ref->vactive;
|
||||
vmode->vfront_porch = ref->vfront_porch;
|
||||
vmode->vback_porch = ref->vback_porch;
|
||||
vmode->vsync_len = ref->vsync_len;
|
||||
|
||||
vmode->flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW |
|
||||
DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
|
||||
DISPLAY_FLAGS_SYNC_NEGEDGE;
|
||||
vmode->pixelclock = (vmode->hactive + vmode->hfront_porch +
|
||||
vmode->hback_porch + vmode->hsync_len) *
|
||||
(vmode->vactive + vmode->vfront_porch +
|
||||
vmode->vback_porch + vmode->vsync_len) *
|
||||
screen_fps;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fb_videomode_from_videomode_copy(const struct videomode *vm,
|
||||
struct fb_videomode *fbmode)
|
||||
{
|
||||
unsigned int htotal, vtotal;
|
||||
|
||||
fbmode->xres = vm->hactive;
|
||||
fbmode->left_margin = vm->hback_porch;
|
||||
fbmode->right_margin = vm->hfront_porch;
|
||||
fbmode->hsync_len = vm->hsync_len;
|
||||
|
||||
fbmode->yres = vm->vactive;
|
||||
fbmode->upper_margin = vm->vback_porch;
|
||||
fbmode->lower_margin = vm->vfront_porch;
|
||||
fbmode->vsync_len = vm->vsync_len;
|
||||
|
||||
/* prevent division by zero in KHZ2PICOS macro */
|
||||
fbmode->pixclock =
|
||||
vm->pixelclock ? KHZ2PICOS(vm->pixelclock / 1000) : 0;
|
||||
|
||||
fbmode->sync = 0;
|
||||
fbmode->vmode = 0;
|
||||
if (vm->flags & DISPLAY_FLAGS_HSYNC_HIGH)
|
||||
fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
|
||||
if (vm->flags & DISPLAY_FLAGS_VSYNC_HIGH)
|
||||
fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
|
||||
if (vm->flags & DISPLAY_FLAGS_INTERLACED)
|
||||
fbmode->vmode |= FB_VMODE_INTERLACED;
|
||||
if (vm->flags & DISPLAY_FLAGS_DOUBLESCAN)
|
||||
fbmode->vmode |= FB_VMODE_DOUBLE;
|
||||
fbmode->flag = 0;
|
||||
|
||||
htotal = vm->hactive + vm->hfront_porch + vm->hback_porch +
|
||||
vm->hsync_len;
|
||||
vtotal = vm->vactive + vm->vfront_porch + vm->vback_porch +
|
||||
vm->vsync_len;
|
||||
/* prevent division by zero */
|
||||
if (htotal && vtotal) {
|
||||
fbmode->refresh = vm->pixelclock / (htotal * vtotal);
|
||||
/* a mode must have htotal and vtotal != 0 or it is invalid */
|
||||
} else {
|
||||
fbmode->refresh = 0;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tinylcd_init_fbinfo(struct tinylcd_dev *fbdev,
|
||||
struct videomode *vmode)
|
||||
{
|
||||
struct device *dev = &fbdev->pdev->dev;
|
||||
struct fb_info *fb_info = fbdev->info;
|
||||
struct fb_videomode mode = { 0 };
|
||||
|
||||
dma_addr_t fb_mem_phy;
|
||||
void *fb_mem_virt;
|
||||
size_t fb_mem_size;
|
||||
int rc;
|
||||
|
||||
/* 配置时序参数 */
|
||||
rc = tinylcd_init_vmode_timings(vmode);
|
||||
if (rc) {
|
||||
dev_err(dev, "invalid screen type %d\n", screen_type);
|
||||
return rc;
|
||||
}
|
||||
dev_dbg(dev, "screen(type %d, fps %d) timings initiated\n", screen_type,
|
||||
screen_fps);
|
||||
|
||||
/* 申请LCD显存 */
|
||||
fb_mem_size = PAGE_ALIGN(vmode->hactive * vmode->vactive * 3);
|
||||
fb_mem_virt = dma_alloc_wc(dev, fb_mem_size, &fb_mem_phy, GFP_KERNEL);
|
||||
if (!fb_mem_virt)
|
||||
return -ENOMEM;
|
||||
memset(fb_mem_virt, 0, fb_mem_size);
|
||||
dev_dbg(dev, "fb_mem(phy %pad, virt %p, size %zu) allocated\n",
|
||||
&fb_mem_phy, fb_mem_virt, fb_mem_size);
|
||||
|
||||
/* 初始化fb_info */
|
||||
fb_info->fbops = &tinylcd_fb_ops;
|
||||
fb_info->flags = FBINFO_FLAG_DEFAULT;
|
||||
fb_info->screen_base = fb_mem_virt;
|
||||
fb_info->screen_size = fb_mem_size;
|
||||
|
||||
fb_info->fix = tinylcd_fb_fix;
|
||||
fb_info->fix.line_length = vmode->hactive * BYTES_PER_PIXEL;
|
||||
fb_info->fix.smem_start = fb_mem_phy;
|
||||
fb_info->fix.smem_len = fb_mem_size;
|
||||
|
||||
fb_info->var = tinylcd_fb_var;
|
||||
fb_info->var.xres = fb_info->var.xres_virtual = vmode->hactive;
|
||||
fb_info->var.yres = fb_info->var.yres_virtual = vmode->vactive;
|
||||
fb_info->var.xoffset = fb_info->var.yoffset = 0;
|
||||
|
||||
fb_videomode_from_videomode_copy(vmode, &mode);
|
||||
fb_videomode_to_var(&fb_info->var, &mode);
|
||||
|
||||
dev_dbg(dev, "fb_info initialized\n");
|
||||
|
||||
/* 初始化调色板 */
|
||||
rc = fb_alloc_cmap(&fb_info->cmap, PALETTE_ENTRIES_NO, 0);
|
||||
if (rc) {
|
||||
dev_err(dev, "fail to allocate colormap (%d entries)\n",
|
||||
PALETTE_ENTRIES_NO);
|
||||
goto err_free_dma;
|
||||
}
|
||||
|
||||
fb_info->pseudo_palette =
|
||||
devm_kzalloc(dev, sizeof(u32) * PALETTE_ENTRIES_NO, GFP_KERNEL);
|
||||
if (!fb_info->pseudo_palette) {
|
||||
rc = -ENOMEM;
|
||||
goto err_free_cmap;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "colormap initialized\n");
|
||||
|
||||
return rc;
|
||||
|
||||
err_free_cmap:
|
||||
fb_dealloc_cmap(&fb_info->cmap);
|
||||
err_free_dma:
|
||||
dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base,
|
||||
fb_info->fix.smem_start);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int tinylcd_init_vtc_cfg(struct tinylcd_dev *fbdev,
|
||||
struct videomode *vmode)
|
||||
{
|
||||
struct device *dev = &fbdev->pdev->dev;
|
||||
struct xvtc_config *vtc_cfg;
|
||||
u32 htotal, hsync_start, hbackporch_start;
|
||||
u32 vtotal, vsync_start, vbackporch_start;
|
||||
|
||||
fbdev->vtc_cfg = devm_kzalloc(dev, sizeof(*fbdev->vtc_cfg), GFP_KERNEL);
|
||||
if (!fbdev->vtc_cfg)
|
||||
return -ENOMEM;
|
||||
vtc_cfg = fbdev->vtc_cfg;
|
||||
|
||||
htotal = vmode->hactive + vmode->hfront_porch + vmode->hback_porch +
|
||||
vmode->hsync_len;
|
||||
hsync_start = vmode->hactive + vmode->hfront_porch;
|
||||
hbackporch_start = hsync_start + vmode->hsync_len;
|
||||
|
||||
vtc_cfg->hblank_start = vmode->hactive & 0x1fff;
|
||||
vtc_cfg->hsync_start = hsync_start & 0x1fff;
|
||||
vtc_cfg->hsync_end = hbackporch_start & 0x1fff;
|
||||
vtc_cfg->hsize = htotal & 0x1fff;
|
||||
|
||||
vtotal = vmode->vactive + vmode->vfront_porch + vmode->vback_porch +
|
||||
vmode->vsync_len;
|
||||
vsync_start = vmode->vactive + vmode->vfront_porch;
|
||||
vbackporch_start = vsync_start + vmode->vsync_len;
|
||||
|
||||
vtc_cfg->vblank_start = vmode->vactive & 0x1fff;
|
||||
vtc_cfg->vsync_start = vsync_start & 0x1fff;
|
||||
vtc_cfg->vsync_end = vbackporch_start & 0x1fff;
|
||||
vtc_cfg->vsize = vtotal & 0x1fff;
|
||||
|
||||
vtc_cfg->fps = screen_fps;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tinylcd_init_vdma(struct tinylcd_dev *fbdev)
|
||||
{
|
||||
struct device *dev = &fbdev->pdev->dev;
|
||||
struct fb_info *info = fbdev->info;
|
||||
struct dma_interleaved_template dma_template = { 0 };
|
||||
struct dma_async_tx_descriptor *tx_desc;
|
||||
struct xilinx_vdma_config vdma_config = { 0 };
|
||||
|
||||
/* 申请VDMA通道 */
|
||||
fbdev->vdma = of_dma_request_slave_channel(dev->of_node, "lcd-vdma");
|
||||
if (IS_ERR(fbdev->vdma)) {
|
||||
dev_err(dev, "failed to request vdma channel: 0x%lx\n",
|
||||
PTR_ERR(fbdev->vdma));
|
||||
return PTR_ERR(fbdev->vdma);
|
||||
}
|
||||
|
||||
/* 终止VDMA通道数据传输 */
|
||||
dmaengine_terminate_all(fbdev->vdma);
|
||||
|
||||
/* 初始化VDMA通道 */
|
||||
dma_template.dir = DMA_MEM_TO_DEV;
|
||||
dma_template.numf = info->var.yres;
|
||||
dma_template.sgl[0].size = info->fix.line_length;
|
||||
dma_template.frame_size = 1;
|
||||
dma_template.sgl[0].icg = 0;
|
||||
dma_template.src_start = info->fix.smem_start;
|
||||
dma_template.src_sgl = 1;
|
||||
dma_template.src_inc = 1;
|
||||
dma_template.dst_inc = 0;
|
||||
dma_template.dst_sgl = 0;
|
||||
|
||||
tx_desc = dmaengine_prep_interleaved_dma(
|
||||
fbdev->vdma, &dma_template, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
|
||||
if (!tx_desc) {
|
||||
dev_err(dev, "failed to prepare DMA descriptor\n");
|
||||
dma_release_channel(fbdev->vdma);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
vdma_config.park = 1;
|
||||
xilinx_vdma_channel_set_config(fbdev->vdma, &vdma_config);
|
||||
|
||||
/* 启动VDMA通道数据传输 */
|
||||
dmaengine_submit(tx_desc);
|
||||
dma_async_issue_pending(fbdev->vdma);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tinylcd_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct tinylcd_dev *fbdev = NULL;
|
||||
struct fb_info *info = NULL;
|
||||
struct videomode vmode;
|
||||
|
||||
int rc;
|
||||
|
||||
dev_info(dev, "initializing Tiny LCD\n");
|
||||
|
||||
/* 先分配内存 */
|
||||
info = framebuffer_alloc(sizeof(struct tinylcd_dev), &pdev->dev);
|
||||
if (!info) {
|
||||
dev_err(dev, "failed to allocate memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
fbdev = info->par;
|
||||
fbdev->info = info;
|
||||
fbdev->pdev = pdev;
|
||||
|
||||
/* 找到 LCD 控制 GPIO */
|
||||
fbdev->backlight_gpio =
|
||||
of_get_named_gpio(pdev->dev.of_node, "lcd-backlight", 0);
|
||||
fbdev->reset_gpio =
|
||||
of_get_named_gpio(pdev->dev.of_node, "lcd-reset", 0);
|
||||
if (!gpio_is_valid(fbdev->backlight_gpio) ||
|
||||
!gpio_is_valid(fbdev->reset_gpio)) {
|
||||
dev_err(dev, "failed to get LCD GPIOs, check your DTS\n");
|
||||
rc = -ENODEV;
|
||||
goto err_release_fb;
|
||||
}
|
||||
|
||||
/* 重置 LCD */
|
||||
gpio_set_value(fbdev->reset_gpio, 0);
|
||||
mdelay(1);
|
||||
gpio_set_value(fbdev->reset_gpio, 1);
|
||||
|
||||
dev_dbg(dev, "reset LCD\n");
|
||||
|
||||
/* 打开LCD背光 */
|
||||
rc = devm_gpio_request_one(dev, fbdev->backlight_gpio,
|
||||
GPIOF_OUT_INIT_HIGH, "lcd backlight");
|
||||
if (rc) {
|
||||
dev_err(dev, "failed to request backlight GPIO\n");
|
||||
goto err_unregister;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "initialized backlight\n");
|
||||
|
||||
/* 找到 Video Timing Controller 设备 */
|
||||
fbdev->vtc = xvtc_of_get(pdev->dev.of_node);
|
||||
if (!fbdev->vtc) {
|
||||
dev_err(dev, "failed to get VTC, check your DTS\n");
|
||||
rc = -ENODEV;
|
||||
goto err_release_fb;
|
||||
}
|
||||
|
||||
/* 先禁止输出 */
|
||||
rc = xvtc_generator_stop(fbdev->vtc);
|
||||
if (rc) {
|
||||
dev_err(dev, "failed to stop VTC\n");
|
||||
goto err_release_fb;
|
||||
}
|
||||
|
||||
/* 初始化info变量 */
|
||||
rc = tinylcd_init_fbinfo(fbdev, &vmode);
|
||||
if (rc)
|
||||
goto err_release_fb;
|
||||
|
||||
/* 初始化 VTC 配置 */
|
||||
rc = tinylcd_init_vtc_cfg(fbdev, &vmode);
|
||||
if (rc)
|
||||
goto err_release_fb_full;
|
||||
|
||||
/* VTC 启动 */
|
||||
rc = xvtc_generator_start(fbdev->vtc, fbdev->vtc_cfg);
|
||||
if (rc) {
|
||||
dev_err(dev, "failed to start VTC\n");
|
||||
goto err_release_vtc_cfg;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "started VTC\n");
|
||||
|
||||
/* 初始化 VDMA */
|
||||
rc = tinylcd_init_vdma(fbdev);
|
||||
if (rc)
|
||||
goto err_stop_vtc;
|
||||
|
||||
dev_dbg(dev, "started VDMA\n");
|
||||
|
||||
/* 注册FrameBuffer设备 */
|
||||
rc = register_framebuffer(info);
|
||||
if (rc) {
|
||||
dev_err(dev, "failed to register framebuffer device\n");
|
||||
goto err_stop_vdma;
|
||||
}
|
||||
|
||||
/* 一切成功 */
|
||||
platform_set_drvdata(pdev, fbdev);
|
||||
dev_info(dev, "Tiny LCD Initialized\n");
|
||||
return 0;
|
||||
|
||||
err_unregister:
|
||||
unregister_framebuffer(info);
|
||||
err_stop_vdma:
|
||||
dmaengine_terminate_all(fbdev->vdma);
|
||||
dma_release_channel(fbdev->vdma);
|
||||
err_stop_vtc:
|
||||
xvtc_generator_stop(fbdev->vtc);
|
||||
err_release_vtc_cfg:
|
||||
devm_kfree(dev, fbdev->vtc_cfg);
|
||||
err_release_fb_full:
|
||||
devm_kfree(dev, info->pseudo_palette);
|
||||
fb_dealloc_cmap(&info->cmap);
|
||||
dma_free_wc(dev, info->screen_size, info->screen_base,
|
||||
info->fix.smem_start);
|
||||
err_release_fb:
|
||||
framebuffer_release(info);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int tinylcd_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct tinylcd_dev *fbdev = platform_get_drvdata(pdev);
|
||||
struct fb_info *info = fbdev->info;
|
||||
|
||||
unregister_framebuffer(info);
|
||||
dmaengine_terminate_all(fbdev->vdma);
|
||||
dma_release_channel(fbdev->vdma);
|
||||
xvtc_generator_stop(fbdev->vtc);
|
||||
devm_kfree(dev, fbdev->vtc_cfg);
|
||||
devm_kfree(dev, info->pseudo_palette);
|
||||
fb_dealloc_cmap(&info->cmap);
|
||||
dma_free_wc(&pdev->dev, info->screen_size, info->screen_base,
|
||||
info->fix.smem_start);
|
||||
framebuffer_release(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct of_device_id tinylcd_of_match[] = {
|
||||
{
|
||||
.compatible = "tinysoc,tinylcd",
|
||||
},
|
||||
{ /* end of list */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, tinylcd_of_match);
|
||||
#else
|
||||
#define tinylcd_of_match
|
||||
#endif
|
||||
|
||||
static struct platform_driver tinylcd_driver = {
|
||||
.driver =
|
||||
{
|
||||
.name = DRIVER_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = tinylcd_of_match,
|
||||
},
|
||||
.probe = tinylcd_probe,
|
||||
.remove = tinylcd_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(tinylcd_driver);
|
@ -0,0 +1,40 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Xilinx Video Timing Controller
|
||||
*
|
||||
* Copyright (C) 2013-2015 Ideas on Board
|
||||
* Copyright (C) 2013-2015 Xilinx, Inc.
|
||||
*
|
||||
* Contacts: Hyun Kwon <hyun.kwon@xilinx.com>
|
||||
* Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
||||
*/
|
||||
|
||||
#ifndef __XILINX_VTC_H__
|
||||
#define __XILINX_VTC_H__
|
||||
|
||||
struct device_node;
|
||||
struct xvtc_device;
|
||||
|
||||
#define XVTC_MAX_HSIZE 8191
|
||||
#define XVTC_MAX_VSIZE 8191
|
||||
|
||||
struct xvtc_config {
|
||||
unsigned int hblank_start;
|
||||
unsigned int hsync_start;
|
||||
unsigned int hsync_end;
|
||||
unsigned int hsize;
|
||||
unsigned int vblank_start;
|
||||
unsigned int vsync_start;
|
||||
unsigned int vsync_end;
|
||||
unsigned int vsize;
|
||||
unsigned int fps;
|
||||
};
|
||||
|
||||
extern struct xvtc_device *xvtc_of_get(struct device_node *np);
|
||||
extern void xvtc_put(struct xvtc_device *xvtc);
|
||||
|
||||
extern int xvtc_generator_start(struct xvtc_device *xvtc,
|
||||
const struct xvtc_config *config);
|
||||
extern int xvtc_generator_stop(struct xvtc_device *xvtc);
|
||||
|
||||
#endif /* __XILINX_VTC_H__ */
|
19
project-spec/meta-user/recipes-modules/tinylcd/tinylcd.bb
Normal file
19
project-spec/meta-user/recipes-modules/tinylcd/tinylcd.bb
Normal file
@ -0,0 +1,19 @@
|
||||
SUMMARY = "Recipe for build an external tinylcd Linux kernel module"
|
||||
SECTION = "PETALINUX/modules"
|
||||
LICENSE = "GPLv2"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
|
||||
|
||||
inherit module
|
||||
|
||||
INHIBIT_PACKAGE_STRIP = "1"
|
||||
|
||||
SRC_URI = "file://Makefile \
|
||||
file://tinylcd.c \
|
||||
file://xilinx-vtc.h \
|
||||
file://COPYING \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
# The inherit of module.bbclass will automatically name module packages with
|
||||
# "kernel-module-" prefix as required by the oe-core build environment.
|
Loading…
Reference in New Issue
Block a user