This patch replaces the code for getting an number from a
userspace buffer by a simple call to kstrou8_from_user.
This makes it easier to read and less error prone.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Acked-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
As check_var already ensures that the mode is valid there is no need
to do those expensive lookups here again. The only thing that might
change is that the deprecated interface could report slightly
different refresh rates due to rounding errors.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch converts the modetables used in viafb to
- remove the strange thing that sync_end and blanking_end contained
the length and not the absolute value
- remove hundreds of useless defines
- use fb_videomode and not our own definition so modes defined in
the subsystem and received via EDID are compatible with ours
As the modes are now stored in a flat structure and no longer in a
tree like thing the lookup time was increased but as it is a rare
event anyway it shouldn't matter. Otherwise the behaviour should be
the same as before.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch removes redundant bits per pixel information by using the
one storged in var directly. Simplifies code without any functional
changes.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Even if the documentation calls this bit "Reserved" it has to be set
to 0 for correct modesetting on IGA1.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: stable@vger.kernel.org
VX900 can do hardware scaling for both IGAs in contrast to previous
hardware which could do it only for IGA2. This patch ensures that
we set the parameter for IGA2 and not for IGA1. This fixes hardware
scaling on VX900 until we have the infrastructure to support it for
both IGAs.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: stable@vger.kernel.org
Obviously this is a typo and although there were no effects observed
it's probably better to fix it.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
We should handle the allocation here, if only to keep the static
checkers happy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch adds support for using EDID data on CRT and DVP1 for
initial configuration if viafb_mode or viafb_mode1 are not present.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch fixes the I2C emulation on GPIO ports by enabling it
(software controlled) and disabling the output on a GPIO line before
reading it.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch implementes this mode (viafb_SAMM_ON set and
viafb_dual_fb not set) in a useful way for CRT and DVI devices.
The same content is shown on both devices in different video modes.
The first (primary) resolution must not be bigger than the secondary
one and determines the visible region. The same content is shown
centered on the secondary output.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch fills xres and yres in var which is required when a
temporary var is genereated when viafb_SAMM_ON is set and
viafb_dual_fb is not set. It also removes an obsolete comment.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch sets the correct polarity for the second adapter when
viafb_SAMM_ON is set and viafb_dual_fb is not set. Just one step to
make this mode useful.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch adds the basic infrastructure and a few stub drivers for
devices that are connected via I2C busses. The infrastructure will
be used to replace and extend the support that is scattered
throughout viafb. The stub drivers are not very useful yet but they
show how the infrastructure works, provide information about the
chips integrated into a system and maybe gather some testers as it
would be very difficult for a single person to get a sane test
environment.
The only thing this actually does is probing the I2C busses which
will hopefully not cause any regressions.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
While the OLPC display appears to be able to handle either positive
or negative sync, the Display Controller only recognises positive sync.
This brings viafb (for XO-1.5) in line with lxfb (for XO-1) and
fixes a recent regression where the XO-1.5 DCON could no longer be
frozen. Thanks to Florian Tobias Schandinat for helping identify
the fix.
Test case: from a vt,
echo 1 > /sys/devices/platform/dcon/freeze
should cause the current screen contents to freeze, rather than garbage being
displayed.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: stable@kernel.org
With module.h being implicitly everywhere via device.h, the absence
of explicitly including something for EXPORT_SYMBOL went unnoticed.
Since we are heading to fix things up and clean module.h from the
device.h file, we need to explicitly include these files now.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
This commit replace the function strict_strtoul(becasue commit 33ee3b2e), and check the return value to avoid such warning:
drivers/video/via/viafbdev.c:1992: warning: ignoring return value of 'kstrtoul', declared with attribute warn_unused_result
Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch removes the remaining places where assumptions about the
structure of the modetable were made. Aside from some places where
assumptions are made that certain modes are in the modetable the
only code dealing with the modetable and not just a single mode is
in viamode. This will allow chaniging the modetable and use other
sources for videomodes like the subsystem or EDID.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch removes the need for knowing the modetable structure
within the LCD modesetting function. The magic 60Hz refresh rate was
already there as always the first entry for a resolution was choosen
based on the ascending refresh rate ordering in the modetable.
For all but one this is at least 60Hz, if only higher frequencies
available we choose those like the code before did. The exception is
OLPC but that resolution has only one frequency so we get the same
behaviour there as well.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch splits the hardware initialization out of the modesetting
function which will make it easier to make it conditional and not
require starting from scratch for every mode change, which is
especially annoying in dual framebuffer mode.
This required some minor reordering but it should not influence its
functionality.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch starts to use the information in var for modesetting for
CRT and DVI devices. This is the right thing as it allows us to use
more generic modes than the ones predefined by VIA. We do not yet
allow more generic modes as check_var still limits them to the
predefined ones but with this patch applied it would be really easy
to do so. A problem was VIAs SAMM mode as it has 2 different modes
but just one frame buffer device. This is solved by creating a
pseudo var which contains enough information to use it for
modesetting. Hopefully one day we can use information in var for all
modes that do not involve hardware scaling.
Well I'd like to say that the chance of regressions is low but it is
quite likely that the behaviour in some cases changed especially
when SAMM is involved. I hope we made it better than before in
particular the DVI frequency check was probably broken before and
hopefully works better now.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
As there is only one user we can just insert the formula where
needed. Avoids one lookup in the modetable and
viafb_fill_var_timing_info does no longer depend on the modetable.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch introduces 2 new functions for selecting a single mode
based on hres, vres and refresh rate and changes some uses to use
those. The advantage is that it is less error prone than doing the
selection based on refresh rate everywhere and allows replacing the
modetable structure. This includes a little change that users may
notice: If a refresh rate was given as module parameters but does
not exist in the modetable prior to this patch a refresh rate of 60
was assumed and after this patch the closest supported refresh rate
to the one provided by the user is used.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
drivers/video/via/via-core.c: In function 'via_pci_probe':
drivers/video/via/via-core.c:691: warning: assignment discards qualifiers from pointer target type
Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
The timing for 640x480-60 was handled different than all others.
This patch changes this by changing the blanking start and end.
The reason for this is that I can't find any reason for the old
behaviour and it was not consistent anyway as the special case for
LCD did not always trigger as the LCD code does not use this
function and it did trigger regardless of whether the display set is
CRT or LCD but only based whether any DVI/LCD device exists.
There are no negative effects observed for CRT or DVI devices.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
As the first argument is just part of the structure passed as the
second argument there is no need for it at all.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
The locking is done within the viafb_set_*_timing functions so there
is no need to do it here. Move a missing hardware reset into the
modesetting function.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch replaces calls to viafb_load_crtc_timing with the code.
This should make it easier to fix the oddity that in the modetable
the blank and sync end entries contain the length and we need to add
the start values to get those to be written to the hardware.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch replaces the old timing setup code with a redesigned one.
The new code might be slightly faster as it has no conditinals and
does not write the same register multiple times. Also it makes the
comparison to the documentation easier.
Regressions are unlikely but could happen as a lot of hardware is
undocumented.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch adds checks for minimum and maximum pitch size to prevent
invalid settings which could otherwise crash the machine. Also the
alignment is done in a slightly more readable way.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: stable@kernel.org
As Laurent pointed out we must not use any information in the passed
var besides xoffset, yoffset and vmode as otherwise applications
might abuse it. Also use the aligned fix.line_length and not the
(possible) unaligned xres_virtual.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@kernel.org
* 'gpio/next' of git://git.secretlab.ca/git/linux-2.6:
gpio/via: rename VIA local config struct
basic_mmio_gpio: split into a gpio library and platform device
gpio: remove some legacy comments in build files
gpio: add trace events for setting direction and value
gpio/pca953x: Use handle_simple_irq instead of handle_edge_irq
gpiolib: export gpiochip_find
gpio: remove redundant Kconfig depends on GPIOLIB
basic_mmio_gpio: convert to non-__raw* accessors
basic_mmio_gpio: support direction registers
basic_mmio_gpio: support different input/output registers
basic_mmio_gpio: detect output method at probe time
basic_mmio_gpio: request register regions
basic_mmio_gpio: allow overriding number of gpio
basic_mmio_gpio: convert to platform_{get,set}_drvdata()
basic_mmio_gpio: remove runtime width/endianness evaluation
* 'viafb-next' of git://github.com/schandinat/linux-2.6: (24 commits)
viafb: Automatic OLPC XO-1.5 configuration
viafb: remove unused CEA mode
viafb: try to map less memory in case of failure
viafb: use write combining for video ram
viafb: add X server compatibility mode
viafb: reduce OLPC refresh a bit
viafb: fix OLPC XO 1.5 device connection
viafb: fix OLPC DCON refresh rate
viafb: delete clock and PLL initialization
viafb: replace custom return values
viafb: some small cleanup for global variables
viafb: gather common good, old VGA initialization in one place
viafb: add engine clock support
viafb: add VIA slapping capability
viafb: split clock and PLL code to an extra file
viafb: add primary/secondary clock on/off switches
viafb: add clock source selection and PLL power management support
viafb: prepare for PLL separation
viafb: call viafb_get_clk_value only in viafb_set_vclock
viafb: remove unused max_hres/vres
...
The local VIA GPIO config struct "gpio_config" collides with my
extension to the gpio_chip struct, so rename it to
viafb_gpio_config so we don't get this clash.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Currently, a long set of viafb options are needed to get the XO-1.5
laptop to output video (there is only 1 configuration that works, that
can't really be autodetected).
This patch automatically detects and configures viafb for the XO-1.5
laptop, meaning all that is required for working display is that
viafb is loaded.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
The current code might result in trying to remap 512MB video ram on
a 32 bit system which is quite likely to fail.
This patch tries to map less of it down to 8MB as this should still
be enough to get a reasonably well working framebuffer. This should
make viafb work for many people without requiring them to manually
allocate more space.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch adds a config option to be compatible with X servers like
OpenChrome. This is required as for example the X server does not
handle things like disabled IGAs/PLLs resulting in a potential
freeze on X startup. With this option disabled we can provide some
nice features like power management and not reinitializing the
hardware on every mode switch (taking long time, causing flickering).
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
When allowing some PLL calculation we get a frequency that seems to
be a bit higher than what the OLPC DCON likes resulting in a still
readable but not so good image. We don't really know whether this is
a problem with the calculation formula or the OLPC but as other
displays seem to be happy with the other modes adjusting the OLPC
refresh looks like the better thing. This patch prevents a
regression when dynamic PLL calculation is allowed.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch fixes the devices connected on OLPC. The OLPC panel seems
to be connected to DVP1 and LVDS2 for some reasons and if not both
are handled correct the display does not work correct or not at all.
This patch prevents regressions on the OLPC where it worked by
accident but would break in future as the driver did not know the
correct devices connected. This might also fix hardware scaling.
Hopefully the OLPC is the only device with such a requirement but it
will be certainly better to actually know what devices are actually
connected and to not work by accident.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>