~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-nouveau/trusty

« back to all changes in this revision

Viewing changes to src/nv_crtc.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-02-05 00:21:35 UTC
  • mfrom: (1.1.3 upstream) (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090205002135-wjjfsjsda0rz6w0d
Tags: 1:0.0.10~git+20090205+4dfd0b1-1
* New upstream snapshot (Closes: #514080)
  - 4dfd0b1... oops
  - e02813a... link against libdrm_nouveau (installed with libdrm)
  - 2c06308... require drm 0.0.12
  - 29aa134... fix NoAccel from when map/unmap became stricter
  - 62adc55... Revert "Improve the NoAccel situation, but it's not working 
    yet."
  - 285027a... Improve the NoAccel situation, but it's not working yet.
  - 5e63c78... Revert "nv50: make entire offscreen area tiled, use extra 
    blits to scanout buffer"
  - 6c3f8da... nv50: make entire offscreen area tiled, use extra blits to 
    scanout buffer
  - 6179102... nv10: use the correct 3d object on NV1A
  - dfd87ec... xv: Unmap filter table BO after init so it can be validated 
    (nv30,40)
  - b8de749... Avoid any risk of parsing oscillation on if_is_24bit
  - 0a0bb72... Split up parsing the bit structure, complain when necessary 
    tables are missing
  - 2d86018... Swap the order of calling parse_fp_mode_table and 
    parse_lvds_manufacturer_table
  - 8c6b3a8... Make calling of init bios functions common
  - 9b32034... Don't read obviously useless bios images, and drop 5x 
    reading on PROM
  - 63aa210... Implement bios I2C opcode 4E (untested)
  - a81f159... Handle I2C device 0xff fallback for I2C bios opcodes
  - 34e967e... Fix pasta error in bios opcode 4D
  - 786dd36... Fix nv04+ IFC upload and frag prog upload
  - 3ab65cf... add vm_vram_base field to nouveau_device instead of 
    hardcoding 512MiB
  - d833c81... nv50/xv: previous xv commit was bonged - fix that
  - 0f741eb... exa: small cleanup
  - c10c3c9... exa: mass renaming and movement of nv04 solid/copy code to 
    nv04_exa.c
  - 81ace5d... exa: remove driver pixmaps path that never worked here anyway
  - 4b1829e... exa: remove NVCopyROP table..
  - 410788d... blow up horribly if GPU access to mapped buffer is attempted
  - 4c9346b... bo_del->bo_ref, closer to ng api
  - c533f86... exa: same for UTS state
  - 02677c0... exa: ensure DFS state is updated across flushes
  - 69d02bc... nv50: remove some redundant init, this stuff is done as 
    required now
  - 60aea90... nv50: forgotten buffer access flags during init
  - 5a382dd... nv10/exa: resubmit state in composite as needed
  - d4ff8db... nv30/exa: resubmit state in composite as needed
  - b71ebcb... nv40/exa: resubmit state in composite as necessary
  - 6ddaddb... exa: rework common pre-nv50 code in the same way nv50 code 
    just was
  - f36fa31... nv50/xv: ensure entire frame will fit in pushbuf without 
    causing a flush
  - 1b48331... nv50/exa: ensure buffer usage is tracked correctly
  - 7e64426... remove unconditional FIRE_RING() in DoneComposite() hooks
  - 34fc446... hack a flush_notify() hook in to match ng
  - d9da090... Drop GPU resources on LeaveVT, reaquire on EnterVT
  - 1eb8b87... Enable ShadowFB for DRM-less mode.
  - 4874638... Allow NoAccel operation without the DRM module present.
  - f78aeed... if CARD_INIT ioctl fails, report it instead of continuing
  - cf65b87... Fix stupidity introduced in 
    25de6b867f319099dac05ba84f170da0f0e6c803
  - 55e9cdd... Split out a function for finding the panel power sequencer 
    stuff
  - 1b3546b... Move the bios flat-panel pointers back into the bios struct
  - d29c481... Remove a BITism from BMP parsing path, and move old style 
    BMP init into common path
  - 3e971f6... randr12: lock independent crtc base registers separately 
    (#19620)
  - ffbca72... randr12: code motion and allow ramdac580 setting on nv40
  - 75a0376... randr12: better selection of nv4x single pll mode and some 
    notes
  - 767fcea... randr12: no mmiotrace indication that the blob ever clears 
    these bits
  - 985ac72... randr12: no mmiotrace evidence for nv47 using the special 
    pll bits
  - 3ef6b41... twoStagePLL is actually a description of cards using two PLL 
    regs
  - c7a423a... nv04 blitter: use correct number of dma params for real nv04
  - 25de6b8... Complain more about weird bios images
  - 4d72981... randr12: avoid classic macro error
  - 133c1a5... No need of separate allocation for bios image
  - 8a25049... Make turning on bios execution logging slightly easier
  - 54d43c4... nv50: small fix
  - 5c9f8d3... nv50: Add a fallback for non-repeating XRGB pixmaps.
  - 0321e67... nv50: don't segfault if preinit fails before display setup 
    done
* Don't include .git in .orig.tar.gz.
* Replace "(C)" in debian/copyright with "©" to appease lintian.
* Replace usage of `dh_clean -k` with dh_prep.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
 
120
120
        if (nv_crtc->head) {
121
121
                regp->vpll_a = NVReadRAMDAC(pNv, 0, NV_RAMDAC_VPLL2);
122
 
                if (pNv->twoStagePLL)
 
122
                if (pNv->two_reg_pll)
123
123
                        regp->vpll_b = NVReadRAMDAC(pNv, 0, NV_RAMDAC_VPLL2_B);
124
124
        } else {
125
125
                regp->vpll_a = NVReadRAMDAC(pNv, 0, NV_RAMDAC_VPLL);
126
 
                if (pNv->twoStagePLL)
 
126
                if (pNv->two_reg_pll)
127
127
                        regp->vpll_b = NVReadRAMDAC(pNv, 0, NV_RAMDAC_VPLL_B);
128
128
        }
129
129
        if (pNv->twoHeads)
156
156
 
157
157
        if (nv_crtc->head) {
158
158
                NVWriteRAMDAC(pNv, 0, NV_RAMDAC_VPLL2, regp->vpll_a);
159
 
                if (pNv->twoStagePLL)
 
159
                if (pNv->two_reg_pll)
160
160
                        NVWriteRAMDAC(pNv, 0, NV_RAMDAC_VPLL2_B, regp->vpll_b);
161
161
        } else {
162
162
                NVWriteRAMDAC(pNv, 0, NV_RAMDAC_VPLL, regp->vpll_a);
163
 
                if (pNv->twoStagePLL)
 
163
                if (pNv->two_reg_pll)
164
164
                        NVWriteRAMDAC(pNv, 0, NV_RAMDAC_VPLL_B, regp->vpll_b);
165
165
        }
166
166
 
211
211
        RIVA_HW_STATE *state = &pNv->ModeReg;
212
212
        NVCrtcRegPtr regp = &state->crtc_reg[nv_crtc->head];
213
213
        struct pll_lims pll_lim;
214
 
        int NM1 = 0xbeef, NM2 = 0, log2P = 0, VClk = 0;
 
214
        bool using_two_pll_stages = false;
 
215
        /* nvidia uses 0x11f as bogus data when running in single stage mode */
 
216
        int NM1 = 0xbeef, NM2 = 0x11f, log2P = 0, VClk = 0;
215
217
        uint32_t g70_pll_special_bits = 0;
216
 
        bool nv4x_single_stage_pll_mode = false;
217
218
        uint8_t arbitration0;
218
219
        uint16_t arbitration1;
219
220
 
220
221
        if (get_pll_limits(pScrn, nv_crtc->head ? VPLL2 : VPLL1, &pll_lim))
221
222
                return;
222
223
 
223
 
        if (pNv->twoStagePLL || pNv->NVArch == 0x30 || pNv->NVArch == 0x35) {
224
 
                if (dot_clock < pll_lim.vco1.maxfreq && pNv->NVArch > 0x40) { /* use a single VCO */
225
 
                        nv4x_single_stage_pll_mode = true;
226
 
                        /* Turn the second set of divider and multiplier off */
227
 
                        /* Bogus data, the same nvidia uses */
228
 
                        NM2 = 0x11f;
229
 
                        VClk = getMNP_single(pScrn, &pll_lim, dot_clock, &NM1, &log2P);
230
 
                } else
231
 
                        VClk = getMNP_double(pScrn, &pll_lim, dot_clock, &NM1, &NM2, &log2P);
 
224
        /* for newer nv4x the blob uses only the first stage of the vpll below a
 
225
         * certain clock.  for a certain nv4b this is 150MHz.  since the max
 
226
         * output frequency of the first stage for this card is 300MHz, it is
 
227
         * assumed the threshold is given by vco1 maxfreq/2
 
228
         */
 
229
        /* for early nv4x, specifically nv40 and *some* nv43 (devids 0 and 6,
 
230
         * not 8, others unknown), the blob always uses both plls.  no problem
 
231
         * has yet been observed in allowing the use a single stage pll on all
 
232
         * nv43 however.  the behaviour of single stage use is untested on nv40
 
233
         */
 
234
        if ((pNv->two_reg_pll || pNv->NVArch == 0x30 || pNv->NVArch == 0x35) &&
 
235
            (pNv->NVArch < 0x41 || dot_clock > (pll_lim.vco1.maxfreq / 2))) {
 
236
                using_two_pll_stages = true;
 
237
                VClk = getMNP_double(pScrn, &pll_lim, dot_clock, &NM1, &NM2, &log2P);
232
238
        } else
233
239
                VClk = getMNP_single(pScrn, &pll_lim, dot_clock, &NM1, &log2P);
234
240
 
235
 
        /* Are these all the (relevant) G70 cards? */
236
 
        if (pNv->NVArch == 0x4B || pNv->NVArch == 0x46 || pNv->NVArch == 0x47 || pNv->NVArch == 0x49) {
237
 
                /* This is a big guess, but should be reasonable until we can narrow it down. */
238
 
                /* What exactly are the purpose of the upper 2 bits of pll_a and pll_b? */
239
 
                if (nv4x_single_stage_pll_mode)
240
 
                        g70_pll_special_bits = 0x1;
241
 
                else
242
 
                        g70_pll_special_bits = 0x3;
243
 
        }
 
241
        /* magic bits set by the blob (but not the bios), purpose unknown */
 
242
        if (pNv->NVArch == 0x46 || pNv->NVArch == 0x49 || pNv->NVArch == 0x4b)
 
243
                g70_pll_special_bits = (using_two_pll_stages ? 0xc : 0x4);
244
244
 
245
245
        if (pNv->NVArch == 0x30 || pNv->NVArch == 0x35)
246
246
                /* See nvregisters.xml for details. */
247
247
                regp->vpll_a = (NM2 & (0x18 << 8)) << 13 | (NM2 & (0x7 << 8)) << 11 | log2P << 16 | NV30_RAMDAC_ENABLE_VCO2 | (NM2 & 7) << 4 | NM1;
248
248
        else
249
 
                regp->vpll_a = g70_pll_special_bits << 30 | log2P << 16 | NM1;
 
249
                regp->vpll_a = g70_pll_special_bits << 28 | log2P << 16 | NM1;
250
250
        regp->vpll_b = NV31_RAMDAC_ENABLE_VCO2 | NM2;
251
251
 
252
 
        if (nv4x_single_stage_pll_mode) {
253
 
                if (nv_crtc->head == 0)
254
 
                        state->reg580 |= NV_RAMDAC_580_VPLL1_ACTIVE;
255
 
                else
256
 
                        state->reg580 |= NV_RAMDAC_580_VPLL2_ACTIVE;
257
 
        } else {
258
 
                if (nv_crtc->head == 0)
259
 
                        state->reg580 &= ~NV_RAMDAC_580_VPLL1_ACTIVE;
260
 
                else
261
 
                        state->reg580 &= ~NV_RAMDAC_580_VPLL2_ACTIVE;
262
 
        }
263
 
 
264
 
        /* The NV40 seems to have more similarities to NV3x than other NV4x */
265
 
        if (pNv->NVArch < 0x41)
266
 
                state->pllsel |= NV_RAMDAC_PLL_SELECT_PLL_SOURCE_NVPLL |
267
 
                                 NV_RAMDAC_PLL_SELECT_PLL_SOURCE_MPLL;
268
252
        /* The blob uses this always, so let's do the same */
269
253
        if (pNv->Architecture == NV_ARCH_40)
270
254
                state->pllsel |= NV_RAMDAC_PLL_SELECT_USE_VPLL2_TRUE;
271
255
 
272
 
        if (nv_crtc->head == 1) {
273
 
                if (!nv4x_single_stage_pll_mode)
274
 
                        state->pllsel |= NV_RAMDAC_PLL_SELECT_VCLK2_RATIO_DB2;
275
 
                else
276
 
                        state->pllsel &= ~NV_RAMDAC_PLL_SELECT_VCLK2_RATIO_DB2;
277
 
                state->pllsel |= NV_RAMDAC_PLL_SELECT_PLL_SOURCE_VPLL2;
278
 
        } else {
279
 
                if (!nv4x_single_stage_pll_mode)
280
 
                        state->pllsel |= NV_RAMDAC_PLL_SELECT_VCLK_RATIO_DB2;
281
 
                else
282
 
                        state->pllsel &= ~NV_RAMDAC_PLL_SELECT_VCLK_RATIO_DB2;
283
 
                state->pllsel |= NV_RAMDAC_PLL_SELECT_PLL_SOURCE_VPLL;
 
256
        /* again nv40 and some nv43 act more like nv3x as described above */
 
257
        if (pNv->NVArch < 0x41)
 
258
                state->pllsel |= NV_RAMDAC_PLL_SELECT_PLL_SOURCE_MPLL |
 
259
                                 NV_RAMDAC_PLL_SELECT_PLL_SOURCE_NVPLL;
 
260
 
 
261
        state->pllsel |= (nv_crtc->head ? NV_RAMDAC_PLL_SELECT_PLL_SOURCE_VPLL2 |
 
262
                                          NV_RAMDAC_PLL_SELECT_VCLK2_RATIO_DB2 :
 
263
                                          NV_RAMDAC_PLL_SELECT_PLL_SOURCE_VPLL |
 
264
                                          NV_RAMDAC_PLL_SELECT_VCLK_RATIO_DB2);
 
265
 
 
266
        if (pNv->NVArch >= 0x40) {
 
267
                if (using_two_pll_stages)
 
268
                        state->reg580 &= (nv_crtc->head ? ~NV_RAMDAC_580_VPLL2_ACTIVE :
 
269
                                                          ~NV_RAMDAC_580_VPLL1_ACTIVE);
 
270
                else
 
271
                        state->reg580 |= (nv_crtc->head ? NV_RAMDAC_580_VPLL2_ACTIVE :
 
272
                                                          NV_RAMDAC_580_VPLL1_ACTIVE);
284
273
        }
285
274
 
286
 
        if ((!pNv->twoStagePLL && pNv->NVArch != 0x30 && pNv->NVArch != 0x35) || nv4x_single_stage_pll_mode)
 
275
        if (using_two_pll_stages)
 
276
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", NM1 >> 8, NM2 >> 8, NM1 & 0xff, NM2 & 0xff, log2P);
 
277
        else
287
278
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "vpll: n %d m %d log2p %d\n", NM1 >> 8, NM1 & 0xff, log2P);
288
 
        else
289
 
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", NM1 >> 8, NM2 >> 8, NM1 & 0xff, NM2 & 0xff, log2P);
290
279
 
291
280
        if (pNv->Architecture < NV_ARCH_30)
292
281
                nv4_10UpdateArbitrationSettings(pScrn, VClk, pScrn->bitsPerPixel, &arbitration0, &arbitration1);
1337
1326
        for (i = 0; i < 5; i++)
1338
1327
                NVWriteVgaSeq(pNv, nv_crtc->head, i, regp->Sequencer[i]);
1339
1328
 
 
1329
        nv_lock_vga_crtc_base(pNv, nv_crtc->head, false);
1340
1330
        for (i = 0; i < 25; i++)
1341
1331
                crtc_wr_cio_state(crtc, regp, i);
 
1332
        nv_lock_vga_crtc_base(pNv, nv_crtc->head, true);
1342
1333
 
1343
1334
        for (i = 0; i < 9; i++)
1344
1335
                NVWriteVgaGr(pNv, nv_crtc->head, i, regp->Graphics[i]);