1bbbe775eSNeil Armstrong /* 2bbbe775eSNeil Armstrong * Copyright (C) 2016 BayLibre, SAS 3bbbe775eSNeil Armstrong * Author: Neil Armstrong <narmstrong@baylibre.com> 4bbbe775eSNeil Armstrong * Copyright (C) 2015 Amlogic, Inc. All rights reserved. 5bbbe775eSNeil Armstrong * 6bbbe775eSNeil Armstrong * This program is free software; you can redistribute it and/or 7bbbe775eSNeil Armstrong * modify it under the terms of the GNU General Public License as 8bbbe775eSNeil Armstrong * published by the Free Software Foundation; either version 2 of the 9bbbe775eSNeil Armstrong * License, or (at your option) any later version. 10bbbe775eSNeil Armstrong * 11bbbe775eSNeil Armstrong * This program is distributed in the hope that it will be useful, but 12bbbe775eSNeil Armstrong * WITHOUT ANY WARRANTY; without even the implied warranty of 13bbbe775eSNeil Armstrong * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14bbbe775eSNeil Armstrong * General Public License for more details. 15bbbe775eSNeil Armstrong * 16bbbe775eSNeil Armstrong * You should have received a copy of the GNU General Public License 17bbbe775eSNeil Armstrong * along with this program; if not, see <http://www.gnu.org/licenses/>. 18bbbe775eSNeil Armstrong */ 19bbbe775eSNeil Armstrong 20bbbe775eSNeil Armstrong #include <linux/kernel.h> 21bbbe775eSNeil Armstrong #include <linux/module.h> 22bbbe775eSNeil Armstrong #include <drm/drmP.h> 23bbbe775eSNeil Armstrong #include "meson_drv.h" 24bbbe775eSNeil Armstrong #include "meson_venc.h" 25bbbe775eSNeil Armstrong #include "meson_vpp.h" 26bbbe775eSNeil Armstrong #include "meson_vclk.h" 27bbbe775eSNeil Armstrong #include "meson_registers.h" 28bbbe775eSNeil Armstrong 292021d5b7SNeil Armstrong /** 302021d5b7SNeil Armstrong * DOC: Video Encoder 312021d5b7SNeil Armstrong * 32bbbe775eSNeil Armstrong * VENC Handle the pixels encoding to the output formats. 33bbbe775eSNeil Armstrong * We handle the following encodings : 342021d5b7SNeil Armstrong * 35bbbe775eSNeil Armstrong * - CVBS Encoding via the ENCI encoder and VDAC digital to analog converter 36bbbe775eSNeil Armstrong * - TMDS/HDMI Encoding via ENCI_DIV and ENCP 37bbbe775eSNeil Armstrong * - Setup of more clock rates for HDMI modes 38335e3713SNeil Armstrong * 39335e3713SNeil Armstrong * What is missing : 402021d5b7SNeil Armstrong * 41bbbe775eSNeil Armstrong * - LCD Panel encoding via ENCL 42bbbe775eSNeil Armstrong * - TV Panel encoding via ENCT 43335e3713SNeil Armstrong * 44335e3713SNeil Armstrong * VENC paths : 452021d5b7SNeil Armstrong * 462021d5b7SNeil Armstrong * .. code:: 472021d5b7SNeil Armstrong * 48335e3713SNeil Armstrong * _____ _____ ____________________ 49335e3713SNeil Armstrong * vd1---| |-| | | VENC /---------|----VDAC 502021d5b7SNeil Armstrong * vd2---| VIU |-| VPP |-|-----ENCI/-ENCI_DVI-|-| 51335e3713SNeil Armstrong * osd1--| |-| | | \ | X--HDMI-TX 522021d5b7SNeil Armstrong * osd2--|_____|-|_____| | |\-ENCP--ENCP_DVI-|-| 53335e3713SNeil Armstrong * | | | 54335e3713SNeil Armstrong * | \--ENCL-----------|----LVDS 55335e3713SNeil Armstrong * |____________________| 56335e3713SNeil Armstrong * 57335e3713SNeil Armstrong * The ENCI is designed for PAl or NTSC encoding and can go through the VDAC 58335e3713SNeil Armstrong * directly for CVBS encoding or through the ENCI_DVI encoder for HDMI. 59335e3713SNeil Armstrong * The ENCP is designed for Progressive encoding but can also generate 60335e3713SNeil Armstrong * 1080i interlaced pixels, and was initialy desined to encode pixels for 61335e3713SNeil Armstrong * VDAC to output RGB ou YUV analog outputs. 62335e3713SNeil Armstrong * It's output is only used through the ENCP_DVI encoder for HDMI. 63335e3713SNeil Armstrong * The ENCL LVDS encoder is not implemented. 64335e3713SNeil Armstrong * 65335e3713SNeil Armstrong * The ENCI and ENCP encoders needs specially defined parameters for each 66335e3713SNeil Armstrong * supported mode and thus cannot be determined from standard video timings. 67335e3713SNeil Armstrong * 68335e3713SNeil Armstrong * The ENCI end ENCP DVI encoders are more generic and can generate any timings 69335e3713SNeil Armstrong * from the pixel data generated by ENCI or ENCP, so can use the standard video 70335e3713SNeil Armstrong * timings are source for HW parameters. 71bbbe775eSNeil Armstrong */ 72bbbe775eSNeil Armstrong 730c931a29SNeil Armstrong /* HHI Registers */ 740c931a29SNeil Armstrong #define HHI_VDAC_CNTL0 0x2F4 /* 0xbd offset in data sheet */ 750c931a29SNeil Armstrong #define HHI_VDAC_CNTL1 0x2F8 /* 0xbe offset in data sheet */ 760c931a29SNeil Armstrong #define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 offset in data sheet */ 770c931a29SNeil Armstrong 78bbbe775eSNeil Armstrong struct meson_cvbs_enci_mode meson_cvbs_enci_pal = { 79bbbe775eSNeil Armstrong .mode_tag = MESON_VENC_MODE_CVBS_PAL, 80bbbe775eSNeil Armstrong .hso_begin = 3, 81bbbe775eSNeil Armstrong .hso_end = 129, 82bbbe775eSNeil Armstrong .vso_even = 3, 83bbbe775eSNeil Armstrong .vso_odd = 260, 84bbbe775eSNeil Armstrong .macv_max_amp = 7, 85bbbe775eSNeil Armstrong .video_prog_mode = 0xff, 86bbbe775eSNeil Armstrong .video_mode = 0x13, 87bbbe775eSNeil Armstrong .sch_adjust = 0x28, 88bbbe775eSNeil Armstrong .yc_delay = 0x343, 89bbbe775eSNeil Armstrong .pixel_start = 251, 90bbbe775eSNeil Armstrong .pixel_end = 1691, 91bbbe775eSNeil Armstrong .top_field_line_start = 22, 92bbbe775eSNeil Armstrong .top_field_line_end = 310, 93bbbe775eSNeil Armstrong .bottom_field_line_start = 23, 94bbbe775eSNeil Armstrong .bottom_field_line_end = 311, 95bbbe775eSNeil Armstrong .video_saturation = 9, 96bbbe775eSNeil Armstrong .video_contrast = 0, 97bbbe775eSNeil Armstrong .video_brightness = 0, 98bbbe775eSNeil Armstrong .video_hue = 0, 99bbbe775eSNeil Armstrong .analog_sync_adj = 0x8080, 100bbbe775eSNeil Armstrong }; 101bbbe775eSNeil Armstrong 102bbbe775eSNeil Armstrong struct meson_cvbs_enci_mode meson_cvbs_enci_ntsc = { 103bbbe775eSNeil Armstrong .mode_tag = MESON_VENC_MODE_CVBS_NTSC, 104bbbe775eSNeil Armstrong .hso_begin = 5, 105bbbe775eSNeil Armstrong .hso_end = 129, 106bbbe775eSNeil Armstrong .vso_even = 3, 107bbbe775eSNeil Armstrong .vso_odd = 260, 108bbbe775eSNeil Armstrong .macv_max_amp = 0xb, 109bbbe775eSNeil Armstrong .video_prog_mode = 0xf0, 110bbbe775eSNeil Armstrong .video_mode = 0x8, 111bbbe775eSNeil Armstrong .sch_adjust = 0x20, 112bbbe775eSNeil Armstrong .yc_delay = 0x333, 113bbbe775eSNeil Armstrong .pixel_start = 227, 114bbbe775eSNeil Armstrong .pixel_end = 1667, 115bbbe775eSNeil Armstrong .top_field_line_start = 18, 116bbbe775eSNeil Armstrong .top_field_line_end = 258, 117bbbe775eSNeil Armstrong .bottom_field_line_start = 19, 118bbbe775eSNeil Armstrong .bottom_field_line_end = 259, 119bbbe775eSNeil Armstrong .video_saturation = 18, 120bbbe775eSNeil Armstrong .video_contrast = 3, 121bbbe775eSNeil Armstrong .video_brightness = 0, 122bbbe775eSNeil Armstrong .video_hue = 0, 123bbbe775eSNeil Armstrong .analog_sync_adj = 0x9c00, 124bbbe775eSNeil Armstrong }; 125bbbe775eSNeil Armstrong 126335e3713SNeil Armstrong union meson_hdmi_venc_mode { 127335e3713SNeil Armstrong struct { 128335e3713SNeil Armstrong unsigned int mode_tag; 129335e3713SNeil Armstrong unsigned int hso_begin; 130335e3713SNeil Armstrong unsigned int hso_end; 131335e3713SNeil Armstrong unsigned int vso_even; 132335e3713SNeil Armstrong unsigned int vso_odd; 133335e3713SNeil Armstrong unsigned int macv_max_amp; 134335e3713SNeil Armstrong unsigned int video_prog_mode; 135335e3713SNeil Armstrong unsigned int video_mode; 136335e3713SNeil Armstrong unsigned int sch_adjust; 137335e3713SNeil Armstrong unsigned int yc_delay; 138335e3713SNeil Armstrong unsigned int pixel_start; 139335e3713SNeil Armstrong unsigned int pixel_end; 140335e3713SNeil Armstrong unsigned int top_field_line_start; 141335e3713SNeil Armstrong unsigned int top_field_line_end; 142335e3713SNeil Armstrong unsigned int bottom_field_line_start; 143335e3713SNeil Armstrong unsigned int bottom_field_line_end; 144335e3713SNeil Armstrong } enci; 145335e3713SNeil Armstrong struct { 146335e3713SNeil Armstrong unsigned int dvi_settings; 147335e3713SNeil Armstrong unsigned int video_mode; 148335e3713SNeil Armstrong unsigned int video_mode_adv; 149335e3713SNeil Armstrong unsigned int video_prog_mode; 150335e3713SNeil Armstrong bool video_prog_mode_present; 151335e3713SNeil Armstrong unsigned int video_sync_mode; 152335e3713SNeil Armstrong bool video_sync_mode_present; 153335e3713SNeil Armstrong unsigned int video_yc_dly; 154335e3713SNeil Armstrong bool video_yc_dly_present; 155335e3713SNeil Armstrong unsigned int video_rgb_ctrl; 156335e3713SNeil Armstrong bool video_rgb_ctrl_present; 157335e3713SNeil Armstrong unsigned int video_filt_ctrl; 158335e3713SNeil Armstrong bool video_filt_ctrl_present; 159335e3713SNeil Armstrong unsigned int video_ofld_voav_ofst; 160335e3713SNeil Armstrong bool video_ofld_voav_ofst_present; 161335e3713SNeil Armstrong unsigned int yfp1_htime; 162335e3713SNeil Armstrong unsigned int yfp2_htime; 163335e3713SNeil Armstrong unsigned int max_pxcnt; 164335e3713SNeil Armstrong unsigned int hspuls_begin; 165335e3713SNeil Armstrong unsigned int hspuls_end; 166335e3713SNeil Armstrong unsigned int hspuls_switch; 167335e3713SNeil Armstrong unsigned int vspuls_begin; 168335e3713SNeil Armstrong unsigned int vspuls_end; 169335e3713SNeil Armstrong unsigned int vspuls_bline; 170335e3713SNeil Armstrong unsigned int vspuls_eline; 171335e3713SNeil Armstrong unsigned int eqpuls_begin; 172335e3713SNeil Armstrong bool eqpuls_begin_present; 173335e3713SNeil Armstrong unsigned int eqpuls_end; 174335e3713SNeil Armstrong bool eqpuls_end_present; 175335e3713SNeil Armstrong unsigned int eqpuls_bline; 176335e3713SNeil Armstrong bool eqpuls_bline_present; 177335e3713SNeil Armstrong unsigned int eqpuls_eline; 178335e3713SNeil Armstrong bool eqpuls_eline_present; 179335e3713SNeil Armstrong unsigned int havon_begin; 180335e3713SNeil Armstrong unsigned int havon_end; 181335e3713SNeil Armstrong unsigned int vavon_bline; 182335e3713SNeil Armstrong unsigned int vavon_eline; 183335e3713SNeil Armstrong unsigned int hso_begin; 184335e3713SNeil Armstrong unsigned int hso_end; 185335e3713SNeil Armstrong unsigned int vso_begin; 186335e3713SNeil Armstrong unsigned int vso_end; 187335e3713SNeil Armstrong unsigned int vso_bline; 188335e3713SNeil Armstrong unsigned int vso_eline; 189335e3713SNeil Armstrong bool vso_eline_present; 190335e3713SNeil Armstrong unsigned int sy_val; 191335e3713SNeil Armstrong bool sy_val_present; 192335e3713SNeil Armstrong unsigned int sy2_val; 193335e3713SNeil Armstrong bool sy2_val_present; 194335e3713SNeil Armstrong unsigned int max_lncnt; 195335e3713SNeil Armstrong } encp; 196335e3713SNeil Armstrong }; 197335e3713SNeil Armstrong 198335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_enci_mode_480i = { 199335e3713SNeil Armstrong .enci = { 200335e3713SNeil Armstrong .hso_begin = 5, 201335e3713SNeil Armstrong .hso_end = 129, 202335e3713SNeil Armstrong .vso_even = 3, 203335e3713SNeil Armstrong .vso_odd = 260, 204335e3713SNeil Armstrong .macv_max_amp = 0x810b, 205335e3713SNeil Armstrong .video_prog_mode = 0xf0, 206335e3713SNeil Armstrong .video_mode = 0x8, 207335e3713SNeil Armstrong .sch_adjust = 0x20, 208335e3713SNeil Armstrong .yc_delay = 0, 209335e3713SNeil Armstrong .pixel_start = 227, 210335e3713SNeil Armstrong .pixel_end = 1667, 211335e3713SNeil Armstrong .top_field_line_start = 18, 212335e3713SNeil Armstrong .top_field_line_end = 258, 213335e3713SNeil Armstrong .bottom_field_line_start = 19, 214335e3713SNeil Armstrong .bottom_field_line_end = 259, 215335e3713SNeil Armstrong }, 216335e3713SNeil Armstrong }; 217335e3713SNeil Armstrong 218335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_enci_mode_576i = { 219335e3713SNeil Armstrong .enci = { 220335e3713SNeil Armstrong .hso_begin = 3, 221335e3713SNeil Armstrong .hso_end = 129, 222335e3713SNeil Armstrong .vso_even = 3, 223335e3713SNeil Armstrong .vso_odd = 260, 224335e3713SNeil Armstrong .macv_max_amp = 8107, 225335e3713SNeil Armstrong .video_prog_mode = 0xff, 226335e3713SNeil Armstrong .video_mode = 0x13, 227335e3713SNeil Armstrong .sch_adjust = 0x28, 228335e3713SNeil Armstrong .yc_delay = 0x333, 229335e3713SNeil Armstrong .pixel_start = 251, 230335e3713SNeil Armstrong .pixel_end = 1691, 231335e3713SNeil Armstrong .top_field_line_start = 22, 232335e3713SNeil Armstrong .top_field_line_end = 310, 233335e3713SNeil Armstrong .bottom_field_line_start = 23, 234335e3713SNeil Armstrong .bottom_field_line_end = 311, 235335e3713SNeil Armstrong }, 236335e3713SNeil Armstrong }; 237335e3713SNeil Armstrong 238335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_480p = { 239335e3713SNeil Armstrong .encp = { 240335e3713SNeil Armstrong .dvi_settings = 0x21, 241335e3713SNeil Armstrong .video_mode = 0x4000, 242335e3713SNeil Armstrong .video_mode_adv = 0x9, 243335e3713SNeil Armstrong .video_prog_mode = 0, 244335e3713SNeil Armstrong .video_prog_mode_present = true, 245335e3713SNeil Armstrong .video_sync_mode = 7, 246335e3713SNeil Armstrong .video_sync_mode_present = true, 247335e3713SNeil Armstrong /* video_yc_dly */ 248335e3713SNeil Armstrong /* video_rgb_ctrl */ 249335e3713SNeil Armstrong .video_filt_ctrl = 0x2052, 250335e3713SNeil Armstrong .video_filt_ctrl_present = true, 251335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 252335e3713SNeil Armstrong .yfp1_htime = 244, 253335e3713SNeil Armstrong .yfp2_htime = 1630, 254335e3713SNeil Armstrong .max_pxcnt = 1715, 255335e3713SNeil Armstrong .hspuls_begin = 0x22, 256335e3713SNeil Armstrong .hspuls_end = 0xa0, 257335e3713SNeil Armstrong .hspuls_switch = 88, 258335e3713SNeil Armstrong .vspuls_begin = 0, 259335e3713SNeil Armstrong .vspuls_end = 1589, 260335e3713SNeil Armstrong .vspuls_bline = 0, 261335e3713SNeil Armstrong .vspuls_eline = 5, 262335e3713SNeil Armstrong .havon_begin = 249, 263335e3713SNeil Armstrong .havon_end = 1689, 264335e3713SNeil Armstrong .vavon_bline = 42, 265335e3713SNeil Armstrong .vavon_eline = 521, 266335e3713SNeil Armstrong /* eqpuls_begin */ 267335e3713SNeil Armstrong /* eqpuls_end */ 268335e3713SNeil Armstrong /* eqpuls_bline */ 269335e3713SNeil Armstrong /* eqpuls_eline */ 270335e3713SNeil Armstrong .hso_begin = 3, 271335e3713SNeil Armstrong .hso_end = 5, 272335e3713SNeil Armstrong .vso_begin = 3, 273335e3713SNeil Armstrong .vso_end = 5, 274335e3713SNeil Armstrong .vso_bline = 0, 275335e3713SNeil Armstrong /* vso_eline */ 276335e3713SNeil Armstrong .sy_val = 8, 277335e3713SNeil Armstrong .sy_val_present = true, 278335e3713SNeil Armstrong .sy2_val = 0x1d8, 279335e3713SNeil Armstrong .sy2_val_present = true, 280335e3713SNeil Armstrong .max_lncnt = 524, 281335e3713SNeil Armstrong }, 282335e3713SNeil Armstrong }; 283335e3713SNeil Armstrong 284335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_576p = { 285335e3713SNeil Armstrong .encp = { 286335e3713SNeil Armstrong .dvi_settings = 0x21, 287335e3713SNeil Armstrong .video_mode = 0x4000, 288335e3713SNeil Armstrong .video_mode_adv = 0x9, 289335e3713SNeil Armstrong .video_prog_mode = 0, 290335e3713SNeil Armstrong .video_prog_mode_present = true, 291335e3713SNeil Armstrong .video_sync_mode = 7, 292335e3713SNeil Armstrong .video_sync_mode_present = true, 293335e3713SNeil Armstrong /* video_yc_dly */ 294335e3713SNeil Armstrong /* video_rgb_ctrl */ 295335e3713SNeil Armstrong .video_filt_ctrl = 0x52, 296335e3713SNeil Armstrong .video_filt_ctrl_present = true, 297335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 298335e3713SNeil Armstrong .yfp1_htime = 235, 299335e3713SNeil Armstrong .yfp2_htime = 1674, 300335e3713SNeil Armstrong .max_pxcnt = 1727, 301335e3713SNeil Armstrong .hspuls_begin = 0, 302335e3713SNeil Armstrong .hspuls_end = 0x80, 303335e3713SNeil Armstrong .hspuls_switch = 88, 304335e3713SNeil Armstrong .vspuls_begin = 0, 305335e3713SNeil Armstrong .vspuls_end = 1599, 306335e3713SNeil Armstrong .vspuls_bline = 0, 307335e3713SNeil Armstrong .vspuls_eline = 4, 308335e3713SNeil Armstrong .havon_begin = 235, 309335e3713SNeil Armstrong .havon_end = 1674, 310335e3713SNeil Armstrong .vavon_bline = 44, 311335e3713SNeil Armstrong .vavon_eline = 619, 312335e3713SNeil Armstrong /* eqpuls_begin */ 313335e3713SNeil Armstrong /* eqpuls_end */ 314335e3713SNeil Armstrong /* eqpuls_bline */ 315335e3713SNeil Armstrong /* eqpuls_eline */ 316335e3713SNeil Armstrong .hso_begin = 0x80, 317335e3713SNeil Armstrong .hso_end = 0, 318335e3713SNeil Armstrong .vso_begin = 0, 319335e3713SNeil Armstrong .vso_end = 5, 320335e3713SNeil Armstrong .vso_bline = 0, 321335e3713SNeil Armstrong /* vso_eline */ 322335e3713SNeil Armstrong .sy_val = 8, 323335e3713SNeil Armstrong .sy_val_present = true, 324335e3713SNeil Armstrong .sy2_val = 0x1d8, 325335e3713SNeil Armstrong .sy2_val_present = true, 326335e3713SNeil Armstrong .max_lncnt = 624, 327335e3713SNeil Armstrong }, 328335e3713SNeil Armstrong }; 329335e3713SNeil Armstrong 330335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_720p60 = { 331335e3713SNeil Armstrong .encp = { 332335e3713SNeil Armstrong .dvi_settings = 0x2029, 333335e3713SNeil Armstrong .video_mode = 0x4040, 334335e3713SNeil Armstrong .video_mode_adv = 0x19, 335335e3713SNeil Armstrong /* video_prog_mode */ 336335e3713SNeil Armstrong /* video_sync_mode */ 337335e3713SNeil Armstrong /* video_yc_dly */ 338335e3713SNeil Armstrong /* video_rgb_ctrl */ 339335e3713SNeil Armstrong /* video_filt_ctrl */ 340335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 341335e3713SNeil Armstrong .yfp1_htime = 648, 342335e3713SNeil Armstrong .yfp2_htime = 3207, 343335e3713SNeil Armstrong .max_pxcnt = 3299, 344335e3713SNeil Armstrong .hspuls_begin = 80, 345335e3713SNeil Armstrong .hspuls_end = 240, 346335e3713SNeil Armstrong .hspuls_switch = 80, 347335e3713SNeil Armstrong .vspuls_begin = 688, 348335e3713SNeil Armstrong .vspuls_end = 3248, 349335e3713SNeil Armstrong .vspuls_bline = 4, 350335e3713SNeil Armstrong .vspuls_eline = 8, 351335e3713SNeil Armstrong .havon_begin = 648, 352335e3713SNeil Armstrong .havon_end = 3207, 353335e3713SNeil Armstrong .vavon_bline = 29, 354335e3713SNeil Armstrong .vavon_eline = 748, 355335e3713SNeil Armstrong /* eqpuls_begin */ 356335e3713SNeil Armstrong /* eqpuls_end */ 357335e3713SNeil Armstrong /* eqpuls_bline */ 358335e3713SNeil Armstrong /* eqpuls_eline */ 359335e3713SNeil Armstrong .hso_begin = 256, 360335e3713SNeil Armstrong .hso_end = 168, 361335e3713SNeil Armstrong .vso_begin = 168, 362335e3713SNeil Armstrong .vso_end = 256, 363335e3713SNeil Armstrong .vso_bline = 0, 364335e3713SNeil Armstrong .vso_eline = 5, 365335e3713SNeil Armstrong .vso_eline_present = true, 366335e3713SNeil Armstrong /* sy_val */ 367335e3713SNeil Armstrong /* sy2_val */ 368335e3713SNeil Armstrong .max_lncnt = 749, 369335e3713SNeil Armstrong }, 370335e3713SNeil Armstrong }; 371335e3713SNeil Armstrong 372335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_720p50 = { 373335e3713SNeil Armstrong .encp = { 374335e3713SNeil Armstrong .dvi_settings = 0x202d, 375335e3713SNeil Armstrong .video_mode = 0x4040, 376335e3713SNeil Armstrong .video_mode_adv = 0x19, 377335e3713SNeil Armstrong .video_prog_mode = 0x100, 378335e3713SNeil Armstrong .video_prog_mode_present = true, 379335e3713SNeil Armstrong .video_sync_mode = 0x407, 380335e3713SNeil Armstrong .video_sync_mode_present = true, 381335e3713SNeil Armstrong .video_yc_dly = 0, 382335e3713SNeil Armstrong .video_yc_dly_present = true, 383335e3713SNeil Armstrong /* video_rgb_ctrl */ 384335e3713SNeil Armstrong /* video_filt_ctrl */ 385335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 386335e3713SNeil Armstrong .yfp1_htime = 648, 387335e3713SNeil Armstrong .yfp2_htime = 3207, 388335e3713SNeil Armstrong .max_pxcnt = 3959, 389335e3713SNeil Armstrong .hspuls_begin = 80, 390335e3713SNeil Armstrong .hspuls_end = 240, 391335e3713SNeil Armstrong .hspuls_switch = 80, 392335e3713SNeil Armstrong .vspuls_begin = 688, 393335e3713SNeil Armstrong .vspuls_end = 3248, 394335e3713SNeil Armstrong .vspuls_bline = 4, 395335e3713SNeil Armstrong .vspuls_eline = 8, 396335e3713SNeil Armstrong .havon_begin = 648, 397335e3713SNeil Armstrong .havon_end = 3207, 398335e3713SNeil Armstrong .vavon_bline = 29, 399335e3713SNeil Armstrong .vavon_eline = 748, 400335e3713SNeil Armstrong /* eqpuls_begin */ 401335e3713SNeil Armstrong /* eqpuls_end */ 402335e3713SNeil Armstrong /* eqpuls_bline */ 403335e3713SNeil Armstrong /* eqpuls_eline */ 404335e3713SNeil Armstrong .hso_begin = 128, 405335e3713SNeil Armstrong .hso_end = 208, 406335e3713SNeil Armstrong .vso_begin = 128, 407335e3713SNeil Armstrong .vso_end = 128, 408335e3713SNeil Armstrong .vso_bline = 0, 409335e3713SNeil Armstrong .vso_eline = 5, 410335e3713SNeil Armstrong .vso_eline_present = true, 411335e3713SNeil Armstrong /* sy_val */ 412335e3713SNeil Armstrong /* sy2_val */ 413335e3713SNeil Armstrong .max_lncnt = 749, 414335e3713SNeil Armstrong }, 415335e3713SNeil Armstrong }; 416335e3713SNeil Armstrong 417335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080i60 = { 418335e3713SNeil Armstrong .encp = { 419335e3713SNeil Armstrong .dvi_settings = 0x2029, 420335e3713SNeil Armstrong .video_mode = 0x5ffc, 421335e3713SNeil Armstrong .video_mode_adv = 0x19, 422335e3713SNeil Armstrong .video_prog_mode = 0x100, 423335e3713SNeil Armstrong .video_prog_mode_present = true, 424335e3713SNeil Armstrong .video_sync_mode = 0x207, 425335e3713SNeil Armstrong .video_sync_mode_present = true, 426335e3713SNeil Armstrong /* video_yc_dly */ 427335e3713SNeil Armstrong /* video_rgb_ctrl */ 428335e3713SNeil Armstrong /* video_filt_ctrl */ 429335e3713SNeil Armstrong .video_ofld_voav_ofst = 0x11, 430335e3713SNeil Armstrong .video_ofld_voav_ofst_present = true, 431335e3713SNeil Armstrong .yfp1_htime = 516, 432335e3713SNeil Armstrong .yfp2_htime = 4355, 433335e3713SNeil Armstrong .max_pxcnt = 4399, 434335e3713SNeil Armstrong .hspuls_begin = 88, 435335e3713SNeil Armstrong .hspuls_end = 264, 436335e3713SNeil Armstrong .hspuls_switch = 88, 437335e3713SNeil Armstrong .vspuls_begin = 440, 438335e3713SNeil Armstrong .vspuls_end = 2200, 439335e3713SNeil Armstrong .vspuls_bline = 0, 440335e3713SNeil Armstrong .vspuls_eline = 4, 441335e3713SNeil Armstrong .havon_begin = 516, 442335e3713SNeil Armstrong .havon_end = 4355, 443335e3713SNeil Armstrong .vavon_bline = 20, 444335e3713SNeil Armstrong .vavon_eline = 559, 445335e3713SNeil Armstrong .eqpuls_begin = 2288, 446335e3713SNeil Armstrong .eqpuls_begin_present = true, 447335e3713SNeil Armstrong .eqpuls_end = 2464, 448335e3713SNeil Armstrong .eqpuls_end_present = true, 449335e3713SNeil Armstrong .eqpuls_bline = 0, 450335e3713SNeil Armstrong .eqpuls_bline_present = true, 451335e3713SNeil Armstrong .eqpuls_eline = 4, 452335e3713SNeil Armstrong .eqpuls_eline_present = true, 453335e3713SNeil Armstrong .hso_begin = 264, 454335e3713SNeil Armstrong .hso_end = 176, 455335e3713SNeil Armstrong .vso_begin = 88, 456335e3713SNeil Armstrong .vso_end = 88, 457335e3713SNeil Armstrong .vso_bline = 0, 458335e3713SNeil Armstrong .vso_eline = 5, 459335e3713SNeil Armstrong .vso_eline_present = true, 460335e3713SNeil Armstrong /* sy_val */ 461335e3713SNeil Armstrong /* sy2_val */ 462335e3713SNeil Armstrong .max_lncnt = 1124, 463335e3713SNeil Armstrong }, 464335e3713SNeil Armstrong }; 465335e3713SNeil Armstrong 466335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080i50 = { 467335e3713SNeil Armstrong .encp = { 468335e3713SNeil Armstrong .dvi_settings = 0x202d, 469335e3713SNeil Armstrong .video_mode = 0x5ffc, 470335e3713SNeil Armstrong .video_mode_adv = 0x19, 471335e3713SNeil Armstrong .video_prog_mode = 0x100, 472335e3713SNeil Armstrong .video_prog_mode_present = true, 473335e3713SNeil Armstrong .video_sync_mode = 0x7, 474335e3713SNeil Armstrong .video_sync_mode_present = true, 475335e3713SNeil Armstrong /* video_yc_dly */ 476335e3713SNeil Armstrong /* video_rgb_ctrl */ 477335e3713SNeil Armstrong /* video_filt_ctrl */ 478335e3713SNeil Armstrong .video_ofld_voav_ofst = 0x11, 479335e3713SNeil Armstrong .video_ofld_voav_ofst_present = true, 480335e3713SNeil Armstrong .yfp1_htime = 526, 481335e3713SNeil Armstrong .yfp2_htime = 4365, 482335e3713SNeil Armstrong .max_pxcnt = 5279, 483335e3713SNeil Armstrong .hspuls_begin = 88, 484335e3713SNeil Armstrong .hspuls_end = 264, 485335e3713SNeil Armstrong .hspuls_switch = 88, 486335e3713SNeil Armstrong .vspuls_begin = 440, 487335e3713SNeil Armstrong .vspuls_end = 2200, 488335e3713SNeil Armstrong .vspuls_bline = 0, 489335e3713SNeil Armstrong .vspuls_eline = 4, 490335e3713SNeil Armstrong .havon_begin = 526, 491335e3713SNeil Armstrong .havon_end = 4365, 492335e3713SNeil Armstrong .vavon_bline = 20, 493335e3713SNeil Armstrong .vavon_eline = 559, 494335e3713SNeil Armstrong .eqpuls_begin = 2288, 495335e3713SNeil Armstrong .eqpuls_begin_present = true, 496335e3713SNeil Armstrong .eqpuls_end = 2464, 497335e3713SNeil Armstrong .eqpuls_end_present = true, 498335e3713SNeil Armstrong .eqpuls_bline = 0, 499335e3713SNeil Armstrong .eqpuls_bline_present = true, 500335e3713SNeil Armstrong .eqpuls_eline = 4, 501335e3713SNeil Armstrong .eqpuls_eline_present = true, 502335e3713SNeil Armstrong .hso_begin = 142, 503335e3713SNeil Armstrong .hso_end = 230, 504335e3713SNeil Armstrong .vso_begin = 142, 505335e3713SNeil Armstrong .vso_end = 142, 506335e3713SNeil Armstrong .vso_bline = 0, 507335e3713SNeil Armstrong .vso_eline = 5, 508335e3713SNeil Armstrong .vso_eline_present = true, 509335e3713SNeil Armstrong /* sy_val */ 510335e3713SNeil Armstrong /* sy2_val */ 511335e3713SNeil Armstrong .max_lncnt = 1124, 512335e3713SNeil Armstrong }, 513335e3713SNeil Armstrong }; 514335e3713SNeil Armstrong 515335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p24 = { 516335e3713SNeil Armstrong .encp = { 517335e3713SNeil Armstrong .dvi_settings = 0xd, 518335e3713SNeil Armstrong .video_mode = 0x4040, 519335e3713SNeil Armstrong .video_mode_adv = 0x18, 520335e3713SNeil Armstrong .video_prog_mode = 0x100, 521335e3713SNeil Armstrong .video_prog_mode_present = true, 522335e3713SNeil Armstrong .video_sync_mode = 0x7, 523335e3713SNeil Armstrong .video_sync_mode_present = true, 524335e3713SNeil Armstrong .video_yc_dly = 0, 525335e3713SNeil Armstrong .video_yc_dly_present = true, 526335e3713SNeil Armstrong .video_rgb_ctrl = 2, 527335e3713SNeil Armstrong .video_rgb_ctrl_present = true, 528335e3713SNeil Armstrong .video_filt_ctrl = 0x1052, 529335e3713SNeil Armstrong .video_filt_ctrl_present = true, 530335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 531335e3713SNeil Armstrong .yfp1_htime = 271, 532335e3713SNeil Armstrong .yfp2_htime = 2190, 533335e3713SNeil Armstrong .max_pxcnt = 2749, 534335e3713SNeil Armstrong .hspuls_begin = 44, 535335e3713SNeil Armstrong .hspuls_end = 132, 536335e3713SNeil Armstrong .hspuls_switch = 44, 537335e3713SNeil Armstrong .vspuls_begin = 220, 538335e3713SNeil Armstrong .vspuls_end = 2140, 539335e3713SNeil Armstrong .vspuls_bline = 0, 540335e3713SNeil Armstrong .vspuls_eline = 4, 541335e3713SNeil Armstrong .havon_begin = 271, 542335e3713SNeil Armstrong .havon_end = 2190, 543335e3713SNeil Armstrong .vavon_bline = 41, 544335e3713SNeil Armstrong .vavon_eline = 1120, 545335e3713SNeil Armstrong /* eqpuls_begin */ 546335e3713SNeil Armstrong /* eqpuls_end */ 547335e3713SNeil Armstrong .eqpuls_bline = 0, 548335e3713SNeil Armstrong .eqpuls_bline_present = true, 549335e3713SNeil Armstrong .eqpuls_eline = 4, 550335e3713SNeil Armstrong .eqpuls_eline_present = true, 551335e3713SNeil Armstrong .hso_begin = 79, 552335e3713SNeil Armstrong .hso_end = 123, 553335e3713SNeil Armstrong .vso_begin = 79, 554335e3713SNeil Armstrong .vso_end = 79, 555335e3713SNeil Armstrong .vso_bline = 0, 556335e3713SNeil Armstrong .vso_eline = 5, 557335e3713SNeil Armstrong .vso_eline_present = true, 558335e3713SNeil Armstrong /* sy_val */ 559335e3713SNeil Armstrong /* sy2_val */ 560335e3713SNeil Armstrong .max_lncnt = 1124, 561335e3713SNeil Armstrong }, 562335e3713SNeil Armstrong }; 563335e3713SNeil Armstrong 564335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p30 = { 565335e3713SNeil Armstrong .encp = { 566335e3713SNeil Armstrong .dvi_settings = 0x1, 567335e3713SNeil Armstrong .video_mode = 0x4040, 568335e3713SNeil Armstrong .video_mode_adv = 0x18, 569335e3713SNeil Armstrong .video_prog_mode = 0x100, 570335e3713SNeil Armstrong .video_prog_mode_present = true, 571335e3713SNeil Armstrong /* video_sync_mode */ 572335e3713SNeil Armstrong /* video_yc_dly */ 573335e3713SNeil Armstrong /* video_rgb_ctrl */ 574335e3713SNeil Armstrong .video_filt_ctrl = 0x1052, 575335e3713SNeil Armstrong .video_filt_ctrl_present = true, 576335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 577335e3713SNeil Armstrong .yfp1_htime = 140, 578335e3713SNeil Armstrong .yfp2_htime = 2060, 579335e3713SNeil Armstrong .max_pxcnt = 2199, 580335e3713SNeil Armstrong .hspuls_begin = 2156, 581335e3713SNeil Armstrong .hspuls_end = 44, 582335e3713SNeil Armstrong .hspuls_switch = 44, 583335e3713SNeil Armstrong .vspuls_begin = 140, 584335e3713SNeil Armstrong .vspuls_end = 2059, 585335e3713SNeil Armstrong .vspuls_bline = 0, 586335e3713SNeil Armstrong .vspuls_eline = 4, 587335e3713SNeil Armstrong .havon_begin = 148, 588335e3713SNeil Armstrong .havon_end = 2067, 589335e3713SNeil Armstrong .vavon_bline = 41, 590335e3713SNeil Armstrong .vavon_eline = 1120, 591335e3713SNeil Armstrong /* eqpuls_begin */ 592335e3713SNeil Armstrong /* eqpuls_end */ 593335e3713SNeil Armstrong /* eqpuls_bline */ 594335e3713SNeil Armstrong /* eqpuls_eline */ 595335e3713SNeil Armstrong .hso_begin = 44, 596335e3713SNeil Armstrong .hso_end = 2156, 597335e3713SNeil Armstrong .vso_begin = 2100, 598335e3713SNeil Armstrong .vso_end = 2164, 599335e3713SNeil Armstrong .vso_bline = 0, 600335e3713SNeil Armstrong .vso_eline = 5, 601335e3713SNeil Armstrong .vso_eline_present = true, 602335e3713SNeil Armstrong /* sy_val */ 603335e3713SNeil Armstrong /* sy2_val */ 604335e3713SNeil Armstrong .max_lncnt = 1124, 605335e3713SNeil Armstrong }, 606335e3713SNeil Armstrong }; 607335e3713SNeil Armstrong 608335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p50 = { 609335e3713SNeil Armstrong .encp = { 610335e3713SNeil Armstrong .dvi_settings = 0xd, 611335e3713SNeil Armstrong .video_mode = 0x4040, 612335e3713SNeil Armstrong .video_mode_adv = 0x18, 613335e3713SNeil Armstrong .video_prog_mode = 0x100, 614335e3713SNeil Armstrong .video_prog_mode_present = true, 615335e3713SNeil Armstrong .video_sync_mode = 0x7, 616335e3713SNeil Armstrong .video_sync_mode_present = true, 617335e3713SNeil Armstrong .video_yc_dly = 0, 618335e3713SNeil Armstrong .video_yc_dly_present = true, 619335e3713SNeil Armstrong .video_rgb_ctrl = 2, 620335e3713SNeil Armstrong .video_rgb_ctrl_present = true, 621335e3713SNeil Armstrong /* video_filt_ctrl */ 622335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 623335e3713SNeil Armstrong .yfp1_htime = 271, 624335e3713SNeil Armstrong .yfp2_htime = 2190, 625335e3713SNeil Armstrong .max_pxcnt = 2639, 626335e3713SNeil Armstrong .hspuls_begin = 44, 627335e3713SNeil Armstrong .hspuls_end = 132, 628335e3713SNeil Armstrong .hspuls_switch = 44, 629335e3713SNeil Armstrong .vspuls_begin = 220, 630335e3713SNeil Armstrong .vspuls_end = 2140, 631335e3713SNeil Armstrong .vspuls_bline = 0, 632335e3713SNeil Armstrong .vspuls_eline = 4, 633335e3713SNeil Armstrong .havon_begin = 271, 634335e3713SNeil Armstrong .havon_end = 2190, 635335e3713SNeil Armstrong .vavon_bline = 41, 636335e3713SNeil Armstrong .vavon_eline = 1120, 637335e3713SNeil Armstrong /* eqpuls_begin */ 638335e3713SNeil Armstrong /* eqpuls_end */ 639335e3713SNeil Armstrong .eqpuls_bline = 0, 640335e3713SNeil Armstrong .eqpuls_bline_present = true, 641335e3713SNeil Armstrong .eqpuls_eline = 4, 642335e3713SNeil Armstrong .eqpuls_eline_present = true, 643335e3713SNeil Armstrong .hso_begin = 79, 644335e3713SNeil Armstrong .hso_end = 123, 645335e3713SNeil Armstrong .vso_begin = 79, 646335e3713SNeil Armstrong .vso_end = 79, 647335e3713SNeil Armstrong .vso_bline = 0, 648335e3713SNeil Armstrong .vso_eline = 5, 649335e3713SNeil Armstrong .vso_eline_present = true, 650335e3713SNeil Armstrong /* sy_val */ 651335e3713SNeil Armstrong /* sy2_val */ 652335e3713SNeil Armstrong .max_lncnt = 1124, 653335e3713SNeil Armstrong }, 654335e3713SNeil Armstrong }; 655335e3713SNeil Armstrong 656335e3713SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p60 = { 657335e3713SNeil Armstrong .encp = { 658335e3713SNeil Armstrong .dvi_settings = 0x1, 659335e3713SNeil Armstrong .video_mode = 0x4040, 660335e3713SNeil Armstrong .video_mode_adv = 0x18, 661335e3713SNeil Armstrong .video_prog_mode = 0x100, 662335e3713SNeil Armstrong .video_prog_mode_present = true, 663335e3713SNeil Armstrong /* video_sync_mode */ 664335e3713SNeil Armstrong /* video_yc_dly */ 665335e3713SNeil Armstrong /* video_rgb_ctrl */ 666335e3713SNeil Armstrong .video_filt_ctrl = 0x1052, 667335e3713SNeil Armstrong .video_filt_ctrl_present = true, 668335e3713SNeil Armstrong /* video_ofld_voav_ofst */ 669335e3713SNeil Armstrong .yfp1_htime = 140, 670335e3713SNeil Armstrong .yfp2_htime = 2060, 671335e3713SNeil Armstrong .max_pxcnt = 2199, 672335e3713SNeil Armstrong .hspuls_begin = 2156, 673335e3713SNeil Armstrong .hspuls_end = 44, 674335e3713SNeil Armstrong .hspuls_switch = 44, 675335e3713SNeil Armstrong .vspuls_begin = 140, 676335e3713SNeil Armstrong .vspuls_end = 2059, 677335e3713SNeil Armstrong .vspuls_bline = 0, 678335e3713SNeil Armstrong .vspuls_eline = 4, 679335e3713SNeil Armstrong .havon_begin = 148, 680335e3713SNeil Armstrong .havon_end = 2067, 681335e3713SNeil Armstrong .vavon_bline = 41, 682335e3713SNeil Armstrong .vavon_eline = 1120, 683335e3713SNeil Armstrong /* eqpuls_begin */ 684335e3713SNeil Armstrong /* eqpuls_end */ 685335e3713SNeil Armstrong /* eqpuls_bline */ 686335e3713SNeil Armstrong /* eqpuls_eline */ 687335e3713SNeil Armstrong .hso_begin = 44, 688335e3713SNeil Armstrong .hso_end = 2156, 689335e3713SNeil Armstrong .vso_begin = 2100, 690335e3713SNeil Armstrong .vso_end = 2164, 691335e3713SNeil Armstrong .vso_bline = 0, 692335e3713SNeil Armstrong .vso_eline = 5, 693335e3713SNeil Armstrong .vso_eline_present = true, 694335e3713SNeil Armstrong /* sy_val */ 695335e3713SNeil Armstrong /* sy2_val */ 696335e3713SNeil Armstrong .max_lncnt = 1124, 697335e3713SNeil Armstrong }, 698335e3713SNeil Armstrong }; 699335e3713SNeil Armstrong 7009c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_640x480_60 = { 7019c936b12SNeil Armstrong .encp = { 7029c936b12SNeil Armstrong .dvi_settings = 0x21, 7039c936b12SNeil Armstrong .video_mode = 0x4040, 7049c936b12SNeil Armstrong .video_mode_adv = 0x18, 7059c936b12SNeil Armstrong /* video_prog_mode */ 7069c936b12SNeil Armstrong /* video_sync_mode */ 7079c936b12SNeil Armstrong /* video_yc_dly */ 7089c936b12SNeil Armstrong /* video_rgb_ctrl */ 7099c936b12SNeil Armstrong /* video_filt_ctrl */ 7109c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 7119c936b12SNeil Armstrong /* yfp1_htime */ 7129c936b12SNeil Armstrong /* yfp2_htime */ 7139c936b12SNeil Armstrong .max_pxcnt = 0x31f, 7149c936b12SNeil Armstrong /* hspuls_begin */ 7159c936b12SNeil Armstrong /* hspuls_end */ 7169c936b12SNeil Armstrong /* hspuls_switch */ 7179c936b12SNeil Armstrong /* vspuls_begin */ 7189c936b12SNeil Armstrong /* vspuls_end */ 7199c936b12SNeil Armstrong /* vspuls_bline */ 7209c936b12SNeil Armstrong /* vspuls_eline */ 7219c936b12SNeil Armstrong .havon_begin = 0x90, 7229c936b12SNeil Armstrong .havon_end = 0x30f, 7239c936b12SNeil Armstrong .vavon_bline = 0x23, 7249c936b12SNeil Armstrong .vavon_eline = 0x202, 7259c936b12SNeil Armstrong /* eqpuls_begin */ 7269c936b12SNeil Armstrong /* eqpuls_end */ 7279c936b12SNeil Armstrong /* eqpuls_bline */ 7289c936b12SNeil Armstrong /* eqpuls_eline */ 7299c936b12SNeil Armstrong .hso_begin = 0, 7309c936b12SNeil Armstrong .hso_end = 0x60, 7319c936b12SNeil Armstrong .vso_begin = 0x1e, 7329c936b12SNeil Armstrong .vso_end = 0x32, 7339c936b12SNeil Armstrong .vso_bline = 0, 7349c936b12SNeil Armstrong .vso_eline = 2, 7359c936b12SNeil Armstrong .vso_eline_present = true, 7369c936b12SNeil Armstrong /* sy_val */ 7379c936b12SNeil Armstrong /* sy2_val */ 7389c936b12SNeil Armstrong .max_lncnt = 0x20c, 7399c936b12SNeil Armstrong }, 7409c936b12SNeil Armstrong }; 7419c936b12SNeil Armstrong 7429c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_800x600_60 = { 7439c936b12SNeil Armstrong .encp = { 7449c936b12SNeil Armstrong .dvi_settings = 0x21, 7459c936b12SNeil Armstrong .video_mode = 0x4040, 7469c936b12SNeil Armstrong .video_mode_adv = 0x18, 7479c936b12SNeil Armstrong /* video_prog_mode */ 7489c936b12SNeil Armstrong /* video_sync_mode */ 7499c936b12SNeil Armstrong /* video_yc_dly */ 7509c936b12SNeil Armstrong /* video_rgb_ctrl */ 7519c936b12SNeil Armstrong /* video_filt_ctrl */ 7529c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 7539c936b12SNeil Armstrong /* yfp1_htime */ 7549c936b12SNeil Armstrong /* yfp2_htime */ 7559c936b12SNeil Armstrong .max_pxcnt = 0x41f, 7569c936b12SNeil Armstrong /* hspuls_begin */ 7579c936b12SNeil Armstrong /* hspuls_end */ 7589c936b12SNeil Armstrong /* hspuls_switch */ 7599c936b12SNeil Armstrong /* vspuls_begin */ 7609c936b12SNeil Armstrong /* vspuls_end */ 7619c936b12SNeil Armstrong /* vspuls_bline */ 7629c936b12SNeil Armstrong /* vspuls_eline */ 7639c936b12SNeil Armstrong .havon_begin = 0xD8, 7649c936b12SNeil Armstrong .havon_end = 0x3f7, 7659c936b12SNeil Armstrong .vavon_bline = 0x1b, 7669c936b12SNeil Armstrong .vavon_eline = 0x272, 7679c936b12SNeil Armstrong /* eqpuls_begin */ 7689c936b12SNeil Armstrong /* eqpuls_end */ 7699c936b12SNeil Armstrong /* eqpuls_bline */ 7709c936b12SNeil Armstrong /* eqpuls_eline */ 7719c936b12SNeil Armstrong .hso_begin = 0, 7729c936b12SNeil Armstrong .hso_end = 0x80, 7739c936b12SNeil Armstrong .vso_begin = 0x1e, 7749c936b12SNeil Armstrong .vso_end = 0x32, 7759c936b12SNeil Armstrong .vso_bline = 0, 7769c936b12SNeil Armstrong .vso_eline = 4, 7779c936b12SNeil Armstrong .vso_eline_present = true, 7789c936b12SNeil Armstrong /* sy_val */ 7799c936b12SNeil Armstrong /* sy2_val */ 7809c936b12SNeil Armstrong .max_lncnt = 0x273, 7819c936b12SNeil Armstrong }, 7829c936b12SNeil Armstrong }; 7839c936b12SNeil Armstrong 7849c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1024x768_60 = { 7859c936b12SNeil Armstrong .encp = { 7869c936b12SNeil Armstrong .dvi_settings = 0x21, 7879c936b12SNeil Armstrong .video_mode = 0x4040, 7889c936b12SNeil Armstrong .video_mode_adv = 0x18, 7899c936b12SNeil Armstrong /* video_prog_mode */ 7909c936b12SNeil Armstrong /* video_sync_mode */ 7919c936b12SNeil Armstrong /* video_yc_dly */ 7929c936b12SNeil Armstrong /* video_rgb_ctrl */ 7939c936b12SNeil Armstrong /* video_filt_ctrl */ 7949c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 7959c936b12SNeil Armstrong /* yfp1_htime */ 7969c936b12SNeil Armstrong /* yfp2_htime */ 7979c936b12SNeil Armstrong .max_pxcnt = 1343, 7989c936b12SNeil Armstrong /* hspuls_begin */ 7999c936b12SNeil Armstrong /* hspuls_end */ 8009c936b12SNeil Armstrong /* hspuls_switch */ 8019c936b12SNeil Armstrong /* vspuls_begin */ 8029c936b12SNeil Armstrong /* vspuls_end */ 8039c936b12SNeil Armstrong /* vspuls_bline */ 8049c936b12SNeil Armstrong /* vspuls_eline */ 8059c936b12SNeil Armstrong .havon_begin = 296, 8069c936b12SNeil Armstrong .havon_end = 1319, 8079c936b12SNeil Armstrong .vavon_bline = 35, 8089c936b12SNeil Armstrong .vavon_eline = 802, 8099c936b12SNeil Armstrong /* eqpuls_begin */ 8109c936b12SNeil Armstrong /* eqpuls_end */ 8119c936b12SNeil Armstrong /* eqpuls_bline */ 8129c936b12SNeil Armstrong /* eqpuls_eline */ 8139c936b12SNeil Armstrong .hso_begin = 0, 8149c936b12SNeil Armstrong .hso_end = 136, 8159c936b12SNeil Armstrong .vso_begin = 30, 8169c936b12SNeil Armstrong .vso_end = 50, 8179c936b12SNeil Armstrong .vso_bline = 0, 8189c936b12SNeil Armstrong .vso_eline = 6, 8199c936b12SNeil Armstrong .vso_eline_present = true, 8209c936b12SNeil Armstrong /* sy_val */ 8219c936b12SNeil Armstrong /* sy2_val */ 8229c936b12SNeil Armstrong .max_lncnt = 805, 8239c936b12SNeil Armstrong }, 8249c936b12SNeil Armstrong }; 8259c936b12SNeil Armstrong 8269c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1152x864_75 = { 8279c936b12SNeil Armstrong .encp = { 8289c936b12SNeil Armstrong .dvi_settings = 0x21, 8299c936b12SNeil Armstrong .video_mode = 0x4040, 8309c936b12SNeil Armstrong .video_mode_adv = 0x18, 8319c936b12SNeil Armstrong /* video_prog_mode */ 8329c936b12SNeil Armstrong /* video_sync_mode */ 8339c936b12SNeil Armstrong /* video_yc_dly */ 8349c936b12SNeil Armstrong /* video_rgb_ctrl */ 8359c936b12SNeil Armstrong /* video_filt_ctrl */ 8369c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 8379c936b12SNeil Armstrong /* yfp1_htime */ 8389c936b12SNeil Armstrong /* yfp2_htime */ 8399c936b12SNeil Armstrong .max_pxcnt = 0x63f, 8409c936b12SNeil Armstrong /* hspuls_begin */ 8419c936b12SNeil Armstrong /* hspuls_end */ 8429c936b12SNeil Armstrong /* hspuls_switch */ 8439c936b12SNeil Armstrong /* vspuls_begin */ 8449c936b12SNeil Armstrong /* vspuls_end */ 8459c936b12SNeil Armstrong /* vspuls_bline */ 8469c936b12SNeil Armstrong /* vspuls_eline */ 8479c936b12SNeil Armstrong .havon_begin = 0x180, 8489c936b12SNeil Armstrong .havon_end = 0x5ff, 8499c936b12SNeil Armstrong .vavon_bline = 0x23, 8509c936b12SNeil Armstrong .vavon_eline = 0x382, 8519c936b12SNeil Armstrong /* eqpuls_begin */ 8529c936b12SNeil Armstrong /* eqpuls_end */ 8539c936b12SNeil Armstrong /* eqpuls_bline */ 8549c936b12SNeil Armstrong /* eqpuls_eline */ 8559c936b12SNeil Armstrong .hso_begin = 0, 8569c936b12SNeil Armstrong .hso_end = 0x80, 8579c936b12SNeil Armstrong .vso_begin = 0x1e, 8589c936b12SNeil Armstrong .vso_end = 0x32, 8599c936b12SNeil Armstrong .vso_bline = 0, 8609c936b12SNeil Armstrong .vso_eline = 3, 8619c936b12SNeil Armstrong .vso_eline_present = true, 8629c936b12SNeil Armstrong /* sy_val */ 8639c936b12SNeil Armstrong /* sy2_val */ 8649c936b12SNeil Armstrong .max_lncnt = 0x383, 8659c936b12SNeil Armstrong }, 8669c936b12SNeil Armstrong }; 8679c936b12SNeil Armstrong 8689c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1280x1024_60 = { 8699c936b12SNeil Armstrong .encp = { 8709c936b12SNeil Armstrong .dvi_settings = 0x21, 8719c936b12SNeil Armstrong .video_mode = 0x4040, 8729c936b12SNeil Armstrong .video_mode_adv = 0x18, 8739c936b12SNeil Armstrong /* video_prog_mode */ 8749c936b12SNeil Armstrong /* video_sync_mode */ 8759c936b12SNeil Armstrong /* video_yc_dly */ 8769c936b12SNeil Armstrong /* video_rgb_ctrl */ 8779c936b12SNeil Armstrong /* video_filt_ctrl */ 8789c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 8799c936b12SNeil Armstrong /* yfp1_htime */ 8809c936b12SNeil Armstrong /* yfp2_htime */ 8819c936b12SNeil Armstrong .max_pxcnt = 0x697, 8829c936b12SNeil Armstrong /* hspuls_begin */ 8839c936b12SNeil Armstrong /* hspuls_end */ 8849c936b12SNeil Armstrong /* hspuls_switch */ 8859c936b12SNeil Armstrong /* vspuls_begin */ 8869c936b12SNeil Armstrong /* vspuls_end */ 8879c936b12SNeil Armstrong /* vspuls_bline */ 8889c936b12SNeil Armstrong /* vspuls_eline */ 8899c936b12SNeil Armstrong .havon_begin = 0x168, 8909c936b12SNeil Armstrong .havon_end = 0x667, 8919c936b12SNeil Armstrong .vavon_bline = 0x29, 8929c936b12SNeil Armstrong .vavon_eline = 0x428, 8939c936b12SNeil Armstrong /* eqpuls_begin */ 8949c936b12SNeil Armstrong /* eqpuls_end */ 8959c936b12SNeil Armstrong /* eqpuls_bline */ 8969c936b12SNeil Armstrong /* eqpuls_eline */ 8979c936b12SNeil Armstrong .hso_begin = 0, 8989c936b12SNeil Armstrong .hso_end = 0x70, 8999c936b12SNeil Armstrong .vso_begin = 0x1e, 9009c936b12SNeil Armstrong .vso_end = 0x32, 9019c936b12SNeil Armstrong .vso_bline = 0, 9029c936b12SNeil Armstrong .vso_eline = 3, 9039c936b12SNeil Armstrong .vso_eline_present = true, 9049c936b12SNeil Armstrong /* sy_val */ 9059c936b12SNeil Armstrong /* sy2_val */ 9069c936b12SNeil Armstrong .max_lncnt = 0x429, 9079c936b12SNeil Armstrong }, 9089c936b12SNeil Armstrong }; 9099c936b12SNeil Armstrong 9109c936b12SNeil Armstrong union meson_hdmi_venc_mode meson_hdmi_encp_mode_1600x1200_60 = { 9119c936b12SNeil Armstrong .encp = { 9129c936b12SNeil Armstrong .dvi_settings = 0x21, 9139c936b12SNeil Armstrong .video_mode = 0x4040, 9149c936b12SNeil Armstrong .video_mode_adv = 0x18, 9159c936b12SNeil Armstrong /* video_prog_mode */ 9169c936b12SNeil Armstrong /* video_sync_mode */ 9179c936b12SNeil Armstrong /* video_yc_dly */ 9189c936b12SNeil Armstrong /* video_rgb_ctrl */ 9199c936b12SNeil Armstrong /* video_filt_ctrl */ 9209c936b12SNeil Armstrong /* video_ofld_voav_ofst */ 9219c936b12SNeil Armstrong /* yfp1_htime */ 9229c936b12SNeil Armstrong /* yfp2_htime */ 9239c936b12SNeil Armstrong .max_pxcnt = 0x86f, 9249c936b12SNeil Armstrong /* hspuls_begin */ 9259c936b12SNeil Armstrong /* hspuls_end */ 9269c936b12SNeil Armstrong /* hspuls_switch */ 9279c936b12SNeil Armstrong /* vspuls_begin */ 9289c936b12SNeil Armstrong /* vspuls_end */ 9299c936b12SNeil Armstrong /* vspuls_bline */ 9309c936b12SNeil Armstrong /* vspuls_eline */ 9319c936b12SNeil Armstrong .havon_begin = 0x1f0, 9329c936b12SNeil Armstrong .havon_end = 0x82f, 9339c936b12SNeil Armstrong .vavon_bline = 0x31, 9349c936b12SNeil Armstrong .vavon_eline = 0x4e0, 9359c936b12SNeil Armstrong /* eqpuls_begin */ 9369c936b12SNeil Armstrong /* eqpuls_end */ 9379c936b12SNeil Armstrong /* eqpuls_bline */ 9389c936b12SNeil Armstrong /* eqpuls_eline */ 9399c936b12SNeil Armstrong .hso_begin = 0, 9409c936b12SNeil Armstrong .hso_end = 0xc0, 9419c936b12SNeil Armstrong .vso_begin = 0x1e, 9429c936b12SNeil Armstrong .vso_end = 0x32, 9439c936b12SNeil Armstrong .vso_bline = 0, 9449c936b12SNeil Armstrong .vso_eline = 3, 9459c936b12SNeil Armstrong .vso_eline_present = true, 9469c936b12SNeil Armstrong /* sy_val */ 9479c936b12SNeil Armstrong /* sy2_val */ 9489c936b12SNeil Armstrong .max_lncnt = 0x4e1, 9499c936b12SNeil Armstrong }, 9509c936b12SNeil Armstrong }; 9519c936b12SNeil Armstrong 9529c936b12SNeil Armstrong struct meson_hdmi_venc_dmt_mode { 9539c936b12SNeil Armstrong struct drm_display_mode drm_mode; 9549c936b12SNeil Armstrong union meson_hdmi_venc_mode *mode; 9559c936b12SNeil Armstrong } meson_hdmi_venc_dmt_modes[] = { 9569c936b12SNeil Armstrong /* 640x480@60Hz */ 9579c936b12SNeil Armstrong { 9589c936b12SNeil Armstrong { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, 9599c936b12SNeil Armstrong 752, 800, 0, 480, 490, 492, 525, 0, 9609c936b12SNeil Armstrong DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, 9619c936b12SNeil Armstrong &meson_hdmi_encp_mode_640x480_60, 9629c936b12SNeil Armstrong }, 9639c936b12SNeil Armstrong /* 800x600@60Hz */ 9649c936b12SNeil Armstrong { 9659c936b12SNeil Armstrong { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, 9669c936b12SNeil Armstrong 968, 1056, 0, 600, 601, 605, 628, 0, 9679c936b12SNeil Armstrong DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 9689c936b12SNeil Armstrong &meson_hdmi_encp_mode_800x600_60, 9699c936b12SNeil Armstrong }, 9709c936b12SNeil Armstrong /* 1024x768@60Hz */ 9719c936b12SNeil Armstrong { 9729c936b12SNeil Armstrong { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 9739c936b12SNeil Armstrong 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, 9749c936b12SNeil Armstrong DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, 9759c936b12SNeil Armstrong &meson_hdmi_encp_mode_1024x768_60, 9769c936b12SNeil Armstrong }, 9779c936b12SNeil Armstrong /* 1152x864@75Hz */ 9789c936b12SNeil Armstrong { 9799c936b12SNeil Armstrong { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 9809c936b12SNeil Armstrong 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, 9819c936b12SNeil Armstrong DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 9829c936b12SNeil Armstrong &meson_hdmi_encp_mode_1152x864_75, 9839c936b12SNeil Armstrong }, 9849c936b12SNeil Armstrong /* 1280x1024@60Hz */ 9859c936b12SNeil Armstrong { 9869c936b12SNeil Armstrong { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 9879c936b12SNeil Armstrong 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, 9889c936b12SNeil Armstrong DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 9899c936b12SNeil Armstrong &meson_hdmi_encp_mode_1280x1024_60, 9909c936b12SNeil Armstrong }, 9919c936b12SNeil Armstrong /* 1600x1200@60Hz */ 9929c936b12SNeil Armstrong { 9939c936b12SNeil Armstrong { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 9949c936b12SNeil Armstrong 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, 9959c936b12SNeil Armstrong DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 9969c936b12SNeil Armstrong &meson_hdmi_encp_mode_1600x1200_60, 9979c936b12SNeil Armstrong }, 9989c936b12SNeil Armstrong /* 1920x1080@60Hz */ 9999c936b12SNeil Armstrong { 10009c936b12SNeil Armstrong { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 10019c936b12SNeil Armstrong 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, 10029c936b12SNeil Armstrong DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, 10039c936b12SNeil Armstrong &meson_hdmi_encp_mode_1080p60 10049c936b12SNeil Armstrong }, 10059c936b12SNeil Armstrong { }, /* sentinel */ 10069c936b12SNeil Armstrong }; 10079c936b12SNeil Armstrong 1008335e3713SNeil Armstrong struct meson_hdmi_venc_vic_mode { 1009335e3713SNeil Armstrong unsigned int vic; 1010335e3713SNeil Armstrong union meson_hdmi_venc_mode *mode; 1011335e3713SNeil Armstrong } meson_hdmi_venc_vic_modes[] = { 1012335e3713SNeil Armstrong { 6, &meson_hdmi_enci_mode_480i }, 1013335e3713SNeil Armstrong { 7, &meson_hdmi_enci_mode_480i }, 1014335e3713SNeil Armstrong { 21, &meson_hdmi_enci_mode_576i }, 1015335e3713SNeil Armstrong { 22, &meson_hdmi_enci_mode_576i }, 1016335e3713SNeil Armstrong { 2, &meson_hdmi_encp_mode_480p }, 1017335e3713SNeil Armstrong { 3, &meson_hdmi_encp_mode_480p }, 1018335e3713SNeil Armstrong { 17, &meson_hdmi_encp_mode_576p }, 1019335e3713SNeil Armstrong { 18, &meson_hdmi_encp_mode_576p }, 1020335e3713SNeil Armstrong { 4, &meson_hdmi_encp_mode_720p60 }, 1021335e3713SNeil Armstrong { 19, &meson_hdmi_encp_mode_720p50 }, 1022335e3713SNeil Armstrong { 5, &meson_hdmi_encp_mode_1080i60 }, 1023335e3713SNeil Armstrong { 20, &meson_hdmi_encp_mode_1080i50 }, 1024335e3713SNeil Armstrong { 32, &meson_hdmi_encp_mode_1080p24 }, 1025335e3713SNeil Armstrong { 34, &meson_hdmi_encp_mode_1080p30 }, 1026335e3713SNeil Armstrong { 31, &meson_hdmi_encp_mode_1080p50 }, 1027335e3713SNeil Armstrong { 16, &meson_hdmi_encp_mode_1080p60 }, 1028335e3713SNeil Armstrong { 0, NULL}, /* sentinel */ 1029335e3713SNeil Armstrong }; 1030335e3713SNeil Armstrong 1031335e3713SNeil Armstrong static signed int to_signed(unsigned int a) 1032335e3713SNeil Armstrong { 1033335e3713SNeil Armstrong if (a <= 7) 1034335e3713SNeil Armstrong return a; 1035335e3713SNeil Armstrong else 1036335e3713SNeil Armstrong return a - 16; 1037335e3713SNeil Armstrong } 1038335e3713SNeil Armstrong 1039335e3713SNeil Armstrong static unsigned long modulo(unsigned long a, unsigned long b) 1040335e3713SNeil Armstrong { 1041335e3713SNeil Armstrong if (a >= b) 1042335e3713SNeil Armstrong return a - b; 1043335e3713SNeil Armstrong else 1044335e3713SNeil Armstrong return a; 1045335e3713SNeil Armstrong } 1046335e3713SNeil Armstrong 10479c936b12SNeil Armstrong bool meson_venc_hdmi_supported_mode(const struct drm_display_mode *mode) 10489c936b12SNeil Armstrong { 10499c936b12SNeil Armstrong struct meson_hdmi_venc_dmt_mode *vmode = meson_hdmi_venc_dmt_modes; 10509c936b12SNeil Armstrong 10519c936b12SNeil Armstrong while (vmode->mode) { 10529c936b12SNeil Armstrong if (drm_mode_equal(&vmode->drm_mode, mode)) 10539c936b12SNeil Armstrong return true; 10549c936b12SNeil Armstrong vmode++; 10559c936b12SNeil Armstrong } 10569c936b12SNeil Armstrong 10579c936b12SNeil Armstrong return false; 10589c936b12SNeil Armstrong } 10599c936b12SNeil Armstrong EXPORT_SYMBOL_GPL(meson_venc_hdmi_supported_mode); 10609c936b12SNeil Armstrong 1061335e3713SNeil Armstrong bool meson_venc_hdmi_supported_vic(int vic) 1062335e3713SNeil Armstrong { 1063335e3713SNeil Armstrong struct meson_hdmi_venc_vic_mode *vmode = meson_hdmi_venc_vic_modes; 1064335e3713SNeil Armstrong 1065335e3713SNeil Armstrong while (vmode->vic && vmode->mode) { 1066335e3713SNeil Armstrong if (vmode->vic == vic) 1067335e3713SNeil Armstrong return true; 1068335e3713SNeil Armstrong vmode++; 1069335e3713SNeil Armstrong } 1070335e3713SNeil Armstrong 1071335e3713SNeil Armstrong return false; 1072335e3713SNeil Armstrong } 1073335e3713SNeil Armstrong EXPORT_SYMBOL_GPL(meson_venc_hdmi_supported_vic); 1074335e3713SNeil Armstrong 10759c936b12SNeil Armstrong static union meson_hdmi_venc_mode 10769c936b12SNeil Armstrong *meson_venc_hdmi_get_dmt_vmode(const struct drm_display_mode *mode) 10779c936b12SNeil Armstrong { 10789c936b12SNeil Armstrong struct meson_hdmi_venc_dmt_mode *vmode = meson_hdmi_venc_dmt_modes; 10799c936b12SNeil Armstrong 10809c936b12SNeil Armstrong while (vmode->mode) { 10819c936b12SNeil Armstrong if (drm_mode_equal(&vmode->drm_mode, mode)) 10829c936b12SNeil Armstrong return vmode->mode; 10839c936b12SNeil Armstrong vmode++; 10849c936b12SNeil Armstrong } 10859c936b12SNeil Armstrong 10869c936b12SNeil Armstrong return NULL; 10879c936b12SNeil Armstrong } 10889c936b12SNeil Armstrong 1089335e3713SNeil Armstrong static union meson_hdmi_venc_mode *meson_venc_hdmi_get_vic_vmode(int vic) 1090335e3713SNeil Armstrong { 1091335e3713SNeil Armstrong struct meson_hdmi_venc_vic_mode *vmode = meson_hdmi_venc_vic_modes; 1092335e3713SNeil Armstrong 1093335e3713SNeil Armstrong while (vmode->vic && vmode->mode) { 1094335e3713SNeil Armstrong if (vmode->vic == vic) 1095335e3713SNeil Armstrong return vmode->mode; 1096335e3713SNeil Armstrong vmode++; 1097335e3713SNeil Armstrong } 1098335e3713SNeil Armstrong 1099335e3713SNeil Armstrong return NULL; 1100335e3713SNeil Armstrong } 1101335e3713SNeil Armstrong 1102335e3713SNeil Armstrong bool meson_venc_hdmi_venc_repeat(int vic) 1103335e3713SNeil Armstrong { 1104335e3713SNeil Armstrong /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */ 1105335e3713SNeil Armstrong if (vic == 6 || vic == 7 || /* 480i */ 1106335e3713SNeil Armstrong vic == 21 || vic == 22 || /* 576i */ 1107335e3713SNeil Armstrong vic == 17 || vic == 18 || /* 576p */ 1108335e3713SNeil Armstrong vic == 2 || vic == 3 || /* 480p */ 1109335e3713SNeil Armstrong vic == 4 || /* 720p60 */ 1110335e3713SNeil Armstrong vic == 19 || /* 720p50 */ 1111335e3713SNeil Armstrong vic == 5 || /* 1080i60 */ 1112335e3713SNeil Armstrong vic == 20) /* 1080i50 */ 1113335e3713SNeil Armstrong return true; 1114335e3713SNeil Armstrong 1115335e3713SNeil Armstrong return false; 1116335e3713SNeil Armstrong } 1117335e3713SNeil Armstrong EXPORT_SYMBOL_GPL(meson_venc_hdmi_venc_repeat); 1118335e3713SNeil Armstrong 1119335e3713SNeil Armstrong void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic, 1120335e3713SNeil Armstrong struct drm_display_mode *mode) 1121335e3713SNeil Armstrong { 1122335e3713SNeil Armstrong union meson_hdmi_venc_mode *vmode = NULL; 1123335e3713SNeil Armstrong bool use_enci = false; 1124335e3713SNeil Armstrong bool venc_repeat = false; 1125335e3713SNeil Armstrong bool hdmi_repeat = false; 1126335e3713SNeil Armstrong unsigned int venc_hdmi_latency = 2; 1127335e3713SNeil Armstrong unsigned long total_pixels_venc = 0; 1128335e3713SNeil Armstrong unsigned long active_pixels_venc = 0; 1129335e3713SNeil Armstrong unsigned long front_porch_venc = 0; 1130335e3713SNeil Armstrong unsigned long hsync_pixels_venc = 0; 1131335e3713SNeil Armstrong unsigned long de_h_begin = 0; 1132335e3713SNeil Armstrong unsigned long de_h_end = 0; 1133335e3713SNeil Armstrong unsigned long de_v_begin_even = 0; 1134335e3713SNeil Armstrong unsigned long de_v_end_even = 0; 1135335e3713SNeil Armstrong unsigned long de_v_begin_odd = 0; 1136335e3713SNeil Armstrong unsigned long de_v_end_odd = 0; 1137335e3713SNeil Armstrong unsigned long hs_begin = 0; 1138335e3713SNeil Armstrong unsigned long hs_end = 0; 1139335e3713SNeil Armstrong unsigned long vs_adjust = 0; 1140335e3713SNeil Armstrong unsigned long vs_bline_evn = 0; 1141335e3713SNeil Armstrong unsigned long vs_eline_evn = 0; 1142335e3713SNeil Armstrong unsigned long vs_bline_odd = 0; 1143335e3713SNeil Armstrong unsigned long vs_eline_odd = 0; 1144335e3713SNeil Armstrong unsigned long vso_begin_evn = 0; 1145335e3713SNeil Armstrong unsigned long vso_begin_odd = 0; 1146335e3713SNeil Armstrong unsigned int eof_lines; 1147335e3713SNeil Armstrong unsigned int sof_lines; 1148335e3713SNeil Armstrong unsigned int vsync_lines; 1149335e3713SNeil Armstrong 11509c936b12SNeil Armstrong if (meson_venc_hdmi_supported_vic(vic)) 1151335e3713SNeil Armstrong vmode = meson_venc_hdmi_get_vic_vmode(vic); 11529c936b12SNeil Armstrong else 11539c936b12SNeil Armstrong vmode = meson_venc_hdmi_get_dmt_vmode(mode); 1154335e3713SNeil Armstrong if (!vmode) { 11559c936b12SNeil Armstrong dev_err(priv->dev, "%s: Fatal Error, unsupported mode " 11569c936b12SNeil Armstrong DRM_MODE_FMT "\n", __func__, DRM_MODE_ARG(mode)); 1157335e3713SNeil Armstrong return; 1158335e3713SNeil Armstrong } 1159335e3713SNeil Armstrong 1160335e3713SNeil Armstrong /* Use VENCI for 480i and 576i and double HDMI pixels */ 1161335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_DBLCLK) { 1162335e3713SNeil Armstrong hdmi_repeat = true; 1163335e3713SNeil Armstrong use_enci = true; 1164335e3713SNeil Armstrong venc_hdmi_latency = 1; 1165335e3713SNeil Armstrong } 1166335e3713SNeil Armstrong 1167335e3713SNeil Armstrong /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */ 1168335e3713SNeil Armstrong if (meson_venc_hdmi_venc_repeat(vic)) 1169335e3713SNeil Armstrong venc_repeat = true; 1170335e3713SNeil Armstrong 1171335e3713SNeil Armstrong eof_lines = mode->vsync_start - mode->vdisplay; 1172335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1173335e3713SNeil Armstrong eof_lines /= 2; 1174335e3713SNeil Armstrong sof_lines = mode->vtotal - mode->vsync_end; 1175335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1176335e3713SNeil Armstrong sof_lines /= 2; 1177335e3713SNeil Armstrong vsync_lines = mode->vsync_end - mode->vsync_start; 1178335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1179335e3713SNeil Armstrong vsync_lines /= 2; 1180335e3713SNeil Armstrong 1181335e3713SNeil Armstrong total_pixels_venc = mode->htotal; 1182335e3713SNeil Armstrong if (hdmi_repeat) 1183335e3713SNeil Armstrong total_pixels_venc /= 2; 1184335e3713SNeil Armstrong if (venc_repeat) 1185335e3713SNeil Armstrong total_pixels_venc *= 2; 1186335e3713SNeil Armstrong 1187335e3713SNeil Armstrong active_pixels_venc = mode->hdisplay; 1188335e3713SNeil Armstrong if (hdmi_repeat) 1189335e3713SNeil Armstrong active_pixels_venc /= 2; 1190335e3713SNeil Armstrong if (venc_repeat) 1191335e3713SNeil Armstrong active_pixels_venc *= 2; 1192335e3713SNeil Armstrong 1193335e3713SNeil Armstrong front_porch_venc = (mode->hsync_start - mode->hdisplay); 1194335e3713SNeil Armstrong if (hdmi_repeat) 1195335e3713SNeil Armstrong front_porch_venc /= 2; 1196335e3713SNeil Armstrong if (venc_repeat) 1197335e3713SNeil Armstrong front_porch_venc *= 2; 1198335e3713SNeil Armstrong 1199335e3713SNeil Armstrong hsync_pixels_venc = (mode->hsync_end - mode->hsync_start); 1200335e3713SNeil Armstrong if (hdmi_repeat) 1201335e3713SNeil Armstrong hsync_pixels_venc /= 2; 1202335e3713SNeil Armstrong if (venc_repeat) 1203335e3713SNeil Armstrong hsync_pixels_venc *= 2; 1204335e3713SNeil Armstrong 1205335e3713SNeil Armstrong /* Disable VDACs */ 12069c936b12SNeil Armstrong writel_bits_relaxed(0xff, 0xff, 1207335e3713SNeil Armstrong priv->io_base + _REG(VENC_VDAC_SETTING)); 1208335e3713SNeil Armstrong 1209335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN)); 1210335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN)); 1211335e3713SNeil Armstrong 1212335e3713SNeil Armstrong if (use_enci) { 1213335e3713SNeil Armstrong unsigned int lines_f0; 1214335e3713SNeil Armstrong unsigned int lines_f1; 1215335e3713SNeil Armstrong 1216335e3713SNeil Armstrong /* CVBS Filter settings */ 1217335e3713SNeil Armstrong writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL)); 1218335e3713SNeil Armstrong writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2)); 1219335e3713SNeil Armstrong 1220335e3713SNeil Armstrong /* Digital Video Select : Interlace, clk27 clk, external */ 1221335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING)); 1222335e3713SNeil Armstrong 1223335e3713SNeil Armstrong /* Reset Video Mode */ 1224335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE)); 1225335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV)); 1226335e3713SNeil Armstrong 1227335e3713SNeil Armstrong /* Horizontal sync signal output */ 1228335e3713SNeil Armstrong writel_relaxed(vmode->enci.hso_begin, 1229335e3713SNeil Armstrong priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN)); 1230335e3713SNeil Armstrong writel_relaxed(vmode->enci.hso_end, 1231335e3713SNeil Armstrong priv->io_base + _REG(ENCI_SYNC_HSO_END)); 1232335e3713SNeil Armstrong 1233335e3713SNeil Armstrong /* Vertical Sync lines */ 1234335e3713SNeil Armstrong writel_relaxed(vmode->enci.vso_even, 1235335e3713SNeil Armstrong priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN)); 1236335e3713SNeil Armstrong writel_relaxed(vmode->enci.vso_odd, 1237335e3713SNeil Armstrong priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN)); 1238335e3713SNeil Armstrong 1239335e3713SNeil Armstrong /* Macrovision max amplitude change */ 1240335e3713SNeil Armstrong writel_relaxed(vmode->enci.macv_max_amp, 1241335e3713SNeil Armstrong priv->io_base + _REG(ENCI_MACV_MAX_AMP)); 1242335e3713SNeil Armstrong 1243335e3713SNeil Armstrong /* Video mode */ 1244335e3713SNeil Armstrong writel_relaxed(vmode->enci.video_prog_mode, 1245335e3713SNeil Armstrong priv->io_base + _REG(VENC_VIDEO_PROG_MODE)); 1246335e3713SNeil Armstrong writel_relaxed(vmode->enci.video_mode, 1247335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_MODE)); 1248335e3713SNeil Armstrong 1249335e3713SNeil Armstrong /* Advanced Video Mode : 1250335e3713SNeil Armstrong * Demux shifting 0x2 1251335e3713SNeil Armstrong * Blank line end at line17/22 1252335e3713SNeil Armstrong * High bandwidth Luma Filter 1253335e3713SNeil Armstrong * Low bandwidth Chroma Filter 1254335e3713SNeil Armstrong * Bypass luma low pass filter 1255335e3713SNeil Armstrong * No macrovision on CSYNC 1256335e3713SNeil Armstrong */ 1257335e3713SNeil Armstrong writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV)); 1258335e3713SNeil Armstrong 1259335e3713SNeil Armstrong writel(vmode->enci.sch_adjust, 1260335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_SCH)); 1261335e3713SNeil Armstrong 1262335e3713SNeil Armstrong /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */ 1263335e3713SNeil Armstrong writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE)); 1264335e3713SNeil Armstrong 1265335e3713SNeil Armstrong if (vmode->enci.yc_delay) 1266335e3713SNeil Armstrong writel_relaxed(vmode->enci.yc_delay, 1267335e3713SNeil Armstrong priv->io_base + _REG(ENCI_YC_DELAY)); 1268335e3713SNeil Armstrong 1269335e3713SNeil Armstrong 1270335e3713SNeil Armstrong /* UNreset Interlaced TV Encoder */ 1271335e3713SNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST)); 1272335e3713SNeil Armstrong 1273335e3713SNeil Armstrong /* Enable Vfifo2vd, Y_Cb_Y_Cr select */ 1274335e3713SNeil Armstrong writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL)); 1275335e3713SNeil Armstrong 1276335e3713SNeil Armstrong /* Timings */ 1277335e3713SNeil Armstrong writel_relaxed(vmode->enci.pixel_start, 1278335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START)); 1279335e3713SNeil Armstrong writel_relaxed(vmode->enci.pixel_end, 1280335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END)); 1281335e3713SNeil Armstrong 1282335e3713SNeil Armstrong writel_relaxed(vmode->enci.top_field_line_start, 1283335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START)); 1284335e3713SNeil Armstrong writel_relaxed(vmode->enci.top_field_line_end, 1285335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END)); 1286335e3713SNeil Armstrong 1287335e3713SNeil Armstrong writel_relaxed(vmode->enci.bottom_field_line_start, 1288335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START)); 1289335e3713SNeil Armstrong writel_relaxed(vmode->enci.bottom_field_line_end, 1290335e3713SNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END)); 1291335e3713SNeil Armstrong 1292335e3713SNeil Armstrong /* Select ENCI for VIU */ 1293335e3713SNeil Armstrong meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI); 1294335e3713SNeil Armstrong 1295335e3713SNeil Armstrong /* Interlace video enable */ 1296335e3713SNeil Armstrong writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN)); 1297335e3713SNeil Armstrong 1298335e3713SNeil Armstrong lines_f0 = mode->vtotal >> 1; 1299335e3713SNeil Armstrong lines_f1 = lines_f0 + 1; 1300335e3713SNeil Armstrong 1301335e3713SNeil Armstrong de_h_begin = modulo(readl_relaxed(priv->io_base + 1302335e3713SNeil Armstrong _REG(ENCI_VFIFO2VD_PIXEL_START)) 1303335e3713SNeil Armstrong + venc_hdmi_latency, 1304335e3713SNeil Armstrong total_pixels_venc); 1305335e3713SNeil Armstrong de_h_end = modulo(de_h_begin + active_pixels_venc, 1306335e3713SNeil Armstrong total_pixels_venc); 1307335e3713SNeil Armstrong 1308335e3713SNeil Armstrong writel_relaxed(de_h_begin, 1309335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_H_BEGIN)); 1310335e3713SNeil Armstrong writel_relaxed(de_h_end, 1311335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_H_END)); 1312335e3713SNeil Armstrong 1313335e3713SNeil Armstrong de_v_begin_even = readl_relaxed(priv->io_base + 1314335e3713SNeil Armstrong _REG(ENCI_VFIFO2VD_LINE_TOP_START)); 1315335e3713SNeil Armstrong de_v_end_even = de_v_begin_even + mode->vdisplay; 1316335e3713SNeil Armstrong de_v_begin_odd = readl_relaxed(priv->io_base + 1317335e3713SNeil Armstrong _REG(ENCI_VFIFO2VD_LINE_BOT_START)); 1318335e3713SNeil Armstrong de_v_end_odd = de_v_begin_odd + mode->vdisplay; 1319335e3713SNeil Armstrong 1320335e3713SNeil Armstrong writel_relaxed(de_v_begin_even, 1321335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_V_BEGIN_EVEN)); 1322335e3713SNeil Armstrong writel_relaxed(de_v_end_even, 1323335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_V_END_EVEN)); 1324335e3713SNeil Armstrong writel_relaxed(de_v_begin_odd, 1325335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_V_BEGIN_ODD)); 1326335e3713SNeil Armstrong writel_relaxed(de_v_end_odd, 1327335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DE_V_END_ODD)); 1328335e3713SNeil Armstrong 1329335e3713SNeil Armstrong /* Program Hsync timing */ 1330335e3713SNeil Armstrong hs_begin = de_h_end + front_porch_venc; 1331335e3713SNeil Armstrong if (de_h_end + front_porch_venc >= total_pixels_venc) { 1332335e3713SNeil Armstrong hs_begin -= total_pixels_venc; 1333335e3713SNeil Armstrong vs_adjust = 1; 1334335e3713SNeil Armstrong } else { 1335335e3713SNeil Armstrong hs_begin = de_h_end + front_porch_venc; 1336335e3713SNeil Armstrong vs_adjust = 0; 1337335e3713SNeil Armstrong } 1338335e3713SNeil Armstrong 1339335e3713SNeil Armstrong hs_end = modulo(hs_begin + hsync_pixels_venc, 1340335e3713SNeil Armstrong total_pixels_venc); 1341335e3713SNeil Armstrong writel_relaxed(hs_begin, 1342335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_HSO_BEGIN)); 1343335e3713SNeil Armstrong writel_relaxed(hs_end, 1344335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_HSO_END)); 1345335e3713SNeil Armstrong 1346335e3713SNeil Armstrong /* Program Vsync timing for even field */ 1347335e3713SNeil Armstrong if (((de_v_end_odd - 1) + eof_lines + vs_adjust) >= lines_f1) { 1348335e3713SNeil Armstrong vs_bline_evn = (de_v_end_odd - 1) 1349335e3713SNeil Armstrong + eof_lines 1350335e3713SNeil Armstrong + vs_adjust 1351335e3713SNeil Armstrong - lines_f1; 1352335e3713SNeil Armstrong vs_eline_evn = vs_bline_evn + vsync_lines; 1353335e3713SNeil Armstrong 1354335e3713SNeil Armstrong writel_relaxed(vs_bline_evn, 1355335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN)); 1356335e3713SNeil Armstrong 1357335e3713SNeil Armstrong writel_relaxed(vs_eline_evn, 1358335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_ELINE_EVN)); 1359335e3713SNeil Armstrong 1360335e3713SNeil Armstrong writel_relaxed(hs_begin, 1361335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_EVN)); 1362335e3713SNeil Armstrong writel_relaxed(hs_begin, 1363335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_END_EVN)); 1364335e3713SNeil Armstrong } else { 1365335e3713SNeil Armstrong vs_bline_odd = (de_v_end_odd - 1) 1366335e3713SNeil Armstrong + eof_lines 1367335e3713SNeil Armstrong + vs_adjust; 1368335e3713SNeil Armstrong 1369335e3713SNeil Armstrong writel_relaxed(vs_bline_odd, 1370335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD)); 1371335e3713SNeil Armstrong 1372335e3713SNeil Armstrong writel_relaxed(hs_begin, 1373335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD)); 1374335e3713SNeil Armstrong 1375335e3713SNeil Armstrong if ((vs_bline_odd + vsync_lines) >= lines_f1) { 1376335e3713SNeil Armstrong vs_eline_evn = vs_bline_odd 1377335e3713SNeil Armstrong + vsync_lines 1378335e3713SNeil Armstrong - lines_f1; 1379335e3713SNeil Armstrong 1380335e3713SNeil Armstrong writel_relaxed(vs_eline_evn, priv->io_base 1381335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_ELINE_EVN)); 1382335e3713SNeil Armstrong 1383335e3713SNeil Armstrong writel_relaxed(hs_begin, priv->io_base 1384335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_END_EVN)); 1385335e3713SNeil Armstrong } else { 1386335e3713SNeil Armstrong vs_eline_odd = vs_bline_odd 1387335e3713SNeil Armstrong + vsync_lines; 1388335e3713SNeil Armstrong 1389335e3713SNeil Armstrong writel_relaxed(vs_eline_odd, priv->io_base 1390335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_ELINE_ODD)); 1391335e3713SNeil Armstrong 1392335e3713SNeil Armstrong writel_relaxed(hs_begin, priv->io_base 1393335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_END_ODD)); 1394335e3713SNeil Armstrong } 1395335e3713SNeil Armstrong } 1396335e3713SNeil Armstrong 1397335e3713SNeil Armstrong /* Program Vsync timing for odd field */ 1398335e3713SNeil Armstrong if (((de_v_end_even - 1) + (eof_lines + 1)) >= lines_f0) { 1399335e3713SNeil Armstrong vs_bline_odd = (de_v_end_even - 1) 1400335e3713SNeil Armstrong + (eof_lines + 1) 1401335e3713SNeil Armstrong - lines_f0; 1402335e3713SNeil Armstrong vs_eline_odd = vs_bline_odd + vsync_lines; 1403335e3713SNeil Armstrong 1404335e3713SNeil Armstrong writel_relaxed(vs_bline_odd, 1405335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD)); 1406335e3713SNeil Armstrong 1407335e3713SNeil Armstrong writel_relaxed(vs_eline_odd, 1408335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_ELINE_ODD)); 1409335e3713SNeil Armstrong 1410335e3713SNeil Armstrong vso_begin_odd = modulo(hs_begin 1411335e3713SNeil Armstrong + (total_pixels_venc >> 1), 1412335e3713SNeil Armstrong total_pixels_venc); 1413335e3713SNeil Armstrong 1414335e3713SNeil Armstrong writel_relaxed(vso_begin_odd, 1415335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD)); 1416335e3713SNeil Armstrong writel_relaxed(vso_begin_odd, 1417335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_END_ODD)); 1418335e3713SNeil Armstrong } else { 1419335e3713SNeil Armstrong vs_bline_evn = (de_v_end_even - 1) 1420335e3713SNeil Armstrong + (eof_lines + 1); 1421335e3713SNeil Armstrong 1422335e3713SNeil Armstrong writel_relaxed(vs_bline_evn, 1423335e3713SNeil Armstrong priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN)); 1424335e3713SNeil Armstrong 1425335e3713SNeil Armstrong vso_begin_evn = modulo(hs_begin 1426335e3713SNeil Armstrong + (total_pixels_venc >> 1), 1427335e3713SNeil Armstrong total_pixels_venc); 1428335e3713SNeil Armstrong 1429335e3713SNeil Armstrong writel_relaxed(vso_begin_evn, priv->io_base 1430335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_BEGIN_EVN)); 1431335e3713SNeil Armstrong 1432335e3713SNeil Armstrong if (vs_bline_evn + vsync_lines >= lines_f0) { 1433335e3713SNeil Armstrong vs_eline_odd = vs_bline_evn 1434335e3713SNeil Armstrong + vsync_lines 1435335e3713SNeil Armstrong - lines_f0; 1436335e3713SNeil Armstrong 1437335e3713SNeil Armstrong writel_relaxed(vs_eline_odd, priv->io_base 1438335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_ELINE_ODD)); 1439335e3713SNeil Armstrong 1440335e3713SNeil Armstrong writel_relaxed(vso_begin_evn, priv->io_base 1441335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_END_ODD)); 1442335e3713SNeil Armstrong } else { 1443335e3713SNeil Armstrong vs_eline_evn = vs_bline_evn + vsync_lines; 1444335e3713SNeil Armstrong 1445335e3713SNeil Armstrong writel_relaxed(vs_eline_evn, priv->io_base 1446335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_ELINE_EVN)); 1447335e3713SNeil Armstrong 1448335e3713SNeil Armstrong writel_relaxed(vso_begin_evn, priv->io_base 1449335e3713SNeil Armstrong + _REG(ENCI_DVI_VSO_END_EVN)); 1450335e3713SNeil Armstrong } 1451335e3713SNeil Armstrong } 1452335e3713SNeil Armstrong } else { 1453335e3713SNeil Armstrong writel_relaxed(vmode->encp.dvi_settings, 1454335e3713SNeil Armstrong priv->io_base + _REG(VENC_DVI_SETTING)); 1455335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_mode, 1456335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_MODE)); 1457335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_mode_adv, 1458335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_MODE_ADV)); 1459335e3713SNeil Armstrong if (vmode->encp.video_prog_mode_present) 1460335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_prog_mode, 1461335e3713SNeil Armstrong priv->io_base + _REG(VENC_VIDEO_PROG_MODE)); 1462335e3713SNeil Armstrong if (vmode->encp.video_sync_mode_present) 1463335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_sync_mode, 1464335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_SYNC_MODE)); 1465335e3713SNeil Armstrong if (vmode->encp.video_yc_dly_present) 1466335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_yc_dly, 1467335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_YC_DLY)); 1468335e3713SNeil Armstrong if (vmode->encp.video_rgb_ctrl_present) 1469335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_rgb_ctrl, 1470335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_RGB_CTRL)); 1471335e3713SNeil Armstrong if (vmode->encp.video_filt_ctrl_present) 1472335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_filt_ctrl, 1473335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_FILT_CTRL)); 1474335e3713SNeil Armstrong if (vmode->encp.video_ofld_voav_ofst_present) 1475335e3713SNeil Armstrong writel_relaxed(vmode->encp.video_ofld_voav_ofst, 1476335e3713SNeil Armstrong priv->io_base 1477335e3713SNeil Armstrong + _REG(ENCP_VIDEO_OFLD_VOAV_OFST)); 1478335e3713SNeil Armstrong writel_relaxed(vmode->encp.yfp1_htime, 1479335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_YFP1_HTIME)); 1480335e3713SNeil Armstrong writel_relaxed(vmode->encp.yfp2_htime, 1481335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_YFP2_HTIME)); 1482335e3713SNeil Armstrong writel_relaxed(vmode->encp.max_pxcnt, 1483335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_MAX_PXCNT)); 1484335e3713SNeil Armstrong writel_relaxed(vmode->encp.hspuls_begin, 1485335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HSPULS_BEGIN)); 1486335e3713SNeil Armstrong writel_relaxed(vmode->encp.hspuls_end, 1487335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HSPULS_END)); 1488335e3713SNeil Armstrong writel_relaxed(vmode->encp.hspuls_switch, 1489335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HSPULS_SWITCH)); 1490335e3713SNeil Armstrong writel_relaxed(vmode->encp.vspuls_begin, 1491335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSPULS_BEGIN)); 1492335e3713SNeil Armstrong writel_relaxed(vmode->encp.vspuls_end, 1493335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSPULS_END)); 1494335e3713SNeil Armstrong writel_relaxed(vmode->encp.vspuls_bline, 1495335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSPULS_BLINE)); 1496335e3713SNeil Armstrong writel_relaxed(vmode->encp.vspuls_eline, 1497335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSPULS_ELINE)); 1498335e3713SNeil Armstrong if (vmode->encp.eqpuls_begin_present) 1499335e3713SNeil Armstrong writel_relaxed(vmode->encp.eqpuls_begin, 1500335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_EQPULS_BEGIN)); 1501335e3713SNeil Armstrong if (vmode->encp.eqpuls_end_present) 1502335e3713SNeil Armstrong writel_relaxed(vmode->encp.eqpuls_end, 1503335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_EQPULS_END)); 1504335e3713SNeil Armstrong if (vmode->encp.eqpuls_bline_present) 1505335e3713SNeil Armstrong writel_relaxed(vmode->encp.eqpuls_bline, 1506335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_EQPULS_BLINE)); 1507335e3713SNeil Armstrong if (vmode->encp.eqpuls_eline_present) 1508335e3713SNeil Armstrong writel_relaxed(vmode->encp.eqpuls_eline, 1509335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_EQPULS_ELINE)); 1510335e3713SNeil Armstrong writel_relaxed(vmode->encp.havon_begin, 1511335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HAVON_BEGIN)); 1512335e3713SNeil Armstrong writel_relaxed(vmode->encp.havon_end, 1513335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HAVON_END)); 1514335e3713SNeil Armstrong writel_relaxed(vmode->encp.vavon_bline, 1515335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VAVON_BLINE)); 1516335e3713SNeil Armstrong writel_relaxed(vmode->encp.vavon_eline, 1517335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VAVON_ELINE)); 1518335e3713SNeil Armstrong writel_relaxed(vmode->encp.hso_begin, 1519335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HSO_BEGIN)); 1520335e3713SNeil Armstrong writel_relaxed(vmode->encp.hso_end, 1521335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_HSO_END)); 1522335e3713SNeil Armstrong writel_relaxed(vmode->encp.vso_begin, 1523335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSO_BEGIN)); 1524335e3713SNeil Armstrong writel_relaxed(vmode->encp.vso_end, 1525335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSO_END)); 1526335e3713SNeil Armstrong writel_relaxed(vmode->encp.vso_bline, 1527335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSO_BLINE)); 1528335e3713SNeil Armstrong if (vmode->encp.vso_eline_present) 1529335e3713SNeil Armstrong writel_relaxed(vmode->encp.vso_eline, 1530335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_VSO_ELINE)); 1531335e3713SNeil Armstrong if (vmode->encp.sy_val_present) 1532335e3713SNeil Armstrong writel_relaxed(vmode->encp.sy_val, 1533335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_SY_VAL)); 1534335e3713SNeil Armstrong if (vmode->encp.sy2_val_present) 1535335e3713SNeil Armstrong writel_relaxed(vmode->encp.sy2_val, 1536335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_SY2_VAL)); 1537335e3713SNeil Armstrong writel_relaxed(vmode->encp.max_lncnt, 1538335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_MAX_LNCNT)); 1539335e3713SNeil Armstrong 1540335e3713SNeil Armstrong writel_relaxed(1, priv->io_base + _REG(ENCP_VIDEO_EN)); 1541335e3713SNeil Armstrong 1542335e3713SNeil Armstrong /* Set DE signal’s polarity is active high */ 1543335e3713SNeil Armstrong writel_bits_relaxed(BIT(14), BIT(14), 1544335e3713SNeil Armstrong priv->io_base + _REG(ENCP_VIDEO_MODE)); 1545335e3713SNeil Armstrong 1546335e3713SNeil Armstrong /* Program DE timing */ 1547335e3713SNeil Armstrong de_h_begin = modulo(readl_relaxed(priv->io_base + 1548335e3713SNeil Armstrong _REG(ENCP_VIDEO_HAVON_BEGIN)) 1549335e3713SNeil Armstrong + venc_hdmi_latency, 1550335e3713SNeil Armstrong total_pixels_venc); 1551335e3713SNeil Armstrong de_h_end = modulo(de_h_begin + active_pixels_venc, 1552335e3713SNeil Armstrong total_pixels_venc); 1553335e3713SNeil Armstrong 1554335e3713SNeil Armstrong writel_relaxed(de_h_begin, 1555335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_H_BEGIN)); 1556335e3713SNeil Armstrong writel_relaxed(de_h_end, 1557335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_H_END)); 1558335e3713SNeil Armstrong 1559335e3713SNeil Armstrong /* Program DE timing for even field */ 1560335e3713SNeil Armstrong de_v_begin_even = readl_relaxed(priv->io_base 1561335e3713SNeil Armstrong + _REG(ENCP_VIDEO_VAVON_BLINE)); 1562335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1563335e3713SNeil Armstrong de_v_end_even = de_v_begin_even + 1564335e3713SNeil Armstrong (mode->vdisplay / 2); 1565335e3713SNeil Armstrong else 1566335e3713SNeil Armstrong de_v_end_even = de_v_begin_even + mode->vdisplay; 1567335e3713SNeil Armstrong 1568335e3713SNeil Armstrong writel_relaxed(de_v_begin_even, 1569335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_V_BEGIN_EVEN)); 1570335e3713SNeil Armstrong writel_relaxed(de_v_end_even, 1571335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_V_END_EVEN)); 1572335e3713SNeil Armstrong 1573335e3713SNeil Armstrong /* Program DE timing for odd field if needed */ 1574335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) { 1575335e3713SNeil Armstrong unsigned int ofld_voav_ofst = 1576335e3713SNeil Armstrong readl_relaxed(priv->io_base + 1577335e3713SNeil Armstrong _REG(ENCP_VIDEO_OFLD_VOAV_OFST)); 1578335e3713SNeil Armstrong de_v_begin_odd = to_signed((ofld_voav_ofst & 0xf0) >> 4) 1579335e3713SNeil Armstrong + de_v_begin_even 1580335e3713SNeil Armstrong + ((mode->vtotal - 1) / 2); 1581335e3713SNeil Armstrong de_v_end_odd = de_v_begin_odd + (mode->vdisplay / 2); 1582335e3713SNeil Armstrong 1583335e3713SNeil Armstrong writel_relaxed(de_v_begin_odd, 1584335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_V_BEGIN_ODD)); 1585335e3713SNeil Armstrong writel_relaxed(de_v_end_odd, 1586335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DE_V_END_ODD)); 1587335e3713SNeil Armstrong } 1588335e3713SNeil Armstrong 1589335e3713SNeil Armstrong /* Program Hsync timing */ 1590335e3713SNeil Armstrong if ((de_h_end + front_porch_venc) >= total_pixels_venc) { 1591335e3713SNeil Armstrong hs_begin = de_h_end 1592335e3713SNeil Armstrong + front_porch_venc 1593335e3713SNeil Armstrong - total_pixels_venc; 1594335e3713SNeil Armstrong vs_adjust = 1; 1595335e3713SNeil Armstrong } else { 1596335e3713SNeil Armstrong hs_begin = de_h_end 1597335e3713SNeil Armstrong + front_porch_venc; 1598335e3713SNeil Armstrong vs_adjust = 0; 1599335e3713SNeil Armstrong } 1600335e3713SNeil Armstrong 1601335e3713SNeil Armstrong hs_end = modulo(hs_begin + hsync_pixels_venc, 1602335e3713SNeil Armstrong total_pixels_venc); 1603335e3713SNeil Armstrong 1604335e3713SNeil Armstrong writel_relaxed(hs_begin, 1605335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_HSO_BEGIN)); 1606335e3713SNeil Armstrong writel_relaxed(hs_end, 1607335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_HSO_END)); 1608335e3713SNeil Armstrong 1609335e3713SNeil Armstrong /* Program Vsync timing for even field */ 1610335e3713SNeil Armstrong if (de_v_begin_even >= 1611335e3713SNeil Armstrong (sof_lines + vsync_lines + (1 - vs_adjust))) 1612335e3713SNeil Armstrong vs_bline_evn = de_v_begin_even 1613335e3713SNeil Armstrong - sof_lines 1614335e3713SNeil Armstrong - vsync_lines 1615335e3713SNeil Armstrong - (1 - vs_adjust); 1616335e3713SNeil Armstrong else 1617335e3713SNeil Armstrong vs_bline_evn = mode->vtotal 1618335e3713SNeil Armstrong + de_v_begin_even 1619335e3713SNeil Armstrong - sof_lines 1620335e3713SNeil Armstrong - vsync_lines 1621335e3713SNeil Armstrong - (1 - vs_adjust); 1622335e3713SNeil Armstrong 1623335e3713SNeil Armstrong vs_eline_evn = modulo(vs_bline_evn + vsync_lines, 1624335e3713SNeil Armstrong mode->vtotal); 1625335e3713SNeil Armstrong 1626335e3713SNeil Armstrong writel_relaxed(vs_bline_evn, 1627335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_BLINE_EVN)); 1628335e3713SNeil Armstrong writel_relaxed(vs_eline_evn, 1629335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_ELINE_EVN)); 1630335e3713SNeil Armstrong 1631335e3713SNeil Armstrong vso_begin_evn = hs_begin; 1632335e3713SNeil Armstrong writel_relaxed(vso_begin_evn, 1633335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_EVN)); 1634335e3713SNeil Armstrong writel_relaxed(vso_begin_evn, 1635335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_END_EVN)); 1636335e3713SNeil Armstrong 1637335e3713SNeil Armstrong /* Program Vsync timing for odd field if needed */ 1638335e3713SNeil Armstrong if (mode->flags & DRM_MODE_FLAG_INTERLACE) { 1639335e3713SNeil Armstrong vs_bline_odd = (de_v_begin_odd - 1) 1640335e3713SNeil Armstrong - sof_lines 1641335e3713SNeil Armstrong - vsync_lines; 1642335e3713SNeil Armstrong vs_eline_odd = (de_v_begin_odd - 1) 1643335e3713SNeil Armstrong - vsync_lines; 1644335e3713SNeil Armstrong vso_begin_odd = modulo(hs_begin 1645335e3713SNeil Armstrong + (total_pixels_venc >> 1), 1646335e3713SNeil Armstrong total_pixels_venc); 1647335e3713SNeil Armstrong 1648335e3713SNeil Armstrong writel_relaxed(vs_bline_odd, 1649335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_BLINE_ODD)); 1650335e3713SNeil Armstrong writel_relaxed(vs_eline_odd, 1651335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_ELINE_ODD)); 1652335e3713SNeil Armstrong writel_relaxed(vso_begin_odd, 1653335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_ODD)); 1654335e3713SNeil Armstrong writel_relaxed(vso_begin_odd, 1655335e3713SNeil Armstrong priv->io_base + _REG(ENCP_DVI_VSO_END_ODD)); 1656335e3713SNeil Armstrong } 1657335e3713SNeil Armstrong 1658335e3713SNeil Armstrong /* Select ENCP for VIU */ 1659335e3713SNeil Armstrong meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCP); 1660335e3713SNeil Armstrong } 1661335e3713SNeil Armstrong 1662335e3713SNeil Armstrong writel_relaxed((use_enci ? 1 : 2) | 1663335e3713SNeil Armstrong (mode->flags & DRM_MODE_FLAG_PHSYNC ? 1 << 2 : 0) | 1664335e3713SNeil Armstrong (mode->flags & DRM_MODE_FLAG_PVSYNC ? 1 << 3 : 0) | 1665335e3713SNeil Armstrong 4 << 5 | 1666335e3713SNeil Armstrong (venc_repeat ? 1 << 8 : 0) | 1667335e3713SNeil Armstrong (hdmi_repeat ? 1 << 12 : 0), 1668335e3713SNeil Armstrong priv->io_base + _REG(VPU_HDMI_SETTING)); 1669335e3713SNeil Armstrong 1670335e3713SNeil Armstrong priv->venc.hdmi_repeat = hdmi_repeat; 1671335e3713SNeil Armstrong priv->venc.venc_repeat = venc_repeat; 1672335e3713SNeil Armstrong priv->venc.hdmi_use_enci = use_enci; 1673335e3713SNeil Armstrong 1674335e3713SNeil Armstrong priv->venc.current_mode = MESON_VENC_MODE_HDMI; 1675335e3713SNeil Armstrong } 1676335e3713SNeil Armstrong EXPORT_SYMBOL_GPL(meson_venc_hdmi_mode_set); 1677335e3713SNeil Armstrong 1678bbbe775eSNeil Armstrong void meson_venci_cvbs_mode_set(struct meson_drm *priv, 1679bbbe775eSNeil Armstrong struct meson_cvbs_enci_mode *mode) 1680bbbe775eSNeil Armstrong { 1681bbbe775eSNeil Armstrong if (mode->mode_tag == priv->venc.current_mode) 1682bbbe775eSNeil Armstrong return; 1683bbbe775eSNeil Armstrong 1684bbbe775eSNeil Armstrong /* CVBS Filter settings */ 1685bbbe775eSNeil Armstrong writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL)); 1686bbbe775eSNeil Armstrong writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2)); 1687bbbe775eSNeil Armstrong 1688bbbe775eSNeil Armstrong /* Digital Video Select : Interlace, clk27 clk, external */ 1689bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING)); 1690bbbe775eSNeil Armstrong 1691bbbe775eSNeil Armstrong /* Reset Video Mode */ 1692bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE)); 1693bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV)); 1694bbbe775eSNeil Armstrong 1695bbbe775eSNeil Armstrong /* Horizontal sync signal output */ 1696bbbe775eSNeil Armstrong writel_relaxed(mode->hso_begin, 1697bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN)); 1698bbbe775eSNeil Armstrong writel_relaxed(mode->hso_end, 1699bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_SYNC_HSO_END)); 1700bbbe775eSNeil Armstrong 1701bbbe775eSNeil Armstrong /* Vertical Sync lines */ 1702bbbe775eSNeil Armstrong writel_relaxed(mode->vso_even, 1703bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN)); 1704bbbe775eSNeil Armstrong writel_relaxed(mode->vso_odd, 1705bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN)); 1706bbbe775eSNeil Armstrong 1707bbbe775eSNeil Armstrong /* Macrovision max amplitude change */ 1708bbbe775eSNeil Armstrong writel_relaxed(0x8100 + mode->macv_max_amp, 1709bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_MACV_MAX_AMP)); 1710bbbe775eSNeil Armstrong 1711bbbe775eSNeil Armstrong /* Video mode */ 1712bbbe775eSNeil Armstrong writel_relaxed(mode->video_prog_mode, 1713bbbe775eSNeil Armstrong priv->io_base + _REG(VENC_VIDEO_PROG_MODE)); 1714bbbe775eSNeil Armstrong writel_relaxed(mode->video_mode, 1715bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_MODE)); 1716bbbe775eSNeil Armstrong 1717bbbe775eSNeil Armstrong /* Advanced Video Mode : 1718bbbe775eSNeil Armstrong * Demux shifting 0x2 1719bbbe775eSNeil Armstrong * Blank line end at line17/22 1720bbbe775eSNeil Armstrong * High bandwidth Luma Filter 1721bbbe775eSNeil Armstrong * Low bandwidth Chroma Filter 1722bbbe775eSNeil Armstrong * Bypass luma low pass filter 1723bbbe775eSNeil Armstrong * No macrovision on CSYNC 1724bbbe775eSNeil Armstrong */ 1725bbbe775eSNeil Armstrong writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV)); 1726bbbe775eSNeil Armstrong 1727bbbe775eSNeil Armstrong writel(mode->sch_adjust, priv->io_base + _REG(ENCI_VIDEO_SCH)); 1728bbbe775eSNeil Armstrong 1729bbbe775eSNeil Armstrong /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */ 1730bbbe775eSNeil Armstrong writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE)); 1731bbbe775eSNeil Armstrong 1732bbbe775eSNeil Armstrong /* 0x3 Y, C, and Component Y delay */ 1733bbbe775eSNeil Armstrong writel_relaxed(mode->yc_delay, priv->io_base + _REG(ENCI_YC_DELAY)); 1734bbbe775eSNeil Armstrong 1735bbbe775eSNeil Armstrong /* Timings */ 1736bbbe775eSNeil Armstrong writel_relaxed(mode->pixel_start, 1737bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START)); 1738bbbe775eSNeil Armstrong writel_relaxed(mode->pixel_end, 1739bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END)); 1740bbbe775eSNeil Armstrong 1741bbbe775eSNeil Armstrong writel_relaxed(mode->top_field_line_start, 1742bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START)); 1743bbbe775eSNeil Armstrong writel_relaxed(mode->top_field_line_end, 1744bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END)); 1745bbbe775eSNeil Armstrong 1746bbbe775eSNeil Armstrong writel_relaxed(mode->bottom_field_line_start, 1747bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START)); 1748bbbe775eSNeil Armstrong writel_relaxed(mode->bottom_field_line_end, 1749bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END)); 1750bbbe775eSNeil Armstrong 1751bbbe775eSNeil Armstrong /* Internal Venc, Internal VIU Sync, Internal Vencoder */ 1752bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_SYNC_ROUTE)); 1753bbbe775eSNeil Armstrong 1754bbbe775eSNeil Armstrong /* UNreset Interlaced TV Encoder */ 1755bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST)); 1756bbbe775eSNeil Armstrong 1757bbbe775eSNeil Armstrong /* Enable Vfifo2vd, Y_Cb_Y_Cr select */ 1758bbbe775eSNeil Armstrong writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL)); 1759bbbe775eSNeil Armstrong 1760bbbe775eSNeil Armstrong /* Power UP Dacs */ 1761bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_SETTING)); 1762bbbe775eSNeil Armstrong 1763bbbe775eSNeil Armstrong /* Video Upsampling */ 1764bbbe775eSNeil Armstrong writel_relaxed(0x0061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL0)); 1765bbbe775eSNeil Armstrong writel_relaxed(0x4061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL1)); 1766bbbe775eSNeil Armstrong writel_relaxed(0x5061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL2)); 1767bbbe775eSNeil Armstrong 1768bbbe775eSNeil Armstrong /* Select Interlace Y DACs */ 1769bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL0)); 1770bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL1)); 1771bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL2)); 1772bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL3)); 1773bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL4)); 1774bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL5)); 1775bbbe775eSNeil Armstrong 1776bbbe775eSNeil Armstrong /* Select ENCI for VIU */ 1777bbbe775eSNeil Armstrong meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI); 1778bbbe775eSNeil Armstrong 1779bbbe775eSNeil Armstrong /* Enable ENCI FIFO */ 1780bbbe775eSNeil Armstrong writel_relaxed(0x2000, priv->io_base + _REG(VENC_VDAC_FIFO_CTRL)); 1781bbbe775eSNeil Armstrong 1782bbbe775eSNeil Armstrong /* Select ENCI DACs 0, 1, 4, and 5 */ 1783bbbe775eSNeil Armstrong writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_0)); 1784bbbe775eSNeil Armstrong writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_1)); 1785bbbe775eSNeil Armstrong 1786bbbe775eSNeil Armstrong /* Interlace video enable */ 1787bbbe775eSNeil Armstrong writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN)); 1788bbbe775eSNeil Armstrong 1789bbbe775eSNeil Armstrong /* Configure Video Saturation / Contrast / Brightness / Hue */ 1790bbbe775eSNeil Armstrong writel_relaxed(mode->video_saturation, 1791bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_SAT)); 1792bbbe775eSNeil Armstrong writel_relaxed(mode->video_contrast, 1793bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_CONT)); 1794bbbe775eSNeil Armstrong writel_relaxed(mode->video_brightness, 1795bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_BRIGHT)); 1796bbbe775eSNeil Armstrong writel_relaxed(mode->video_hue, 1797bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_VIDEO_HUE)); 1798bbbe775eSNeil Armstrong 1799bbbe775eSNeil Armstrong /* Enable DAC0 Filter */ 1800bbbe775eSNeil Armstrong writel_relaxed(0x1, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL0)); 1801bbbe775eSNeil Armstrong writel_relaxed(0xfc48, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL1)); 1802bbbe775eSNeil Armstrong 1803bbbe775eSNeil Armstrong /* 0 in Macrovision register 0 */ 1804bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_MACV_N0)); 1805bbbe775eSNeil Armstrong 1806bbbe775eSNeil Armstrong /* Analog Synchronization and color burst value adjust */ 1807bbbe775eSNeil Armstrong writel_relaxed(mode->analog_sync_adj, 1808bbbe775eSNeil Armstrong priv->io_base + _REG(ENCI_SYNC_ADJ)); 1809bbbe775eSNeil Armstrong 1810bbbe775eSNeil Armstrong priv->venc.current_mode = mode->mode_tag; 1811bbbe775eSNeil Armstrong } 1812bbbe775eSNeil Armstrong 1813bbbe775eSNeil Armstrong /* Returns the current ENCI field polarity */ 1814bbbe775eSNeil Armstrong unsigned int meson_venci_get_field(struct meson_drm *priv) 1815bbbe775eSNeil Armstrong { 1816bbbe775eSNeil Armstrong return readl_relaxed(priv->io_base + _REG(ENCI_INFO_READ)) & BIT(29); 1817bbbe775eSNeil Armstrong } 1818bbbe775eSNeil Armstrong 1819bbbe775eSNeil Armstrong void meson_venc_enable_vsync(struct meson_drm *priv) 1820bbbe775eSNeil Armstrong { 1821bbbe775eSNeil Armstrong writel_relaxed(2, priv->io_base + _REG(VENC_INTCTRL)); 1822bbbe775eSNeil Armstrong } 1823bbbe775eSNeil Armstrong 1824bbbe775eSNeil Armstrong void meson_venc_disable_vsync(struct meson_drm *priv) 1825bbbe775eSNeil Armstrong { 1826bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(VENC_INTCTRL)); 1827bbbe775eSNeil Armstrong } 1828bbbe775eSNeil Armstrong 1829bbbe775eSNeil Armstrong void meson_venc_init(struct meson_drm *priv) 1830bbbe775eSNeil Armstrong { 18310c931a29SNeil Armstrong /* Disable CVBS VDAC */ 18320c931a29SNeil Armstrong regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0); 18330c931a29SNeil Armstrong regmap_write(priv->hhi, HHI_VDAC_CNTL1, 8); 18340c931a29SNeil Armstrong 18350c931a29SNeil Armstrong /* Power Down Dacs */ 18360c931a29SNeil Armstrong writel_relaxed(0xff, priv->io_base + _REG(VENC_VDAC_SETTING)); 18370c931a29SNeil Armstrong 18380c931a29SNeil Armstrong /* Disable HDMI PHY */ 18390c931a29SNeil Armstrong regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0); 18400c931a29SNeil Armstrong 18410c931a29SNeil Armstrong /* Disable HDMI */ 18420c931a29SNeil Armstrong writel_bits_relaxed(0x3, 0, 18430c931a29SNeil Armstrong priv->io_base + _REG(VPU_HDMI_SETTING)); 18440c931a29SNeil Armstrong 1845bbbe775eSNeil Armstrong /* Disable all encoders */ 1846bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN)); 1847bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN)); 1848bbbe775eSNeil Armstrong writel_relaxed(0, priv->io_base + _REG(ENCL_VIDEO_EN)); 1849bbbe775eSNeil Armstrong 1850bbbe775eSNeil Armstrong /* Disable VSync IRQ */ 1851bbbe775eSNeil Armstrong meson_venc_disable_vsync(priv); 1852bbbe775eSNeil Armstrong 1853bbbe775eSNeil Armstrong priv->venc.current_mode = MESON_VENC_MODE_NONE; 1854bbbe775eSNeil Armstrong } 1855