r200.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include <drm/drmP.h>
  29. #include <drm/radeon_drm.h>
  30. #include "radeon_reg.h"
  31. #include "radeon.h"
  32. #include "radeon_asic.h"
  33. #include "r100d.h"
  34. #include "r200_reg_safe.h"
  35. #include "r100_track.h"
  36. static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)
  37. {
  38. int vtx_size, i;
  39. vtx_size = 2;
  40. if (vtx_fmt_0 & R200_VTX_Z0)
  41. vtx_size++;
  42. if (vtx_fmt_0 & R200_VTX_W0)
  43. vtx_size++;
  44. /* blend weight */
  45. if (vtx_fmt_0 & (0x7 << R200_VTX_WEIGHT_COUNT_SHIFT))
  46. vtx_size += (vtx_fmt_0 >> R200_VTX_WEIGHT_COUNT_SHIFT) & 0x7;
  47. if (vtx_fmt_0 & R200_VTX_PV_MATRIX_SEL)
  48. vtx_size++;
  49. if (vtx_fmt_0 & R200_VTX_N0)
  50. vtx_size += 3;
  51. if (vtx_fmt_0 & R200_VTX_POINT_SIZE)
  52. vtx_size++;
  53. if (vtx_fmt_0 & R200_VTX_DISCRETE_FOG)
  54. vtx_size++;
  55. if (vtx_fmt_0 & R200_VTX_SHININESS_0)
  56. vtx_size++;
  57. if (vtx_fmt_0 & R200_VTX_SHININESS_1)
  58. vtx_size++;
  59. for (i = 0; i < 8; i++) {
  60. int color_size = (vtx_fmt_0 >> (11 + 2*i)) & 0x3;
  61. switch (color_size) {
  62. case 0: break;
  63. case 1: vtx_size++; break;
  64. case 2: vtx_size += 3; break;
  65. case 3: vtx_size += 4; break;
  66. }
  67. }
  68. if (vtx_fmt_0 & R200_VTX_XY1)
  69. vtx_size += 2;
  70. if (vtx_fmt_0 & R200_VTX_Z1)
  71. vtx_size++;
  72. if (vtx_fmt_0 & R200_VTX_W1)
  73. vtx_size++;
  74. if (vtx_fmt_0 & R200_VTX_N1)
  75. vtx_size += 3;
  76. return vtx_size;
  77. }
  78. struct radeon_fence *r200_copy_dma(struct radeon_device *rdev,
  79. uint64_t src_offset,
  80. uint64_t dst_offset,
  81. unsigned num_gpu_pages,
  82. struct reservation_object *resv)
  83. {
  84. struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
  85. struct radeon_fence *fence;
  86. uint32_t size;
  87. uint32_t cur_size;
  88. int i, num_loops;
  89. int r = 0;
  90. /* radeon pitch is /64 */
  91. size = num_gpu_pages << RADEON_GPU_PAGE_SHIFT;
  92. num_loops = DIV_ROUND_UP(size, 0x1FFFFF);
  93. r = radeon_ring_lock(rdev, ring, num_loops * 4 + 64);
  94. if (r) {
  95. DRM_ERROR("radeon: moving bo (%d).\n", r);
  96. return ERR_PTR(r);
  97. }
  98. /* Must wait for 2D idle & clean before DMA or hangs might happen */
  99. radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0));
  100. radeon_ring_write(ring, (1 << 16));
  101. for (i = 0; i < num_loops; i++) {
  102. cur_size = size;
  103. if (cur_size > 0x1FFFFF) {
  104. cur_size = 0x1FFFFF;
  105. }
  106. size -= cur_size;
  107. radeon_ring_write(ring, PACKET0(0x720, 2));
  108. radeon_ring_write(ring, src_offset);
  109. radeon_ring_write(ring, dst_offset);
  110. radeon_ring_write(ring, cur_size | (1 << 31) | (1 << 30));
  111. src_offset += cur_size;
  112. dst_offset += cur_size;
  113. }
  114. radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0));
  115. radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE);
  116. r = radeon_fence_emit(rdev, &fence, RADEON_RING_TYPE_GFX_INDEX);
  117. if (r) {
  118. radeon_ring_unlock_undo(rdev, ring);
  119. return ERR_PTR(r);
  120. }
  121. radeon_ring_unlock_commit(rdev, ring, false);
  122. return fence;
  123. }
  124. static int r200_get_vtx_size_1(uint32_t vtx_fmt_1)
  125. {
  126. int vtx_size, i, tex_size;
  127. vtx_size = 0;
  128. for (i = 0; i < 6; i++) {
  129. tex_size = (vtx_fmt_1 >> (i * 3)) & 0x7;
  130. if (tex_size > 4)
  131. continue;
  132. vtx_size += tex_size;
  133. }
  134. return vtx_size;
  135. }
  136. int r200_packet0_check(struct radeon_cs_parser *p,
  137. struct radeon_cs_packet *pkt,
  138. unsigned idx, unsigned reg)
  139. {
  140. struct radeon_bo_list *reloc;
  141. struct r100_cs_track *track;
  142. volatile uint32_t *ib;
  143. uint32_t tmp;
  144. int r;
  145. int i;
  146. int face;
  147. u32 tile_flags = 0;
  148. u32 idx_value;
  149. ib = p->ib.ptr;
  150. track = (struct r100_cs_track *)p->track;
  151. idx_value = radeon_get_ib_value(p, idx);
  152. switch (reg) {
  153. case RADEON_CRTC_GUI_TRIG_VLINE:
  154. r = r100_cs_packet_parse_vline(p);
  155. if (r) {
  156. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  157. idx, reg);
  158. radeon_cs_dump_packet(p, pkt);
  159. return r;
  160. }
  161. break;
  162. /* FIXME: only allow PACKET3 blit? easier to check for out of
  163. * range access */
  164. case RADEON_DST_PITCH_OFFSET:
  165. case RADEON_SRC_PITCH_OFFSET:
  166. r = r100_reloc_pitch_offset(p, pkt, idx, reg);
  167. if (r)
  168. return r;
  169. break;
  170. case RADEON_RB3D_DEPTHOFFSET:
  171. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  172. if (r) {
  173. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  174. idx, reg);
  175. radeon_cs_dump_packet(p, pkt);
  176. return r;
  177. }
  178. track->zb.robj = reloc->robj;
  179. track->zb.offset = idx_value;
  180. track->zb_dirty = true;
  181. ib[idx] = idx_value + ((u32)reloc->gpu_offset);
  182. break;
  183. case RADEON_RB3D_COLOROFFSET:
  184. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  185. if (r) {
  186. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  187. idx, reg);
  188. radeon_cs_dump_packet(p, pkt);
  189. return r;
  190. }
  191. track->cb[0].robj = reloc->robj;
  192. track->cb[0].offset = idx_value;
  193. track->cb_dirty = true;
  194. ib[idx] = idx_value + ((u32)reloc->gpu_offset);
  195. break;
  196. case R200_PP_TXOFFSET_0:
  197. case R200_PP_TXOFFSET_1:
  198. case R200_PP_TXOFFSET_2:
  199. case R200_PP_TXOFFSET_3:
  200. case R200_PP_TXOFFSET_4:
  201. case R200_PP_TXOFFSET_5:
  202. i = (reg - R200_PP_TXOFFSET_0) / 24;
  203. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  204. if (r) {
  205. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  206. idx, reg);
  207. radeon_cs_dump_packet(p, pkt);
  208. return r;
  209. }
  210. if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) {
  211. if (reloc->tiling_flags & RADEON_TILING_MACRO)
  212. tile_flags |= R200_TXO_MACRO_TILE;
  213. if (reloc->tiling_flags & RADEON_TILING_MICRO)
  214. tile_flags |= R200_TXO_MICRO_TILE;
  215. tmp = idx_value & ~(0x7 << 2);
  216. tmp |= tile_flags;
  217. ib[idx] = tmp + ((u32)reloc->gpu_offset);
  218. } else
  219. ib[idx] = idx_value + ((u32)reloc->gpu_offset);
  220. track->textures[i].robj = reloc->robj;
  221. track->tex_dirty = true;
  222. break;
  223. case R200_PP_CUBIC_OFFSET_F1_0:
  224. case R200_PP_CUBIC_OFFSET_F2_0:
  225. case R200_PP_CUBIC_OFFSET_F3_0:
  226. case R200_PP_CUBIC_OFFSET_F4_0:
  227. case R200_PP_CUBIC_OFFSET_F5_0:
  228. case R200_PP_CUBIC_OFFSET_F1_1:
  229. case R200_PP_CUBIC_OFFSET_F2_1:
  230. case R200_PP_CUBIC_OFFSET_F3_1:
  231. case R200_PP_CUBIC_OFFSET_F4_1:
  232. case R200_PP_CUBIC_OFFSET_F5_1:
  233. case R200_PP_CUBIC_OFFSET_F1_2:
  234. case R200_PP_CUBIC_OFFSET_F2_2:
  235. case R200_PP_CUBIC_OFFSET_F3_2:
  236. case R200_PP_CUBIC_OFFSET_F4_2:
  237. case R200_PP_CUBIC_OFFSET_F5_2:
  238. case R200_PP_CUBIC_OFFSET_F1_3:
  239. case R200_PP_CUBIC_OFFSET_F2_3:
  240. case R200_PP_CUBIC_OFFSET_F3_3:
  241. case R200_PP_CUBIC_OFFSET_F4_3:
  242. case R200_PP_CUBIC_OFFSET_F5_3:
  243. case R200_PP_CUBIC_OFFSET_F1_4:
  244. case R200_PP_CUBIC_OFFSET_F2_4:
  245. case R200_PP_CUBIC_OFFSET_F3_4:
  246. case R200_PP_CUBIC_OFFSET_F4_4:
  247. case R200_PP_CUBIC_OFFSET_F5_4:
  248. case R200_PP_CUBIC_OFFSET_F1_5:
  249. case R200_PP_CUBIC_OFFSET_F2_5:
  250. case R200_PP_CUBIC_OFFSET_F3_5:
  251. case R200_PP_CUBIC_OFFSET_F4_5:
  252. case R200_PP_CUBIC_OFFSET_F5_5:
  253. i = (reg - R200_PP_TXOFFSET_0) / 24;
  254. face = (reg - ((i * 24) + R200_PP_TXOFFSET_0)) / 4;
  255. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  256. if (r) {
  257. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  258. idx, reg);
  259. radeon_cs_dump_packet(p, pkt);
  260. return r;
  261. }
  262. track->textures[i].cube_info[face - 1].offset = idx_value;
  263. ib[idx] = idx_value + ((u32)reloc->gpu_offset);
  264. track->textures[i].cube_info[face - 1].robj = reloc->robj;
  265. track->tex_dirty = true;
  266. break;
  267. case RADEON_RE_WIDTH_HEIGHT:
  268. track->maxy = ((idx_value >> 16) & 0x7FF);
  269. track->cb_dirty = true;
  270. track->zb_dirty = true;
  271. break;
  272. case RADEON_RB3D_COLORPITCH:
  273. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  274. if (r) {
  275. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  276. idx, reg);
  277. radeon_cs_dump_packet(p, pkt);
  278. return r;
  279. }
  280. if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) {
  281. if (reloc->tiling_flags & RADEON_TILING_MACRO)
  282. tile_flags |= RADEON_COLOR_TILE_ENABLE;
  283. if (reloc->tiling_flags & RADEON_TILING_MICRO)
  284. tile_flags |= RADEON_COLOR_MICROTILE_ENABLE;
  285. tmp = idx_value & ~(0x7 << 16);
  286. tmp |= tile_flags;
  287. ib[idx] = tmp;
  288. } else
  289. ib[idx] = idx_value;
  290. track->cb[0].pitch = idx_value & RADEON_COLORPITCH_MASK;
  291. track->cb_dirty = true;
  292. break;
  293. case RADEON_RB3D_DEPTHPITCH:
  294. track->zb.pitch = idx_value & RADEON_DEPTHPITCH_MASK;
  295. track->zb_dirty = true;
  296. break;
  297. case RADEON_RB3D_CNTL:
  298. switch ((idx_value >> RADEON_RB3D_COLOR_FORMAT_SHIFT) & 0x1f) {
  299. case 7:
  300. case 8:
  301. case 9:
  302. case 11:
  303. case 12:
  304. track->cb[0].cpp = 1;
  305. break;
  306. case 3:
  307. case 4:
  308. case 15:
  309. track->cb[0].cpp = 2;
  310. break;
  311. case 6:
  312. track->cb[0].cpp = 4;
  313. break;
  314. default:
  315. DRM_ERROR("Invalid color buffer format (%d) !\n",
  316. ((idx_value >> RADEON_RB3D_COLOR_FORMAT_SHIFT) & 0x1f));
  317. return -EINVAL;
  318. }
  319. if (idx_value & RADEON_DEPTHXY_OFFSET_ENABLE) {
  320. DRM_ERROR("No support for depth xy offset in kms\n");
  321. return -EINVAL;
  322. }
  323. track->z_enabled = !!(idx_value & RADEON_Z_ENABLE);
  324. track->cb_dirty = true;
  325. track->zb_dirty = true;
  326. break;
  327. case RADEON_RB3D_ZSTENCILCNTL:
  328. switch (idx_value & 0xf) {
  329. case 0:
  330. track->zb.cpp = 2;
  331. break;
  332. case 2:
  333. case 3:
  334. case 4:
  335. case 5:
  336. case 9:
  337. case 11:
  338. track->zb.cpp = 4;
  339. break;
  340. default:
  341. break;
  342. }
  343. track->zb_dirty = true;
  344. break;
  345. case RADEON_RB3D_ZPASS_ADDR:
  346. r = radeon_cs_packet_next_reloc(p, &reloc, 0);
  347. if (r) {
  348. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  349. idx, reg);
  350. radeon_cs_dump_packet(p, pkt);
  351. return r;
  352. }
  353. ib[idx] = idx_value + ((u32)reloc->gpu_offset);
  354. break;
  355. case RADEON_PP_CNTL:
  356. {
  357. uint32_t temp = idx_value >> 4;
  358. for (i = 0; i < track->num_texture; i++)
  359. track->textures[i].enabled = !!(temp & (1 << i));
  360. track->tex_dirty = true;
  361. }
  362. break;
  363. case RADEON_SE_VF_CNTL:
  364. track->vap_vf_cntl = idx_value;
  365. break;
  366. case 0x210c:
  367. /* VAP_VF_MAX_VTX_INDX */
  368. track->max_indx = idx_value & 0x00FFFFFFUL;
  369. break;
  370. case R200_SE_VTX_FMT_0:
  371. track->vtx_size = r200_get_vtx_size_0(idx_value);
  372. break;
  373. case R200_SE_VTX_FMT_1:
  374. track->vtx_size += r200_get_vtx_size_1(idx_value);
  375. break;
  376. case R200_PP_TXSIZE_0:
  377. case R200_PP_TXSIZE_1:
  378. case R200_PP_TXSIZE_2:
  379. case R200_PP_TXSIZE_3:
  380. case R200_PP_TXSIZE_4:
  381. case R200_PP_TXSIZE_5:
  382. i = (reg - R200_PP_TXSIZE_0) / 32;
  383. track->textures[i].width = (idx_value & RADEON_TEX_USIZE_MASK) + 1;
  384. track->textures[i].height = ((idx_value & RADEON_TEX_VSIZE_MASK) >> RADEON_TEX_VSIZE_SHIFT) + 1;
  385. track->tex_dirty = true;
  386. break;
  387. case R200_PP_TXPITCH_0:
  388. case R200_PP_TXPITCH_1:
  389. case R200_PP_TXPITCH_2:
  390. case R200_PP_TXPITCH_3:
  391. case R200_PP_TXPITCH_4:
  392. case R200_PP_TXPITCH_5:
  393. i = (reg - R200_PP_TXPITCH_0) / 32;
  394. track->textures[i].pitch = idx_value + 32;
  395. track->tex_dirty = true;
  396. break;
  397. case R200_PP_TXFILTER_0:
  398. case R200_PP_TXFILTER_1:
  399. case R200_PP_TXFILTER_2:
  400. case R200_PP_TXFILTER_3:
  401. case R200_PP_TXFILTER_4:
  402. case R200_PP_TXFILTER_5:
  403. i = (reg - R200_PP_TXFILTER_0) / 32;
  404. track->textures[i].num_levels = ((idx_value & R200_MAX_MIP_LEVEL_MASK)
  405. >> R200_MAX_MIP_LEVEL_SHIFT);
  406. tmp = (idx_value >> 23) & 0x7;
  407. if (tmp == 2 || tmp == 6)
  408. track->textures[i].roundup_w = false;
  409. tmp = (idx_value >> 27) & 0x7;
  410. if (tmp == 2 || tmp == 6)
  411. track->textures[i].roundup_h = false;
  412. track->tex_dirty = true;
  413. break;
  414. case R200_PP_TXMULTI_CTL_0:
  415. case R200_PP_TXMULTI_CTL_1:
  416. case R200_PP_TXMULTI_CTL_2:
  417. case R200_PP_TXMULTI_CTL_3:
  418. case R200_PP_TXMULTI_CTL_4:
  419. case R200_PP_TXMULTI_CTL_5:
  420. i = (reg - R200_PP_TXMULTI_CTL_0) / 32;
  421. break;
  422. case R200_PP_TXFORMAT_X_0:
  423. case R200_PP_TXFORMAT_X_1:
  424. case R200_PP_TXFORMAT_X_2:
  425. case R200_PP_TXFORMAT_X_3:
  426. case R200_PP_TXFORMAT_X_4:
  427. case R200_PP_TXFORMAT_X_5:
  428. i = (reg - R200_PP_TXFORMAT_X_0) / 32;
  429. track->textures[i].txdepth = idx_value & 0x7;
  430. tmp = (idx_value >> 16) & 0x3;
  431. /* 2D, 3D, CUBE */
  432. switch (tmp) {
  433. case 0:
  434. case 3:
  435. case 4:
  436. case 5:
  437. case 6:
  438. case 7:
  439. /* 1D/2D */
  440. track->textures[i].tex_coord_type = 0;
  441. break;
  442. case 1:
  443. /* CUBE */
  444. track->textures[i].tex_coord_type = 2;
  445. break;
  446. case 2:
  447. /* 3D */
  448. track->textures[i].tex_coord_type = 1;
  449. break;
  450. }
  451. track->tex_dirty = true;
  452. break;
  453. case R200_PP_TXFORMAT_0:
  454. case R200_PP_TXFORMAT_1:
  455. case R200_PP_TXFORMAT_2:
  456. case R200_PP_TXFORMAT_3:
  457. case R200_PP_TXFORMAT_4:
  458. case R200_PP_TXFORMAT_5:
  459. i = (reg - R200_PP_TXFORMAT_0) / 32;
  460. if (idx_value & R200_TXFORMAT_NON_POWER2) {
  461. track->textures[i].use_pitch = 1;
  462. } else {
  463. track->textures[i].use_pitch = 0;
  464. track->textures[i].width = 1 << ((idx_value >> RADEON_TXFORMAT_WIDTH_SHIFT) & RADEON_TXFORMAT_WIDTH_MASK);
  465. track->textures[i].height = 1 << ((idx_value >> RADEON_TXFORMAT_HEIGHT_SHIFT) & RADEON_TXFORMAT_HEIGHT_MASK);
  466. }
  467. if (idx_value & R200_TXFORMAT_LOOKUP_DISABLE)
  468. track->textures[i].lookup_disable = true;
  469. switch ((idx_value & RADEON_TXFORMAT_FORMAT_MASK)) {
  470. case R200_TXFORMAT_I8:
  471. case R200_TXFORMAT_RGB332:
  472. case R200_TXFORMAT_Y8:
  473. track->textures[i].cpp = 1;
  474. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  475. break;
  476. case R200_TXFORMAT_AI88:
  477. case R200_TXFORMAT_ARGB1555:
  478. case R200_TXFORMAT_RGB565:
  479. case R200_TXFORMAT_ARGB4444:
  480. case R200_TXFORMAT_VYUY422:
  481. case R200_TXFORMAT_YVYU422:
  482. case R200_TXFORMAT_LDVDU655:
  483. case R200_TXFORMAT_DVDU88:
  484. case R200_TXFORMAT_AVYU4444:
  485. track->textures[i].cpp = 2;
  486. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  487. break;
  488. case R200_TXFORMAT_ARGB8888:
  489. case R200_TXFORMAT_RGBA8888:
  490. case R200_TXFORMAT_ABGR8888:
  491. case R200_TXFORMAT_BGR111110:
  492. case R200_TXFORMAT_LDVDU8888:
  493. track->textures[i].cpp = 4;
  494. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  495. break;
  496. case R200_TXFORMAT_DXT1:
  497. track->textures[i].cpp = 1;
  498. track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
  499. break;
  500. case R200_TXFORMAT_DXT23:
  501. case R200_TXFORMAT_DXT45:
  502. track->textures[i].cpp = 1;
  503. track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
  504. break;
  505. }
  506. track->textures[i].cube_info[4].width = 1 << ((idx_value >> 16) & 0xf);
  507. track->textures[i].cube_info[4].height = 1 << ((idx_value >> 20) & 0xf);
  508. track->tex_dirty = true;
  509. break;
  510. case R200_PP_CUBIC_FACES_0:
  511. case R200_PP_CUBIC_FACES_1:
  512. case R200_PP_CUBIC_FACES_2:
  513. case R200_PP_CUBIC_FACES_3:
  514. case R200_PP_CUBIC_FACES_4:
  515. case R200_PP_CUBIC_FACES_5:
  516. tmp = idx_value;
  517. i = (reg - R200_PP_CUBIC_FACES_0) / 32;
  518. for (face = 0; face < 4; face++) {
  519. track->textures[i].cube_info[face].width = 1 << ((tmp >> (face * 8)) & 0xf);
  520. track->textures[i].cube_info[face].height = 1 << ((tmp >> ((face * 8) + 4)) & 0xf);
  521. }
  522. track->tex_dirty = true;
  523. break;
  524. default:
  525. printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n",
  526. reg, idx);
  527. return -EINVAL;
  528. }
  529. return 0;
  530. }
  531. void r200_set_safe_registers(struct radeon_device *rdev)
  532. {
  533. rdev->config.r100.reg_safe_bm = r200_reg_safe_bm;
  534. rdev->config.r100.reg_safe_bm_size = ARRAY_SIZE(r200_reg_safe_bm);
  535. }