Commit f2434237 authored by Francisco Jerez's avatar Francisco Jerez Committed by Ben Skeggs

drm/nouveau: Break some long lines in the TV-out code.

Signed-off-by: default avatarFrancisco Jerez <currojerez@riseup.net>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 8597a1ba
...@@ -193,55 +193,56 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector) ...@@ -193,55 +193,56 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector)
} }
} }
static const struct { static int nv17_tv_get_ld_modes(struct drm_encoder *encoder,
int hdisplay; struct drm_connector *connector)
int vdisplay;
} modes[] = {
{ 640, 400 },
{ 640, 480 },
{ 720, 480 },
{ 720, 576 },
{ 800, 600 },
{ 1024, 768 },
{ 1280, 720 },
{ 1280, 1024 },
{ 1920, 1080 }
};
static int nv17_tv_get_modes(struct drm_encoder *encoder,
struct drm_connector *connector)
{ {
struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
struct drm_display_mode *mode; struct drm_display_mode *mode, *tv_mode;
struct drm_display_mode *output_mode;
int n = 0; int n = 0;
int i;
if (tv_norm->kind != CTV_ENC_MODE) { for (tv_mode = nv17_tv_modes; tv_mode->hdisplay; tv_mode++) {
struct drm_display_mode *tv_mode; mode = drm_mode_duplicate(encoder->dev, tv_mode);
for (tv_mode = nv17_tv_modes; tv_mode->hdisplay; tv_mode++) { mode->clock = tv_norm->tv_enc_mode.vrefresh *
mode = drm_mode_duplicate(encoder->dev, tv_mode); mode->htotal / 1000 *
mode->vtotal / 1000;
mode->clock = tv_norm->tv_enc_mode.vrefresh * if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
mode->htotal / 1000 * mode->clock *= 2;
mode->vtotal / 1000;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
mode->clock *= 2;
if (mode->hdisplay == tv_norm->tv_enc_mode.hdisplay && if (mode->hdisplay == tv_norm->tv_enc_mode.hdisplay &&
mode->vdisplay == tv_norm->tv_enc_mode.vdisplay) mode->vdisplay == tv_norm->tv_enc_mode.vdisplay)
mode->type |= DRM_MODE_TYPE_PREFERRED; mode->type |= DRM_MODE_TYPE_PREFERRED;
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
n++; n++;
}
return n;
} }
/* tv_norm->kind == CTV_ENC_MODE */ return n;
output_mode = &tv_norm->ctv_enc_mode.mode; }
static int nv17_tv_get_hd_modes(struct drm_encoder *encoder,
struct drm_connector *connector)
{
struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
struct drm_display_mode *output_mode = &tv_norm->ctv_enc_mode.mode;
struct drm_display_mode *mode;
const struct {
int hdisplay;
int vdisplay;
} modes[] = {
{ 640, 400 },
{ 640, 480 },
{ 720, 480 },
{ 720, 576 },
{ 800, 600 },
{ 1024, 768 },
{ 1280, 720 },
{ 1280, 1024 },
{ 1920, 1080 }
};
int i, n = 0;
for (i = 0; i < ARRAY_SIZE(modes); i++) { for (i = 0; i < ARRAY_SIZE(modes); i++) {
if (modes[i].hdisplay > output_mode->hdisplay || if (modes[i].hdisplay > output_mode->hdisplay ||
modes[i].vdisplay > output_mode->vdisplay) modes[i].vdisplay > output_mode->vdisplay)
...@@ -251,11 +252,12 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder, ...@@ -251,11 +252,12 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder,
modes[i].vdisplay == output_mode->vdisplay) { modes[i].vdisplay == output_mode->vdisplay) {
mode = drm_mode_duplicate(encoder->dev, output_mode); mode = drm_mode_duplicate(encoder->dev, output_mode);
mode->type |= DRM_MODE_TYPE_PREFERRED; mode->type |= DRM_MODE_TYPE_PREFERRED;
} else { } else {
mode = drm_cvt_mode(encoder->dev, modes[i].hdisplay, mode = drm_cvt_mode(encoder->dev, modes[i].hdisplay,
modes[i].vdisplay, 60, false, modes[i].vdisplay, 60, false,
output_mode->flags & DRM_MODE_FLAG_INTERLACE, (output_mode->flags &
false); DRM_MODE_FLAG_INTERLACE), false);
} }
/* CVT modes are sometimes unsuitable... */ /* CVT modes are sometimes unsuitable... */
...@@ -266,6 +268,7 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder, ...@@ -266,6 +268,7 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder,
- mode->hdisplay) * 9 / 10) & ~7; - mode->hdisplay) * 9 / 10) & ~7;
mode->hsync_end = mode->hsync_start + 8; mode->hsync_end = mode->hsync_start + 8;
} }
if (output_mode->vdisplay >= 1024) { if (output_mode->vdisplay >= 1024) {
mode->vtotal = output_mode->vtotal; mode->vtotal = output_mode->vtotal;
mode->vsync_start = output_mode->vsync_start; mode->vsync_start = output_mode->vsync_start;
...@@ -276,9 +279,21 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder, ...@@ -276,9 +279,21 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder,
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
n++; n++;
} }
return n; return n;
} }
static int nv17_tv_get_modes(struct drm_encoder *encoder,
struct drm_connector *connector)
{
struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
if (tv_norm->kind == CTV_ENC_MODE)
return nv17_tv_get_hd_modes(encoder, connector);
else
return nv17_tv_get_ld_modes(encoder, connector);
}
static int nv17_tv_mode_valid(struct drm_encoder *encoder, static int nv17_tv_mode_valid(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
......
...@@ -127,7 +127,8 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder); ...@@ -127,7 +127,8 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
/* TV hardware access functions */ /* TV hardware access functions */
static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg, uint32_t val) static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
uint32_t val)
{ {
nv_wr32(dev, reg, val); nv_wr32(dev, reg, val);
} }
...@@ -137,7 +138,8 @@ static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg) ...@@ -137,7 +138,8 @@ static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
return nv_rd32(dev, reg); return nv_rd32(dev, reg);
} }
static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg, uint8_t val) static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg,
uint8_t val)
{ {
nv_write_ptv(dev, NV_PTV_TV_INDEX, reg); nv_write_ptv(dev, NV_PTV_TV_INDEX, reg);
nv_write_ptv(dev, NV_PTV_TV_DATA, val); nv_write_ptv(dev, NV_PTV_TV_DATA, val);
...@@ -149,8 +151,11 @@ static inline uint8_t nv_read_tv_enc(struct drm_device *dev, uint8_t reg) ...@@ -149,8 +151,11 @@ static inline uint8_t nv_read_tv_enc(struct drm_device *dev, uint8_t reg)
return nv_read_ptv(dev, NV_PTV_TV_DATA); return nv_read_ptv(dev, NV_PTV_TV_DATA);
} }
#define nv_load_ptv(dev, state, reg) nv_write_ptv(dev, NV_PTV_OFFSET + 0x##reg, state->ptv_##reg) #define nv_load_ptv(dev, state, reg) \
#define nv_save_ptv(dev, state, reg) state->ptv_##reg = nv_read_ptv(dev, NV_PTV_OFFSET + 0x##reg) nv_write_ptv(dev, NV_PTV_OFFSET + 0x##reg, state->ptv_##reg)
#define nv_load_tv_enc(dev, state, reg) nv_write_tv_enc(dev, 0x##reg, state->tv_enc[0x##reg]) #define nv_save_ptv(dev, state, reg) \
state->ptv_##reg = nv_read_ptv(dev, NV_PTV_OFFSET + 0x##reg)
#define nv_load_tv_enc(dev, state, reg) \
nv_write_tv_enc(dev, 0x##reg, state->tv_enc[0x##reg])
#endif #endif
...@@ -336,12 +336,17 @@ static void tv_setup_filter(struct drm_encoder *encoder) ...@@ -336,12 +336,17 @@ static void tv_setup_filter(struct drm_encoder *encoder)
struct filter_params *p = &fparams[k][j]; struct filter_params *p = &fparams[k][j];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
int64_t c = (p->k1 + p->ki*i + p->ki2*i*i + p->ki3*i*i*i) int64_t c = (p->k1 + p->ki*i + p->ki2*i*i +
+ (p->kr + p->kir*i + p->ki2r*i*i + p->ki3r*i*i*i)*rs[k] p->ki3*i*i*i)
+ (p->kf + p->kif*i + p->ki2f*i*i + p->ki3f*i*i*i)*flicker + (p->kr + p->kir*i + p->ki2r*i*i +
+ (p->krf + p->kirf*i + p->ki2rf*i*i + p->ki3rf*i*i*i)*flicker*rs[k]; p->ki3r*i*i*i) * rs[k]
+ (p->kf + p->kif*i + p->ki2f*i*i +
(*filters[k])[j][i] = (c + id5/2) >> 39 & (0x1 << 31 | 0x7f << 9); p->ki3f*i*i*i) * flicker
+ (p->krf + p->kirf*i + p->ki2rf*i*i +
p->ki3rf*i*i*i) * flicker * rs[k];
(*filters[k])[j][i] = (c + id5/2) >> 39
& (0x1 << 31 | 0x7f << 9);
} }
} }
} }
...@@ -349,7 +354,8 @@ static void tv_setup_filter(struct drm_encoder *encoder) ...@@ -349,7 +354,8 @@ static void tv_setup_filter(struct drm_encoder *encoder)
/* Hardware state saving/restoring */ /* Hardware state saving/restoring */
static void tv_save_filter(struct drm_device *dev, uint32_t base, uint32_t regs[4][7]) static void tv_save_filter(struct drm_device *dev, uint32_t base,
uint32_t regs[4][7])
{ {
int i, j; int i, j;
uint32_t offsets[] = { base, base + 0x1c, base + 0x40, base + 0x5c }; uint32_t offsets[] = { base, base + 0x1c, base + 0x40, base + 0x5c };
...@@ -360,7 +366,8 @@ static void tv_save_filter(struct drm_device *dev, uint32_t base, uint32_t regs[ ...@@ -360,7 +366,8 @@ static void tv_save_filter(struct drm_device *dev, uint32_t base, uint32_t regs[
} }
} }
static void tv_load_filter(struct drm_device *dev, uint32_t base, uint32_t regs[4][7]) static void tv_load_filter(struct drm_device *dev, uint32_t base,
uint32_t regs[4][7])
{ {
int i, j; int i, j;
uint32_t offsets[] = { base, base + 0x1c, base + 0x40, base + 0x5c }; uint32_t offsets[] = { base, base + 0x1c, base + 0x40, base + 0x5c };
...@@ -504,10 +511,10 @@ void nv17_tv_update_properties(struct drm_encoder *encoder) ...@@ -504,10 +511,10 @@ void nv17_tv_update_properties(struct drm_encoder *encoder)
break; break;
} }
regs->tv_enc[0x20] = interpolate(0, tv_norm->tv_enc_mode.tv_enc[0x20], 255, regs->tv_enc[0x20] = interpolate(0, tv_norm->tv_enc_mode.tv_enc[0x20],
tv_enc->saturation); 255, tv_enc->saturation);
regs->tv_enc[0x22] = interpolate(0, tv_norm->tv_enc_mode.tv_enc[0x22], 255, regs->tv_enc[0x22] = interpolate(0, tv_norm->tv_enc_mode.tv_enc[0x22],
tv_enc->saturation); 255, tv_enc->saturation);
regs->tv_enc[0x25] = tv_enc->hue * 255 / 100; regs->tv_enc[0x25] = tv_enc->hue * 255 / 100;
nv_load_ptv(dev, regs, 204); nv_load_ptv(dev, regs, 204);
...@@ -541,7 +548,8 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder) ...@@ -541,7 +548,8 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder)
int head = nouveau_crtc(encoder->crtc)->index; int head = nouveau_crtc(encoder->crtc)->index;
struct nv04_crtc_reg *regs = &dev_priv->mode_reg.crtc_reg[head]; struct nv04_crtc_reg *regs = &dev_priv->mode_reg.crtc_reg[head];
struct drm_display_mode *crtc_mode = &encoder->crtc->mode; struct drm_display_mode *crtc_mode = &encoder->crtc->mode;
struct drm_display_mode *output_mode = &get_tv_norm(encoder)->ctv_enc_mode.mode; struct drm_display_mode *output_mode =
&get_tv_norm(encoder)->ctv_enc_mode.mode;
int overscan, hmargin, vmargin, hratio, vratio; int overscan, hmargin, vmargin, hratio, vratio;
/* The rescaler doesn't do the right thing for interlaced modes. */ /* The rescaler doesn't do the right thing for interlaced modes. */
...@@ -553,13 +561,15 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder) ...@@ -553,13 +561,15 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder)
hmargin = (output_mode->hdisplay - crtc_mode->hdisplay) / 2; hmargin = (output_mode->hdisplay - crtc_mode->hdisplay) / 2;
vmargin = (output_mode->vdisplay - crtc_mode->vdisplay) / 2; vmargin = (output_mode->vdisplay - crtc_mode->vdisplay) / 2;
hmargin = interpolate(0, min(hmargin, output_mode->hdisplay/20), hmargin, hmargin = interpolate(0, min(hmargin, output_mode->hdisplay/20),
overscan); hmargin, overscan);
vmargin = interpolate(0, min(vmargin, output_mode->vdisplay/20), vmargin, vmargin = interpolate(0, min(vmargin, output_mode->vdisplay/20),
overscan); vmargin, overscan);
hratio = crtc_mode->hdisplay * 0x800 / (output_mode->hdisplay - 2*hmargin); hratio = crtc_mode->hdisplay * 0x800 /
vratio = crtc_mode->vdisplay * 0x800 / (output_mode->vdisplay - 2*vmargin) & ~3; (output_mode->hdisplay - 2*hmargin);
vratio = crtc_mode->vdisplay * 0x800 /
(output_mode->vdisplay - 2*vmargin) & ~3;
regs->fp_horiz_regs[FP_VALID_START] = hmargin; regs->fp_horiz_regs[FP_VALID_START] = hmargin;
regs->fp_horiz_regs[FP_VALID_END] = output_mode->hdisplay - hmargin - 1; regs->fp_horiz_regs[FP_VALID_END] = output_mode->hdisplay - hmargin - 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment