init xv clone adaptor 90/32890/4
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 24 Dec 2014 05:58:19 +0000 (14:58 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 31 Dec 2014 11:14:30 +0000 (20:14 +0900)
Change-Id: Ia546183cb87d99eb1abd8e37256ae1ca7c1f532f
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
13 files changed:
src/Makefile.am
src/crtcconfig/sec_crtc.c
src/crtcconfig/sec_display.c
src/crtcconfig/sec_output.c
src/crtcconfig/sec_xberc.c
src/ipp/sec_wb.c
src/ipp/sec_wb.h
src/util/sec_util.h
src/xv/sec_video.c
src/xv/sec_video.h
src/xv/sec_video_clone.c [new file with mode: 0644]
src/xv/sec_video_clone.h [new file with mode: 0644]
src/xv/sec_video_virtual.c

index c8626b2..c8162d4 100644 (file)
@@ -39,12 +39,13 @@ exynos_drv_la_SOURCES += \
        xv/sec_video_tvout.c \
        xv/sec_video_virtual.c \
        xv/sec_video_display.c \
+       xv/sec_video_clone.c \
        xv/sec_video.c
 AM_CFLAGS += -I@top_srcdir@/src/xv
 
 # util
 exynos_drv_la_SOURCES += \
-       util/sec_util.c 
+       util/sec_util.c
 AM_CFLAGS += -I@top_srcdir@/src/util
 
 # debug
index 9b4377d..6a8a32b 100644 (file)
@@ -1913,10 +1913,6 @@ secCrtcApply(xf86CrtcPtr pCrtc)
                 continue;
 
             pOutputPriv = pOutput->driver_private;
-#if 1
-        if (pOutputPriv->mode_output->modes)
-            memcpy (&pSecMode->main_lcd_mode, pOutputPriv->mode_output->modes, sizeof(drmModeModeInfo));
-#endif
 
             /* TODO :: soolim :: check this out */
             secOutputDpmsSet(pOutput, DPMSModeOn);
index e3dc626..789178a 100644 (file)
@@ -1266,9 +1266,7 @@ secDisplaySetDispSetMode  (ScrnInfoPtr pScrn, SECDisplaySetMode set_mode)
 {
     SECPtr pSec = SECPTR (pScrn);
     SECModePtr pSecMode = pSec->pSecMode;
-#ifdef NO_CRTC_MODE
-    return TRUE;
-#endif
+
     if (pSecMode->set_mode == set_mode)
     {
         XDBG_INFO (MDISP, "set_mode(%d) is already set\n", set_mode);
@@ -1315,7 +1313,7 @@ secDisplaySetDispSetMode  (ScrnInfoPtr pScrn, SECDisplaySetMode set_mode)
 
             XDBG_TRACE (MWB, "wb_hz(%d) vrefresh(%d)\n", pSec->wb_hz, pSecMode->ext_connector_mode.vrefresh);
 
-            pSec->wb_clone = secWbOpen (pScrn, FOURCC_SN12, 0, 0, (pSec->scanout)?TRUE:FALSE, wb_hz, TRUE);
+            pSec->wb_clone = secWbOpen (pScrn, FOURCC_ST12, 0, 0, (pSec->scanout)?TRUE:FALSE, wb_hz, TRUE);
             if (pSec->wb_clone)
             {
                 secWbAddNotifyFunc (pSec->wb_clone, WB_NOTI_CLOSED,
index 9614e3c..4d87a80 100644 (file)
@@ -681,11 +681,11 @@ SECOutputSetProperty(xf86OutputPtr output, Atom property,
     /* set the hidden properties : features for sec debugging*/
     /* TODO : xberc can works on only LVDS????? */
 #ifdef NO_CRTC_MODE
-        if ((pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_HDMIA) ||
-            (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_VIRTUAL) ||
-            (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_LVDS))
+    if ((pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_HDMIA) ||
+        (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_VIRTUAL) ||
+        (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_LVDS))
 #else
-        if (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_LVDS)
+    if (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_LVDS)
 #endif
     {
         if (secPropSetLvdsFunc (output, property, value))
@@ -702,13 +702,7 @@ SECOutputSetProperty(xf86OutputPtr output, Atom property,
 
         if (secXbercSetProperty (output, property, value))
             return TRUE;
-    }
-    /* set the hidden properties : features for driver specific funtions */
 
-    if (pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
-        pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_HDMIB ||
-        pOutputPriv->mode_output->connector_type == DRM_MODE_CONNECTOR_VIRTUAL)
-    {
         /* set the property for the display mode */
         if (secPropSetDisplayMode(output, property, value))
             return TRUE;
index 9af272c..bed2cc1 100644 (file)
@@ -1230,7 +1230,7 @@ secXbercSetProperty (xf86OutputPtr output, Atom property, RRPropertyValuePtr val
     if (rr_property_atom != property)
     {
         _secXbercSetReturnProperty (value, "[Xberc]: Unrecognized property name.\n");
-        return TRUE;
+        return FALSE;
     }
 
     if (_secXbercParseArg (&argc, argv, value) == FALSE || argc < 1)
index eef539d..e80c24d 100644 (file)
@@ -75,8 +75,9 @@ enum
 
 enum
 {
-    STATUS_STARTED,
-    STATUS_STOPPED,
+    STATUS_RUNNING,
+    STATUS_PAUSE,
+    STATUS_STOP,
 };
 
 typedef struct _SECWbNotifyFuncInfo
@@ -149,7 +150,7 @@ static Atom atom_wb_rotate;
 static void _secWbQueue (SECWb *wb, int index);
 static Bool _secWbRegisterRotateHook (SECWb *wb, Bool hook);
 static void _secWbCloseDrmDstBuffer (SECWb *wb);
-static void _secWbCloseDrm (SECWb *wb);
+static void _secWbCloseDrm (SECWb *wb, Bool pause);
 
 static CARD32
 _secWbCountPrint (OsTimerPtr timer, CARD32 now, pointer arg)
@@ -253,6 +254,11 @@ _secWbLayerNotifyFunc (SECLayer *layer, int type, void *type_data, void *data)
     XDBG_RETURN_IF_FAIL (wb != NULL);
     XDBG_RETURN_IF_FAIL (VBUF_IS_VALID (vbuf));
 
+    if (wb->status == STATUS_PAUSE) {
+        XDBG_WARNING (MWB, "pause status. return.\n");
+        return;
+    }
+
     if (wb->wait_show >= 0 && wb->dst_buf[wb->wait_show] != vbuf)
         XDBG_WARNING (MWB, "wait_show(%d,%p) != showing_vbuf(%p). \n",
                       wb->wait_show, wb->dst_buf[wb->wait_show], vbuf);
@@ -480,9 +486,10 @@ secWbHandleIppEvent (int fd, unsigned int *buf_idx, void *data)
         wb->event_timer = NULL;
     }
 
-    if (wb->status == STATUS_STOPPED)
+    if ((wb->status == STATUS_STOP) || (wb->status == STATUS_PAUSE))
     {
-        XDBG_ERROR (MWB, "stopped. ignore a event. %p\n", data);
+        XDBG_ERROR (MWB, "stop or pause. ignore a event. %p, (status:%d)\n",
+            data, wb->status);
         return;
     }
 
@@ -725,7 +732,7 @@ _secWbOpenDrm (SECWb *wb)
 
 fail_to_open:
 
-    _secWbCloseDrm (wb);
+    _secWbCloseDrm (wb, FALSE);
 
     _secWbCloseDrmDstBuffer (wb);
 
@@ -733,7 +740,7 @@ fail_to_open:
 }
 
 static void
-_secWbCloseDrm (SECWb *wb)
+_secWbCloseDrm (SECWb *wb, Bool pause)
 {
     struct drm_exynos_ipp_cmd_ctrl ctrl;
     int i;
@@ -742,7 +749,8 @@ _secWbCloseDrm (SECWb *wb)
 
     XDBG_TRACE (MWB, "now_showing(%d) \n", wb->now_showing);
 
-    if (wb->tv)
+    /* pause : remain displaying layer buffer */
+    if (wb->tv && !pause)
     {
         secVideoTvDisconnect (wb->tv);
         wb->tv = NULL;
@@ -922,7 +930,7 @@ secWbIsRunning (void)
     if (!keep_wb)
         return FALSE;
 
-    return (keep_wb->status == STATUS_STARTED) ? TRUE : FALSE;
+    return (keep_wb->status == STATUS_RUNNING) ? TRUE : FALSE;
 }
 
 SECWb*
@@ -965,7 +973,7 @@ _secWbOpen (ScrnInfoPtr pScrn, unsigned int id, int width, int height,
 
     keep_wb->width = width;
     keep_wb->height = height;
-    keep_wb->status = STATUS_STOPPED;
+    keep_wb->status = STATUS_STOP;
 
     keep_wb->scanout = scanout;
     keep_wb->hz = (hz > 0) ? hz : 60;
@@ -1028,7 +1036,7 @@ _secWbStart (SECWb *wb, const char *func)
         return FALSE;
     }
 
-    if (wb->status == STATUS_STARTED)
+    if (wb->status == STATUS_RUNNING)
         return TRUE;
 
     if (!_secWbOpenDrm (wb))
@@ -1037,7 +1045,7 @@ _secWbStart (SECWb *wb, const char *func)
         return FALSE;
     }
 
-    wb->status = STATUS_STARTED;
+    wb->status = STATUS_RUNNING;
 
     _secWbCallNotifyFunc (wb, WB_NOTI_START, NULL);
 
@@ -1051,7 +1059,7 @@ _secWbStop (SECWb *wb, Bool close_buf,const char *func)
 {
     XDBG_RETURN_IF_FAIL (wb != NULL);
 
-    if (wb->status == STATUS_STOPPED)
+    if ((wb->status == STATUS_STOP) || (wb->status == STATUS_PAUSE))
     {
         if (wb->rotate_timer)
         {
@@ -1061,27 +1069,68 @@ _secWbStop (SECWb *wb, Bool close_buf,const char *func)
         return;
     }
 
-    _secWbCloseDrm (wb);
+    _secWbCloseDrm (wb, FALSE);
 
     if (close_buf)
         _secWbCloseDrmDstBuffer (wb);
     else
         _secWbClearDrmDstBuffer (wb);
 
-    wb->status = STATUS_STOPPED;
+    wb->status = STATUS_STOP;
 
     _secWbCallNotifyFunc (wb, WB_NOTI_STOP, NULL);
 
     XDBG_TRACE (MWB, "stop: %s \n", func);
 }
 
+void
+secWbPause (SECWb *wb)
+{
+    XDBG_RETURN_IF_FAIL (wb != NULL);
+
+    if ((wb->status == STATUS_STOP) || (wb->status == STATUS_PAUSE))
+    {
+        if (wb->rotate_timer)
+        {
+            TimerFree (wb->rotate_timer);
+            wb->rotate_timer = NULL;
+        }
+        return;
+    }
+
+    _secWbCloseDrm (wb, TRUE);
+
+    _secWbCloseDrmDstBuffer (wb);
+
+    wb->status = STATUS_PAUSE;
+
+    _secWbCallNotifyFunc (wb, WB_NOTI_PAUSE, NULL);
+
+    XDBG_TRACE (MWB, "pause: %s, wb(%p)\n", __func__, wb);
+}
+
+void
+secWbResume (SECWb *wb)
+{
+    wb->wait_show = -1;
+    wb->now_showing = -1;
+
+    if (!secWbStart (wb))
+    {
+        XDBG_ERROR(MWB, "wb(%p) start fail.%s\n", wb, __func__);
+        secWbClose (wb);
+        wb = NULL;
+    }
+    XDBG_TRACE (MWB, "start: %s, wb(%p)\n", __func__, wb);
+}
+
 Bool
 secWbSetBuffer (SECWb *wb, SECVideoBuf **vbufs, int bufnum)
 {
     int i;
 
     XDBG_RETURN_VAL_IF_FAIL (wb != NULL, FALSE);
-    XDBG_RETURN_VAL_IF_FAIL (wb->status != STATUS_STARTED, FALSE);
+    XDBG_RETURN_VAL_IF_FAIL (wb->status != STATUS_RUNNING, FALSE);
     XDBG_RETURN_VAL_IF_FAIL (vbufs != NULL, FALSE);
     XDBG_RETURN_VAL_IF_FAIL (wb->buf_num <= bufnum, FALSE);
     XDBG_RETURN_VAL_IF_FAIL (bufnum <= WB_BUF_MAX, FALSE);
@@ -1141,7 +1190,7 @@ secWbSetRotate (SECWb *wb, int rotate)
 
     wb->rotate = rotate;
 
-    if (wb->status == STATUS_STARTED)
+    if (wb->status == STATUS_RUNNING)
     {
         SECModePtr pSecMode = (SECModePtr) SECPTR (wb->pScrn)->pSecMode;
 
@@ -1176,7 +1225,7 @@ secWbSetTvout (SECWb *wb, Bool enable)
 
     wb->tvout = enable;
 
-    if (wb->status == STATUS_STARTED)
+    if (wb->status == STATUS_RUNNING)
     {
         secWbStop (wb, FALSE);
 
@@ -1207,7 +1256,7 @@ secWbSetSecure (SECWb *wb, Bool secure)
 
     wb->secure = secure;
 
-    if (wb->status == STATUS_STARTED)
+    if (wb->status == STATUS_RUNNING)
     {
         secWbStop (wb, TRUE);
 
index 38b9752..4a3b6f0 100644 (file)
@@ -43,6 +43,7 @@ typedef enum
     WB_NOTI_START,
     WB_NOTI_IPP_EVENT,
     WB_NOTI_IPP_EVENT_DONE,
+    WB_NOTI_PAUSE,
     WB_NOTI_STOP,
     WB_NOTI_CLOSED,
 } SECWbNotify;
@@ -89,6 +90,9 @@ Bool   secWbIsOpened  (void);
 Bool   secWbIsRunning (void);
 void   secWbDestroy   (void);
 
+void   secWbPause (SECWb *wb);
+void   secWbResume (SECWb *wb);
+
 unsigned int secWbGetPropID (void);
 void   secWbHandleIppEvent (int fd, unsigned int *buf_idx, void *data);
 
index 72f9fbe..07dd493 100644 (file)
@@ -70,6 +70,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define MEXAH   XDBG_M('E','X','A','H')
 #define MG2D    XDBG_M('G','2','D',0)
 #define MDOUT   XDBG_M('D','O','T',0)
+#define MCLON   XDBG_M('C','L','O','N')
 
 #define _XID(win)   ((unsigned int)(((WindowPtr)win)->drawable.id))
 
index cf044b4..f44fc1e 100644 (file)
@@ -62,6 +62,7 @@
 #include "sec_wb.h"
 #include "sec_video_virtual.h"
 #include "sec_video_display.h"
+#include "sec_video_clone.h"
 #include "sec_video_tvout.h"
 #include "sec_video_fourcc.h"
 #include "sec_converter.h"
@@ -1453,7 +1454,7 @@ _secVideoStreamOff (SECPortPrivPtr pPort)
 
     pPort->need_start_wb = FALSE;
     pPort->skip_tvout = FALSE;
-    pPort->usr_output = OUTPUT_LCD|OUTPUT_EXT;
+    pPort->usr_output = OUTPUT_LCD|OUTPUT_EXT|OUTPUT_FULL;
     pPort->outbuf_cvting = -1;
     pPort->drawing = 0;
     pPort->tv_prev_time = 0;
@@ -1485,7 +1486,7 @@ _secVideoCalculateSize (SECPortPrivPtr pPort)
     src_prop.height = pPort->d.height;
     src_prop.crop = pPort->d.src;
 
-     dst_prop.id = FOURCC_RGB32;
+    dst_prop.id = FOURCC_RGB32;
     if (pPort->drawing == ON_PIXMAP || pPort->drawing == ON_WINDOW)
     {
         dst_prop.width = pPort->d.pDraw->width;
@@ -2451,12 +2452,7 @@ SECVideoSetPortAttribute (ScrnInfoPtr pScrn,
     }
     else if (attribute == _portAtom (PAA_OUTPUT))
     {
-        if (value == OUTPUT_MODE_TVOUT)
-            pPort->usr_output = OUTPUT_LCD|OUTPUT_EXT|OUTPUT_FULL;
-        else if (value == OUTPUT_MODE_EXT_ONLY)
-            pPort->usr_output = OUTPUT_EXT|OUTPUT_FULL;
-        else
-            pPort->usr_output = OUTPUT_LCD|OUTPUT_EXT;
+        pPort->usr_output = OUTPUT_LCD|OUTPUT_EXT|OUTPUT_FULL;
 
         XDBG_DEBUG (MVDO, "output (%d) \n", (int) value);
 
@@ -2973,7 +2969,7 @@ secVideoSetupImageVideo (ScreenPtr pScreen)
     {
         pAdaptor->pPortPrivates[i].ptr = &pPort[i];
         pPort[i].index = i;
-        pPort[i].usr_output = OUTPUT_LCD|OUTPUT_EXT;
+        pPort[i].usr_output = OUTPUT_LCD|OUTPUT_EXT|OUTPUT_FULL;
         pPort[i].outbuf_cvting = -1;
     }
 
@@ -3064,6 +3060,16 @@ Bool secVideoInit (ScreenPtr pScreen)
         return FALSE;
     }
 
+    pVideo->pAdaptor[3] = secVideoSetupCloneVideo (pScreen);
+    if (!pVideo->pAdaptor[3])
+    {
+        free (pVideo->pAdaptor[2]);
+        free (pVideo->pAdaptor[1]);
+        free (pVideo->pAdaptor[0]);
+        free (pVideo);
+        return FALSE;
+    }
+
     xf86XVScreenInit (pScreen, pVideo->pAdaptor, ADAPTOR_NUM);
 
     SECVideoReplacePutImageFunc (pScreen);
index 54888bc..94a116c 100644 (file)
@@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef SEC_VIDEO_H
 #define SEC_VIDEO_H
 
-#define ADAPTOR_NUM  3
+#define ADAPTOR_NUM  4
 
 enum
 {
diff --git a/src/xv/sec_video_clone.c b/src/xv/sec_video_clone.c
new file mode 100644 (file)
index 0000000..42f2357
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ * xserver-xorg-video-exynos
+ *
+ * Copyright 2014 - 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Junkyeong Kim <jk0430.kim@samsung.com>
+ *
+ * Permission to use, copy, modify, distribute and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the authors and/or copyright holders
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  The authors and
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without any express
+ * or implied warranty.
+ *
+ * THE AUTHORS AND COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <pixman.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include <fourcc.h>
+
+#include <xf86xv.h>
+
+#include "sec.h"
+#include "sec_util.h"
+#include "sec_video_clone.h"
+#include "sec_video_fourcc.h"
+#include "sec_layer.h"
+
+#include "fimg2d.h"
+
+#define SEC_MAX_PORT        1
+#define LAYER_BUF_CNT       3
+#define OUTBUF_NUM          3
+
+static XF86VideoEncodingRec dummy_encoding[] =
+{
+    { 0, "XV_IMAGE", -1, -1, { 1, 1 } },
+    { 1, "XV_IMAGE", 4224, 4224, { 1, 1 } },
+};
+
+static XF86VideoFormatRec formats[] =
+{
+    { 16, TrueColor },
+    { 24, TrueColor },
+    { 32, TrueColor },
+};
+
+static XF86AttributeRec attributes[] =
+{
+    { 0, 0, 1, "_USER_WM_PORT_ATTRIBUTE_CLONE" },
+};
+
+typedef enum
+{
+    PAA_MIN,
+    PAA_FREEZE,
+    PAA_ROTATE,
+    PAA_MAX
+} SECPortAttrAtom;
+
+static struct
+{
+    SECPortAttrAtom  paa;
+    const char      *name;
+    Atom             atom;
+} atoms[] =
+{
+    { PAA_FREEZE, "_USER_WM_PORT_ATTRIBUTE_FREEZE", None },
+    { PAA_ROTATE, "_USER_WM_PORT_ATTRIBUTE_ROTATE", None },
+};
+
+/* SEC port information structure */
+typedef struct
+{
+    int index;
+
+    /* attributes */
+    Bool freeze;
+    int degree;
+    ScrnInfoPtr pScrn;
+
+    /* writeback */
+    SECWb *wb;
+
+    struct xorg_list link;
+} SECPortPriv, *SECPortPrivPtr;
+
+typedef struct _SECCloneVideoResource
+{
+    XID id;
+    RESTYPE type;
+
+    SECPortPrivPtr pPort;
+    ScrnInfoPtr pScrn;
+} SECCloneVideoResource;
+
+#define NUM_FORMATS       (sizeof(formats) / sizeof(formats[0]))
+#define NUM_ATTRIBUTES    (sizeof(attributes) / sizeof(attributes[0]))
+#define NUM_ATOMS         (sizeof(atoms) / sizeof(atoms[0]))
+
+static Atom
+_portAtom (SECPortAttrAtom paa)
+{
+    int i;
+
+    XDBG_RETURN_VAL_IF_FAIL (paa > PAA_MIN && paa < PAA_MAX, None);
+
+    for (i = 0; i < NUM_ATOMS; i++)
+    {
+        if (paa == atoms[i].paa)
+        {
+            if (atoms[i].atom == None)
+                atoms[i].atom = MakeAtom (atoms[i].name,
+                                          strlen (atoms[i].name), TRUE);
+
+            return atoms[i].atom;
+        }
+    }
+
+    XDBG_ERROR (MCLON, "Error: Unknown Port Attribute Name!\n");
+
+    return None;
+}
+
+static int
+SECCloneVideoGetPortAttribute (ScrnInfoPtr pScrn,
+                                 Atom        attribute,
+                                 INT32      *value,
+                                 pointer     data)
+{
+    SECPortPrivPtr pPort = (SECPortPrivPtr) data;
+
+    if (attribute == _portAtom (PAA_FREEZE)) {
+        *value = pPort->freeze;
+        return Success;
+    } else if (attribute == _portAtom (PAA_ROTATE)) {
+        *value = pPort->degree;
+        return Success;
+    }
+
+    return BadMatch;
+}
+
+static int
+SECCloneVideoSetPortAttribute (ScrnInfoPtr pScrn,
+                                 Atom        attribute,
+                                 INT32       value,
+                                 pointer     data)
+{
+    SECPortPrivPtr pPort = (SECPortPrivPtr) data;
+
+    if (attribute == _portAtom (PAA_FREEZE)) {
+        if (!pPort->wb) {
+            XDBG_ERROR (MCLON, "do PutVideo first\n");
+            return BadMatch;
+        }
+        if (pPort->freeze == value) {
+            XDBG_WARNING (MCLON, "same freeze cmd(%d)\n", (int)value);
+            return Success;
+        }
+
+        pPort->freeze = value;
+        XDBG_DEBUG (MCLON, "freeze(%d)\n", (int)value);
+
+        if (value == 1)
+            secWbPause(pPort->wb);
+        else
+            secWbResume(pPort->wb);
+        return Success;
+    } else if (attribute == _portAtom (PAA_ROTATE)) {
+        if (pPort->degree != value) {
+            pPort->degree = value;
+            if (pPort->wb) {
+                XDBG_DEBUG (MCLON, "rotate(%d)\n", (int)value);
+                secWbSetRotate (pPort->wb, pPort->degree);
+            }
+        }
+
+        return Success;
+    }
+
+    return BadMatch;
+}
+
+static int
+SECCloneVideoPutVideo (ScrnInfoPtr pScrn,
+                         short vid_x, short vid_y, short drw_x, short drw_y,
+                         short vid_w, short vid_h, short drw_w, short drw_h,
+                         RegionPtr clipBoxes, pointer data,
+                         DrawablePtr pDraw)
+{
+    SECPortPrivPtr pPort = (SECPortPrivPtr) data;
+    SECPtr pSec = SECPTR (pScrn);
+    SECModePtr pSecMode = pSec->pSecMode;
+    int wb_hz;
+
+    XDBG_DEBUG (MCLON, "SECCloneVideoPutVideo start\n");
+
+    if (pDraw->type != DRAWABLE_WINDOW) {
+        XDBG_ERROR (MCLON, "Fail : pDraw->type is not DRAWABLE_WINDOW.\n");
+        return BadRequest;
+    }
+
+    pPort->pScrn = pScrn;
+
+    if (pPort->wb) {
+        XDBG_ERROR (MCLON, "Fail : wb(%p) already exists.\n", pPort->wb);
+        return BadRequest;
+    }
+
+    if (secWbIsOpened()) {
+        XDBG_ERROR (MCLON, "Fail : wb(%d) already opened.\n", secWbGet());
+        return BadRequest;
+    }
+
+    wb_hz = (pSec->wb_hz > 0)?pSec->wb_hz:pSecMode->ext_connector_mode.vrefresh;
+    XDBG_TRACE (MCLON, "wb_hz(%d) vrefresh(%d)\n",
+        pSec->wb_hz, pSecMode->ext_connector_mode.vrefresh);
+
+    pPort->wb = secWbOpen(pPort->pScrn, FOURCC_ST12,
+            pDraw->width, pDraw->height,
+            pSec->scanout, wb_hz, FALSE);//(pPort->degree)?FALSE:TRUE);
+    XDBG_RETURN_VAL_IF_FAIL(pPort->wb != NULL, BadAlloc);
+
+    if (pPort->wb) {
+        secWbSetRotate (pPort->wb, pSecMode->rotate);//pPort->degree);
+        XDBG_DEBUG (MCLON, "pSecMode->rotate : %d\n", pSecMode->rotate);
+        secWbSetTvout (pPort->wb, TRUE);
+
+        XDBG_TRACE(MCLON, "wb(%p) start.\n", pPort->wb);
+        if (!secWbStart (pPort->wb)) {
+            XDBG_ERROR(MCLON, "wb(%p) start fail.\n", pPort->wb);
+            secWbClose (pSec->wb_clone);
+            pPort->wb = NULL;
+            return BadDrawable;
+        }
+    }
+
+    if (!secWbIsRunning()) {
+        XDBG_WARNING (MCLON, "wb is stopped.\n");
+        return BadRequest;
+    }
+
+    XDBG_TRACE (MCLON, "wb(%p), running(%d).\n", pPort->wb, secWbIsRunning());
+
+    return Success;
+}
+
+static void
+SECCloneVideoStop (ScrnInfoPtr pScrn, pointer data, Bool exit)
+{
+    SECPortPrivPtr pPort = (SECPortPrivPtr) data;
+
+    XDBG_TRACE (MCLON, "exit (%d) \n", exit);
+
+    if (!exit)
+        return;
+
+    if (pPort->wb) {
+        secWbClose(pPort->wb);
+        pPort->wb = NULL;
+        XDBG_TRACE (MCLON, "excuted\n");
+    }
+    pPort->freeze = 0;
+    pPort->degree = 0;
+}
+
+static void
+SECCloneVideoQueryBestSize (ScrnInfoPtr pScrn,
+                              Bool motion,
+                              short vid_w, short vid_h,
+                              short dst_w, short dst_h,
+                              unsigned int *p_w, unsigned int *p_h,
+                              pointer data)
+{
+    if (p_w)
+        *p_w = (unsigned int)dst_w & (~0x1);
+    if (p_h)
+        *p_h = (unsigned int)dst_h & (~0x1);
+}
+
+XF86VideoAdaptorPtr
+secVideoSetupCloneVideo (ScreenPtr pScreen)
+{
+    XF86VideoAdaptorPtr pAdaptor;
+    SECPortPrivPtr pPort;
+    int i;
+
+    pAdaptor = calloc (1, sizeof (XF86VideoAdaptorRec) +
+                       (sizeof (DevUnion) + sizeof (SECPortPriv)) * SEC_MAX_PORT);
+    if (!pAdaptor)
+        return NULL;
+
+    dummy_encoding[0].width = pScreen->width;
+    dummy_encoding[0].height = pScreen->height;
+
+    pAdaptor->type = XvWindowMask | XvInputMask | XvVideoMask;
+    pAdaptor->flags = VIDEO_OVERLAID_IMAGES;
+    pAdaptor->name = "SEC Clone Video";
+    pAdaptor->nEncodings = sizeof (dummy_encoding) / sizeof (XF86VideoEncodingRec);
+    pAdaptor->pEncodings = dummy_encoding;
+    pAdaptor->nFormats = NUM_FORMATS;
+    pAdaptor->pFormats = formats;
+    pAdaptor->nPorts = SEC_MAX_PORT;
+    pAdaptor->pPortPrivates = (DevUnion*)(&pAdaptor[1]);
+
+    pPort = (SECPortPrivPtr) (&pAdaptor->pPortPrivates[SEC_MAX_PORT]);
+
+    for (i = 0; i < SEC_MAX_PORT; i++)
+    {
+        pAdaptor->pPortPrivates[i].ptr = &pPort[i];
+        pPort[i].index = i;
+        pPort[i].freeze = 0;
+        pPort[i].degree = 0;
+    }
+
+    pAdaptor->nAttributes = NUM_ATTRIBUTES;
+    pAdaptor->pAttributes = attributes;
+
+    pAdaptor->GetPortAttribute     = SECCloneVideoGetPortAttribute;
+    pAdaptor->SetPortAttribute     = SECCloneVideoSetPortAttribute;
+    pAdaptor->PutVideo             = SECCloneVideoPutVideo;
+    pAdaptor->StopVideo            = SECCloneVideoStop;
+    pAdaptor->QueryBestSize        = SECCloneVideoQueryBestSize;
+
+    return pAdaptor;
+}
diff --git a/src/xv/sec_video_clone.h b/src/xv/sec_video_clone.h
new file mode 100644 (file)
index 0000000..43f19d5
--- /dev/null
@@ -0,0 +1,36 @@
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2014 - 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Junkyeong Kim <jk0430.kim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+#ifndef __SEC_VIDEO_CLONE_H__
+#define __SEC_VIDEO_CLONE_H__
+
+/* setup clone adaptor */
+XF86VideoAdaptorPtr secVideoSetupCloneVideo (ScreenPtr pScreen);
+
+#endif
\ No newline at end of file
index af74c98..1878ec7 100644 (file)
@@ -1111,7 +1111,8 @@ _secVirtualStillCompositeExtLayers (SECPortPrivPtr pPort, int connector_type, Bo
     if (!complete)
     {
         /* check if operation in process*/
-        if (pPort->wait_rgb_convert) goto convert_ipp_still;
+        if (pPort->wait_rgb_convert)
+            goto convert_ipp_still;
 
         if (lower_layer)
         {
@@ -1136,12 +1137,13 @@ _secVirtualStillCompositeExtLayers (SECPortPrivPtr pPort, int connector_type, Bo
                 comp = TRUE;
              }
         }
-    } else
-         {
-          if (pPort->capture_dstbuf)
-          dst_buf = pPort->capture_dstbuf;
-          pPort->wait_rgb_convert = FALSE;
-         }
+    }
+    else
+    {
+        if (pPort->capture_dstbuf)
+            dst_buf = pPort->capture_dstbuf;
+        pPort->wait_rgb_convert = FALSE;
+    }
 
     pix_buf = _secVirtualVideoGetDrawableBuffer (pPort);
     XDBG_GOTO_IF_FAIL (pix_buf != NULL, done_ipp_still);