summaryrefslogtreecommitdiff
path: root/sys/pvr2d/gstpvr.c
blob: 1f86abc89ba118b1ccb0375f9d64d7f3d923de4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * GStreamer
 * Copyright (c) 2010, Texas Instruments Incorporated
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation
 * version 2.1 of the License.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include "gstpvr.h"
#include "gstpvrvideosink.h"

GST_DEBUG_CATEGORY (gst_debug_pvrvideosink);

static gboolean
plugin_init (GstPlugin * plugin)
{
  GST_DEBUG_CATEGORY_INIT (gst_debug_pvrvideosink, "pvrvideosink", 0,
      "pvrvideosink");

  return gst_element_register (plugin, "pvrvideosink", GST_RANK_PRIMARY,
      GST_TYPE_PVRVIDEOSINK);
}

void *
gst_ducati_alloc_1d (gint sz)
{
  MemAllocBlock block = {
    .pixelFormat = PIXEL_FMT_PAGE,
    .dim.len = sz,
  };
  return MemMgr_Alloc (&block, 1);
}

void *
gst_ducati_alloc_2d (gint width, gint height, guint * sz)
{
  MemAllocBlock block[] = { {
          .pixelFormat = PIXEL_FMT_8BIT,
          .dim = {.area = {
                      .width = width,
                      .height = ALIGN2 (height, 1),
                  }},
      .stride = 4096}, {
        .pixelFormat = PIXEL_FMT_16BIT,
        .dim = {.area = {
                    .width = width,
                    .height = ALIGN2 (height, 1) / 2,
                }},
      .stride = 4096}
  };
  if (sz) {
    *sz = (4096 * ALIGN2 (height, 1) * 3) / 2;
  }
  return MemMgr_Alloc (block, 2);
}

static struct
{
  PVR2DERROR code;
  const gchar *errstring;
} pvr2derrorcodestring[] = {
  {
  PVR2D_OK, "OK (0)"}, {
  PVR2DERROR_INVALID_PARAMETER, "Invalid Parameter (-1)"}, {
  PVR2DERROR_DEVICE_UNAVAILABLE, "Device Unavailable (-2)"}, {
  PVR2DERROR_INVALID_CONTEXT, "Invalid Context (-3)"}, {
  PVR2DERROR_MEMORY_UNAVAILABLE, "Memory Unavailable (-4)"}, {
  PVR2DERROR_DEVICE_NOT_PRESENT, "Device not present (-5)"}, {
  PVR2DERROR_IOCTL_ERROR, "ioctl Error (-6)"}, {
  PVR2DERROR_GENERIC_ERROR, "Generic Error (-7)"}, {
  PVR2DERROR_BLT_NOTCOMPLETE, "blt not complete (-8)"}, {
  PVR2DERROR_HW_FEATURE_NOT_SUPPORTED, "Hardware feature not supported (-9)"}, {
  PVR2DERROR_NOT_YET_IMPLEMENTED, "Not yet implemented (-10)"}, {
  PVR2DERROR_MAPPING_FAILED, "Mapping failed (-11)"}
};

const gchar *
gst_pvr2d_error_get_string (PVR2DERROR code)
{
  if (code <= PVR2D_OK && code >= PVR2DERROR_MAPPING_FAILED)
    return pvr2derrorcodestring[PVR2D_OK - code].errstring;
  return "Uknown Error";
}

/* PACKAGE: this is usually set by autotools depending on some _INIT macro
 * in configure.ac and then written into and defined in config.h, but we can
 * just set it ourselves here in case someone doesn't use autotools to
 * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
 */
#ifndef PACKAGE
#  define PACKAGE "ducati"
#endif

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
    GST_VERSION_MINOR,
    pvr,
    "Pvr2d based plugin",
    plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")