0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #define DSS_SUBSYS_NAME "OVERLAY"
0013
0014 #include <linux/kernel.h>
0015 #include <linux/module.h>
0016 #include <linux/err.h>
0017 #include <linux/sysfs.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/delay.h>
0020 #include <linux/slab.h>
0021
0022 #include <video/omapfb_dss.h>
0023
0024 #include "dss.h"
0025 #include "dss_features.h"
0026
0027 static int num_overlays;
0028 static struct omap_overlay *overlays;
0029
0030 int omap_dss_get_num_overlays(void)
0031 {
0032 return num_overlays;
0033 }
0034 EXPORT_SYMBOL(omap_dss_get_num_overlays);
0035
0036 struct omap_overlay *omap_dss_get_overlay(int num)
0037 {
0038 if (num >= num_overlays)
0039 return NULL;
0040
0041 return &overlays[num];
0042 }
0043 EXPORT_SYMBOL(omap_dss_get_overlay);
0044
0045 void dss_init_overlays(struct platform_device *pdev)
0046 {
0047 int i, r;
0048
0049 num_overlays = dss_feat_get_num_ovls();
0050
0051 overlays = kcalloc(num_overlays, sizeof(struct omap_overlay),
0052 GFP_KERNEL);
0053
0054 BUG_ON(overlays == NULL);
0055
0056 for (i = 0; i < num_overlays; ++i) {
0057 struct omap_overlay *ovl = &overlays[i];
0058
0059 switch (i) {
0060 case 0:
0061 ovl->name = "gfx";
0062 ovl->id = OMAP_DSS_GFX;
0063 break;
0064 case 1:
0065 ovl->name = "vid1";
0066 ovl->id = OMAP_DSS_VIDEO1;
0067 break;
0068 case 2:
0069 ovl->name = "vid2";
0070 ovl->id = OMAP_DSS_VIDEO2;
0071 break;
0072 case 3:
0073 ovl->name = "vid3";
0074 ovl->id = OMAP_DSS_VIDEO3;
0075 break;
0076 }
0077
0078 ovl->caps = dss_feat_get_overlay_caps(ovl->id);
0079 ovl->supported_modes =
0080 dss_feat_get_supported_color_modes(ovl->id);
0081
0082 r = dss_overlay_kobj_init(ovl, pdev);
0083 if (r)
0084 DSSERR("failed to create sysfs file\n");
0085 }
0086 }
0087
0088 void dss_uninit_overlays(struct platform_device *pdev)
0089 {
0090 int i;
0091
0092 for (i = 0; i < num_overlays; ++i) {
0093 struct omap_overlay *ovl = &overlays[i];
0094 dss_overlay_kobj_uninit(ovl);
0095 }
0096
0097 kfree(overlays);
0098 overlays = NULL;
0099 num_overlays = 0;
0100 }
0101
0102 int dss_ovl_simple_check(struct omap_overlay *ovl,
0103 const struct omap_overlay_info *info)
0104 {
0105 if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
0106 if (info->out_width != 0 && info->width != info->out_width) {
0107 DSSERR("check_overlay: overlay %d doesn't support "
0108 "scaling\n", ovl->id);
0109 return -EINVAL;
0110 }
0111
0112 if (info->out_height != 0 && info->height != info->out_height) {
0113 DSSERR("check_overlay: overlay %d doesn't support "
0114 "scaling\n", ovl->id);
0115 return -EINVAL;
0116 }
0117 }
0118
0119 if ((ovl->supported_modes & info->color_mode) == 0) {
0120 DSSERR("check_overlay: overlay %d doesn't support mode %d\n",
0121 ovl->id, info->color_mode);
0122 return -EINVAL;
0123 }
0124
0125 if (info->zorder >= omap_dss_get_num_overlays()) {
0126 DSSERR("check_overlay: zorder %d too high\n", info->zorder);
0127 return -EINVAL;
0128 }
0129
0130 if (dss_feat_rotation_type_supported(info->rotation_type) == 0) {
0131 DSSERR("check_overlay: rotation type %d not supported\n",
0132 info->rotation_type);
0133 return -EINVAL;
0134 }
0135
0136 return 0;
0137 }
0138
0139 int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
0140 const struct omap_video_timings *mgr_timings)
0141 {
0142 u16 outw, outh;
0143 u16 dw, dh;
0144
0145 dw = mgr_timings->x_res;
0146 dh = mgr_timings->y_res;
0147
0148 if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
0149 outw = info->width;
0150 outh = info->height;
0151 } else {
0152 if (info->out_width == 0)
0153 outw = info->width;
0154 else
0155 outw = info->out_width;
0156
0157 if (info->out_height == 0)
0158 outh = info->height;
0159 else
0160 outh = info->out_height;
0161 }
0162
0163 if (dw < info->pos_x + outw) {
0164 DSSERR("overlay %d horizontally not inside the display area "
0165 "(%d + %d >= %d)\n",
0166 ovl->id, info->pos_x, outw, dw);
0167 return -EINVAL;
0168 }
0169
0170 if (dh < info->pos_y + outh) {
0171 DSSERR("overlay %d vertically not inside the display area "
0172 "(%d + %d >= %d)\n",
0173 ovl->id, info->pos_y, outh, dh);
0174 return -EINVAL;
0175 }
0176
0177 return 0;
0178 }
0179
0180
0181
0182
0183
0184 bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
0185 enum omap_color_mode mode)
0186 {
0187 if (mode != OMAP_DSS_COLOR_RGB12U && mode != OMAP_DSS_COLOR_RGB16)
0188 return false;
0189
0190 return config.video_port_width > 16;
0191 }