vmwgfx_rr_inlines.h revision 34a0776d
134a0776dSmrg/**************************************************************************
234a0776dSmrg * Copyright © 2016 VMware, Inc., Palo Alto, CA., USA
334a0776dSmrg * All Rights Reserved.
434a0776dSmrg *
534a0776dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
634a0776dSmrg * copy of this software and associated documentation files (the
734a0776dSmrg * "Software"), to deal in the Software without restriction, including
834a0776dSmrg * without limitation the rights to use, copy, modify, merge, publish,
934a0776dSmrg * distribute, sub license, and/or sell copies of the Software, and to
1034a0776dSmrg * permit persons to whom the Software is furnished to do so, subject to
1134a0776dSmrg * the following conditions:
1234a0776dSmrg *
1334a0776dSmrg * The above copyright notice and this permission notice (including the
1434a0776dSmrg * next paragraph) shall be included in all copies or substantial portions
1534a0776dSmrg * of the Software.
1634a0776dSmrg *
1734a0776dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1834a0776dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1934a0776dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
2034a0776dSmrg * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
2134a0776dSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2234a0776dSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2334a0776dSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
2434a0776dSmrg *
2534a0776dSmrg **************************************************************************/
2634a0776dSmrg/*
2734a0776dSmrg * This file contains calls into the RandR1.2 code and modification of core
2834a0776dSmrg * RandR data structures that probably were never intended from drivers.
2934a0776dSmrg */
3034a0776dSmrg
3134a0776dSmrg#ifndef _VMWGFX_RR_INLINES_H_
3234a0776dSmrg#define _VMWGFX_RR_INLINES_H_
3334a0776dSmrg
3434a0776dSmrg#include <xf86Crtc.h>
3534a0776dSmrg#include <xf86RandR12.h>
3634a0776dSmrg
3734a0776dSmrg#define VMW_DPI 96.
3834a0776dSmrg#define VMW_INCH_TO_MM 25.4
3934a0776dSmrg
4034a0776dSmrg/**
4134a0776dSmrg * vmwgfx_notify_rr - Notify RandR that our configuration has changed.
4234a0776dSmrg *
4334a0776dSmrg * @pScreen: Pointer to the affected screen.
4434a0776dSmrg *
4534a0776dSmrg * Normally screen configurations are typically only changed using RandR,
4634a0776dSmrg * so when we do it in an udev handler, we need to notify RandR that we've
4734a0776dSmrg * made a change, so that it can be propagated to all RandR clients.
4834a0776dSmrg */
4934a0776dSmrgstatic inline void
5034a0776dSmrgvmwgfx_notify_rr(ScreenPtr pScreen)
5134a0776dSmrg{
5234a0776dSmrg    rrScrPriv(pScreen);
5334a0776dSmrg
5434a0776dSmrg
5534a0776dSmrg    /*
5634a0776dSmrg     * We need to update the time-stamps, otherwise X clients that haven't
5734a0776dSmrg     * yet read this config might just overwrite it.
5834a0776dSmrg     * This effectively stops the desktop manager from trying to
5934a0776dSmrg     * outsmart us, since RandR simply doesn't accept requests from
6034a0776dSmrg     * clients that haven't read this config and tag their request with
6134a0776dSmrg     * an earlier timestamp.
6234a0776dSmrg     */
6334a0776dSmrg    pScrPriv->lastSetTime = currentTime;
6434a0776dSmrg    pScrPriv->lastConfigTime = currentTime;
6534a0776dSmrg#ifdef RANDR_12_INTERFACE
6634a0776dSmrg    xf86RandR12TellChanged(pScreen);
6734a0776dSmrg#else
6834a0776dSmrg    RRTellChanged(pScreen);
6934a0776dSmrg#endif
7034a0776dSmrg}
7134a0776dSmrg
7234a0776dSmrg/**
7334a0776dSmrg * vmwgfx_rr_screen_set_size - Use RandR to change the root pixmap dimensions.
7434a0776dSmrg *
7534a0776dSmrg * @pScreen: Pointer to the affected screen.
7634a0776dSmrg *
7734a0776dSmrg * Returns: TRUE if successful. False otherwise.
7834a0776dSmrg */
7934a0776dSmrgstatic inline Bool
8034a0776dSmrgvmwgfx_rr_screen_set_size(ScreenPtr pScreen, int width, int height)
8134a0776dSmrg{
8234a0776dSmrg    rrScrPriv(pScreen);
8334a0776dSmrg    float mm_width, mm_height;
8434a0776dSmrg
8534a0776dSmrg    mm_width = ((float) width) * VMW_INCH_TO_MM / VMW_DPI + .5;
8634a0776dSmrg    mm_height = ((float) height) * VMW_INCH_TO_MM / VMW_DPI + .5;
8734a0776dSmrg
8834a0776dSmrg    return pScrPriv->rrScreenSetSize(pScreen, width, height,
8934a0776dSmrg				     (int) mm_width, (int) mm_height);
9034a0776dSmrg}
9134a0776dSmrg
9234a0776dSmrg#endif
93