Bug 13535 - scaling done incorrectly in penmount/DMC9000 when both InvertY and SwapXY are on
Summary: scaling done incorrectly in penmount/DMC9000 when both InvertY and SwapXY are on
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/penmount (show other bugs)
Version: unspecified
Hardware: All All
: medium major
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-05 07:57 UTC by Dmitrii Tisnek
Modified: 2008-06-22 01:43 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch that calls swapXY before inverting and scaling the X and Y axes for the DMC9000. (772 bytes, patch)
2008-06-22 00:18 UTC, Arrigo Marchiori
no flags Details | Splinter Review

Description Dmitrii Tisnek 2007-12-05 07:57:50 UTC
penmount versions: at least 1.2.0, 1.2.1
xorg: 1.3.0

the following code is incorrect:

                if (priv->invert_y) 
                {
                        y = priv->max_y - y;
                }
                if ( priv->swap_xy)
                {
                        tmp = y;
                        y = x;
                        x = tmp;        
                }
                priv->packet[0] = priv->pen_down ? 0x01 : 0x00;

                if (priv->reporting_mode == TS_Scaled)
                {       
                        x = xf86ScaleAxis (x, 0, priv->screen_width, priv->min_x
,
                                           priv->max_x);
                        y = xf86ScaleAxis (y, 0, priv->screen_height, priv->min_
y,
                                           priv->max_y);
                }

when both SwapXY and InvertY are On, final value of x becomes:
scale(max_y - y, min_x, max_x)

which is incorrect - x should not depend on both max_x and max_y simultaneousely.

I propose to scale first, then invert and swap.
(alternatively, scale, swap, invert if that's easier to understand and both invertx and inverty are provided)

Hardware where both SwapXY and InvertY are needed: iEi Afolux AFL-08A.
Comment 1 Arrigo Marchiori 2008-06-22 00:18:03 UTC
Created attachment 17285 [details] [review]
Patch that calls swapXY before inverting and scaling the X and Y axes for the DMC9000.

This patch calls swapXY before doing any axes' scaling and inverting.
It does it only for the DMC9000 devices, that is where the bug was detected.
Comment 2 Arrigo Marchiori 2008-06-22 00:18:43 UTC
I confirm this wrong behavior.

I personally think that this is a major bug, at least for us who need this feature. That's why I'm changing its priority.

I'm attaching a patch that does the only solution that Dmitrii hasn't proposed :-)
That is: first swapping, then inverting and scaling. I think it's the most intuitive solution to the problem, because it makes minX, maxX & co. act on the _actual_ X and Y axes, from the user/developer point of view.

Anyway, the solution can be easily changed by moving the block "if ( priv->swap_xy) { ... }", as Dimitrii has clearly pointed out.
Comment 3 Peter Hutterer 2008-06-22 01:43:12 UTC
Pushed as 8a9ff94e3db692736f86d52e569f65f6f363b0e0. Thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.