Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2593 lines
74 KiB

  1. /*++
  2. Copyright (c) 1997 1998 PHILIPS I&C
  3. Module Name: mprpobj.c
  4. Abstract: Property handling module
  5. Author: Michael Verberne
  6. Revision History:
  7. Date Reason
  8. Sept.22, 98 Optimized for NT5
  9. Nov. 30, 98 PID and VID properties added
  10. --*/
  11. #include "mwarn.h"
  12. #include "wdm.h"
  13. #include <strmini.h>
  14. #include <ksmedia.h>
  15. #include "usbdi.h"
  16. #include "usbcamdi.h"
  17. #include "mcamdrv.h"
  18. #include "mssidef.h"
  19. #include "mprpobj.h"
  20. #include "mprpobjx.h"
  21. #include "mprpdef.h"
  22. #include "mprpftn.h"
  23. /*
  24. * defines
  25. */
  26. #define WAIT_FOR_COMPLETION 2000 // timeout value for USB in msec
  27. #define NUM_100NANOSEC_UNITS_PERFRAME(x) ((x > 0) ? ((LONGLONG)10000000 / x) :0 )
  28. /*
  29. * exported data
  30. */
  31. const GUID PROPSETID_PHILIPS_CUSTOM_PROP = {
  32. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP };
  33. const GUID PROPSETID_PHILIPS_FACTORY_PROP = {
  34. STATIC_PROPSETID_PHILIPS_FACTORY_PROP };
  35. /*
  36. * Local data
  37. */
  38. //static PHW_STREAM_REQUEST_BLOCK CurrentpSrb;
  39. LONG Address = 0;
  40. /*
  41. * Local function definitions
  42. */
  43. static NTSTATUS
  44. Get_Brightness(
  45. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  46. PLONG pBrightness);
  47. static NTSTATUS
  48. Set_Brightness(
  49. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  50. LONG Brightness);
  51. static NTSTATUS
  52. Get_Contrast(
  53. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  54. PLONG pContrast);
  55. static NTSTATUS
  56. Set_Contrast(
  57. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  58. LONG Contrast);
  59. static NTSTATUS
  60. Get_Gamma(
  61. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  62. PLONG pGamma);
  63. static NTSTATUS
  64. Set_Gamma(
  65. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  66. LONG Gamma);
  67. static NTSTATUS
  68. Get_ColorEnable(
  69. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  70. PLONG pColorEnable);
  71. static NTSTATUS
  72. Set_ColorEnable(
  73. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  74. LONG ColorEnable);
  75. static NTSTATUS
  76. Get_BackLight_Compensation(
  77. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  78. PLONG pBackLight_Compensation);
  79. static NTSTATUS
  80. Set_BackLight_Compensation(
  81. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  82. LONG BackLight_Compensation);
  83. static NTSTATUS
  84. Get_WB_Mode(
  85. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  86. PLONG pWB_Mode);
  87. static NTSTATUS
  88. Set_WB_Mode(
  89. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  90. LONG WB_Mode);
  91. static NTSTATUS
  92. Get_WB_Speed(
  93. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  94. PLONG pWB_Speed);
  95. static NTSTATUS
  96. Set_WB_Speed(
  97. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  98. LONG WB_Speed);
  99. static NTSTATUS
  100. Get_WB_Delay(
  101. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  102. PLONG pWB_Delay);
  103. static NTSTATUS
  104. Set_WB_Delay(
  105. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  106. LONG WB_Delay);
  107. static NTSTATUS
  108. Get_WB_Red_Gain(
  109. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  110. PLONG pWB_Red_Gain);
  111. static NTSTATUS
  112. Set_WB_Red_Gain(
  113. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  114. LONG WB_Red_Gain);
  115. static NTSTATUS
  116. Get_WB_Blue_Gain(
  117. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  118. PLONG pWB_Blue_Gain);
  119. static NTSTATUS
  120. Set_WB_Blue_Gain(
  121. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  122. LONG WB_Blue_Gain);
  123. static NTSTATUS
  124. Get_AE_Control_Speed(
  125. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  126. PLONG pAE_Control_Speed);
  127. static NTSTATUS
  128. Set_AE_Control_Speed(
  129. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  130. LONG AE_Control_Speed);
  131. static NTSTATUS
  132. Get_AE_Flickerless(
  133. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  134. PLONG pAE_Flickerless);
  135. static NTSTATUS
  136. Set_AE_Flickerless(
  137. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  138. LONG AE_Flickerless);
  139. static NTSTATUS
  140. Get_AE_Shutter_Mode(
  141. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  142. PLONG pAE_Shutter_Mode);
  143. static NTSTATUS
  144. Set_AE_Shutter_Mode(
  145. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  146. LONG AE_Shutter_Mode);
  147. static NTSTATUS
  148. Get_AE_Shutter_Speed(
  149. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  150. PLONG pAE_Shutter_Speed);
  151. static NTSTATUS
  152. Set_AE_Shutter_Speed(
  153. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  154. LONG AE_Shutter_Speed);
  155. static NTSTATUS
  156. Get_AE_Shutter_Status(
  157. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  158. PLONG pAE_Shutter_Status);
  159. static NTSTATUS
  160. Get_AE_AGC_Mode(
  161. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  162. PLONG pAE_AGC_Mode);
  163. static NTSTATUS
  164. Set_AE_AGC_Mode(
  165. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  166. LONG AE_AGC_Mode);
  167. static NTSTATUS
  168. Get_AE_AGC(
  169. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  170. PLONG pAE_AGC);
  171. static NTSTATUS
  172. Set_AE_AGC(
  173. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  174. LONG AE_AGC);
  175. static NTSTATUS
  176. Get_DriverVersion(
  177. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  178. PLONG pDriverVersion);
  179. static NTSTATUS
  180. Get_Framerate(
  181. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  182. PLONG pFramerate);
  183. static NTSTATUS
  184. Set_Framerate(
  185. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  186. LONG Framerate);
  187. static NTSTATUS
  188. Get_Framerates_Supported(
  189. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  190. PLONG pFramerates_Supported);
  191. static NTSTATUS
  192. Get_VideoFormat(
  193. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  194. PLONG pVideoFormat);
  195. static NTSTATUS
  196. Get_SensorType(
  197. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  198. PLONG pSensorType);
  199. static NTSTATUS
  200. Get_VideoCompression(
  201. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  202. PLONG pVideoCompression);
  203. static NTSTATUS
  204. Set_Defaults(
  205. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  206. LONG Command);
  207. static NTSTATUS
  208. Get_Release_Number(
  209. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  210. PLONG pRelease_Number);
  211. static NTSTATUS
  212. Get_Vendor_Id(
  213. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  214. PLONG pVendor_Id);
  215. static NTSTATUS
  216. Get_Product_Id(
  217. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  218. PLONG pProduct_Id);
  219. static NTSTATUS
  220. PHILIPSCAM_Defaults_Restore_User(
  221. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext);
  222. static NTSTATUS
  223. PHILIPSCAM_Defaults_Save_User(
  224. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext);
  225. static NTSTATUS
  226. PHILIPSCAM_Defaults_Restore_Factory(
  227. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext);
  228. static NTSTATUS
  229. Get_RegisterData(
  230. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  231. PLONG pValue);
  232. static NTSTATUS
  233. Set_RegisterAddress(
  234. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  235. LONG AddressToSet);
  236. static NTSTATUS
  237. Set_RegisterData(
  238. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  239. LONG Value);
  240. static NTSTATUS
  241. Set_Factory_Mode(
  242. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  243. LONG Factory_Mode);
  244. static NTSTATUS
  245. PHILIPSCAM_RestoreDriverDefaults(
  246. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext);
  247. static NTSTATUS
  248. PHILPCAM_ControlVendorCommand(
  249. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  250. UCHAR Request,
  251. USHORT Value,
  252. USHORT Index,
  253. PVOID Buffer,
  254. PULONG BufferLength,
  255. BOOLEAN GetData,
  256. PCOMMAND_COMPLETE_FUNCTION CommandComplete,
  257. PVOID CommandContext);
  258. static NTSTATUS Map_Framerate_Drv_to_KS(
  259. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  260. PLONG pFramerate);
  261. static NTSTATUS Map_Framerate_KS_to_Drv(
  262. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  263. LONG Framerate);
  264. static NTSTATUS Map_VideoFormat_Drv_to_KS(
  265. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  266. PLONG pVideoFormat);
  267. static NTSTATUS Map_VideoCompression_Drv_to_KS(
  268. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  269. PLONG pVideoCompression);
  270. //static VOID
  271. //PHILIPSCAM_TimeoutDPC(
  272. // PKDPC Dpc,
  273. // PVOID DeferredContext,
  274. // PVOID SystemArgument1,
  275. // PVOID SystemArgument2
  276. // );
  277. /*
  278. ** PHILIPSCAM_InitPrpObj()
  279. **
  280. ** Arguments:
  281. **
  282. ** DeviceContext - driver context
  283. **
  284. ** Returns:
  285. **
  286. ** Side Effects: none
  287. */
  288. NTSTATUS
  289. PHILIPSCAM_InitPrpObj(
  290. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext
  291. )
  292. {
  293. NTSTATUS status = STATUS_SUCCESS;
  294. // Read defaults from camera, could also be done
  295. // using PHILIPSCAM_RestoreDriverDefaults() but this
  296. // is more save
  297. status = PHILIPSCAM_Defaults_Restore_User(DeviceContext);
  298. return status;
  299. }
  300. /*
  301. ** PHILIPSCAM_GetAdapterPropertyTable()
  302. **
  303. ** Arguments:
  304. **
  305. ** NumberOfPropertySets
  306. **
  307. ** Returns:
  308. **
  309. ** Addres of property table
  310. **
  311. ** Side Effects: none
  312. */
  313. PVOID
  314. PHILIPSCAM_GetAdapterPropertyTable(
  315. PULONG NumberOfPropertySets
  316. )
  317. {
  318. *NumberOfPropertySets = NUMBER_OF_ADAPTER_PROPERTY_SETS;
  319. return (PVOID) AdapterPropertyTable;
  320. }
  321. /*
  322. ** PHILIPSCAM_GetCameraProperty()
  323. **
  324. ** Arguments:
  325. **
  326. ** DeviceContext - driver context
  327. **
  328. ** Returns:
  329. **
  330. ** NT status completion code
  331. **
  332. ** Side Effects: none
  333. */
  334. NTSTATUS
  335. PHILIPSCAM_GetCameraProperty(
  336. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  337. PHW_STREAM_REQUEST_BLOCK pSrb
  338. )
  339. {
  340. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  341. pSrb->CommandData.PropertyInfo;
  342. PKSPROPERTY_VIDEOPROCAMP_S propertyData =
  343. streamPropertyDescr->PropertyInfo;
  344. ULONG flags = propertyData->Flags;
  345. ULONG propertyID = streamPropertyDescr->Property->Id;
  346. NTSTATUS status = STATUS_SUCCESS;
  347. ASSERT(streamPropertyDescr->PropertyOutputSize
  348. >= sizeof(KSPROPERTY_VIDEOPROCAMP_S));
  349. switch(propertyID) {
  350. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  351. status = Get_Brightness(DeviceContext, &propertyData->Value);
  352. break;
  353. case KSPROPERTY_VIDEOPROCAMP_CONTRAST:
  354. status = Get_Contrast(DeviceContext, &propertyData->Value);
  355. break;
  356. case KSPROPERTY_VIDEOPROCAMP_GAMMA:
  357. status = Get_Gamma(DeviceContext, &propertyData->Value);
  358. break;
  359. case KSPROPERTY_VIDEOPROCAMP_COLORENABLE:
  360. status = Get_ColorEnable(DeviceContext, &propertyData->Value);
  361. break;
  362. case KSPROPERTY_VIDEOPROCAMP_BACKLIGHT_COMPENSATION:
  363. status = Get_BackLight_Compensation(DeviceContext, &propertyData->Value);
  364. break;
  365. default:
  366. status = STATUS_NOT_SUPPORTED;
  367. }
  368. if (NT_SUCCESS(status))
  369. {
  370. pSrb->ActualBytesTransferred = sizeof(KSPROPERTY_VIDEOPROCAMP_S);
  371. propertyData->Capabilities = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  372. propertyData->Flags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  373. }
  374. pSrb->Status = status;
  375. return status;
  376. }
  377. /*
  378. ** PHILIPSCAM_SetCameraProperty()
  379. **
  380. ** Arguments:
  381. **
  382. ** DeviceContext - driver context
  383. **
  384. ** Returns:
  385. **
  386. ** NT status completion code
  387. **
  388. ** Side Effects: none
  389. */
  390. NTSTATUS
  391. PHILIPSCAM_SetCameraProperty(
  392. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  393. PHW_STREAM_REQUEST_BLOCK pSrb
  394. )
  395. {
  396. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  397. pSrb->CommandData.PropertyInfo;
  398. PKSPROPERTY_VIDEOPROCAMP_S propertyData =
  399. streamPropertyDescr->PropertyInfo;
  400. ULONG flags = propertyData->Flags;
  401. ULONG propertyID = streamPropertyDescr->Property->Id;
  402. NTSTATUS status = STATUS_SUCCESS;
  403. switch (propertyID) {
  404. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  405. status = Set_Brightness(DeviceContext, propertyData->Value);
  406. break;
  407. case KSPROPERTY_VIDEOPROCAMP_CONTRAST:
  408. status = Set_Contrast(DeviceContext, propertyData->Value);
  409. break;
  410. case KSPROPERTY_VIDEOPROCAMP_GAMMA:
  411. status = Set_Gamma(DeviceContext, propertyData->Value);
  412. break;
  413. case KSPROPERTY_VIDEOPROCAMP_COLORENABLE:
  414. status = Set_ColorEnable(DeviceContext, propertyData->Value);
  415. break;
  416. case KSPROPERTY_VIDEOPROCAMP_BACKLIGHT_COMPENSATION:
  417. status = Set_BackLight_Compensation(DeviceContext, propertyData->Value);
  418. break;
  419. default:
  420. status = STATUS_NOT_SUPPORTED;
  421. }
  422. pSrb->Status = status;
  423. return status;
  424. }
  425. /*
  426. ** PHILIPSCAM_GetCameraControlProperty()
  427. **
  428. ** Arguments:
  429. **
  430. ** DeviceContext - driver context
  431. **
  432. ** Returns:
  433. **
  434. ** NT status completion code
  435. **
  436. ** Side Effects: none
  437. */
  438. NTSTATUS
  439. PHILIPSCAM_GetCameraControlProperty(
  440. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  441. PHW_STREAM_REQUEST_BLOCK pSrb
  442. )
  443. {
  444. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  445. pSrb->CommandData.PropertyInfo;
  446. PKSPROPERTY_CAMERACONTROL_S propertyData =
  447. streamPropertyDescr->PropertyInfo;
  448. ULONG flags = propertyData->Flags;
  449. ULONG propertyID = streamPropertyDescr->Property->Id;
  450. NTSTATUS status = STATUS_SUCCESS;
  451. ASSERT(streamPropertyDescr->PropertyOutputSize
  452. >= sizeof(KSPROPERTY_CAMERACONTROL_S));
  453. switch(propertyID)
  454. {
  455. default:
  456. status = STATUS_NOT_SUPPORTED;
  457. }
  458. pSrb->Status = status;
  459. return status;
  460. }
  461. /*
  462. ** PHILIPSCAM_SetCameraControlProperty()
  463. **
  464. ** Arguments:
  465. **
  466. ** DeviceContext - driver context
  467. **
  468. ** Returns:
  469. **
  470. ** NT status completion code
  471. **
  472. ** Side Effects: none
  473. */
  474. NTSTATUS
  475. PHILIPSCAM_SetCameraControlProperty(
  476. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  477. PHW_STREAM_REQUEST_BLOCK pSrb
  478. )
  479. {
  480. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  481. pSrb->CommandData.PropertyInfo;
  482. PKSPROPERTY_CAMERACONTROL_S propertyData =
  483. streamPropertyDescr->PropertyInfo;
  484. ULONG flags = propertyData->Flags;
  485. ULONG propertyID = streamPropertyDescr->Property->Id;
  486. NTSTATUS status = STATUS_SUCCESS;
  487. switch (propertyID)
  488. {
  489. default:
  490. status = STATUS_NOT_SUPPORTED;
  491. }
  492. pSrb->Status = status;
  493. return status;
  494. }
  495. /*
  496. ** PHILIPSCAM_GetCustomProperty()
  497. **
  498. ** Arguments:
  499. **
  500. ** DeviceContext - driver context
  501. **
  502. ** Returns:
  503. **
  504. ** NT status completion code
  505. **
  506. ** Side Effects: none
  507. */
  508. NTSTATUS
  509. PHILIPSCAM_GetCustomProperty(
  510. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  511. PHW_STREAM_REQUEST_BLOCK pSrb
  512. )
  513. {
  514. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  515. pSrb->CommandData.PropertyInfo;
  516. PKSPROPERTY_PHILIPS_CUSTOM_PROP_S propertyData =
  517. streamPropertyDescr->PropertyInfo;
  518. ULONG flags = propertyData->Flags;
  519. ULONG propertyID = streamPropertyDescr->Property->Id;
  520. NTSTATUS status = STATUS_SUCCESS;
  521. ASSERT(streamPropertyDescr->PropertyOutputSize
  522. >= sizeof(KSPROPERTY_PHILIPS_CUSTOM_PROP_S));
  523. switch(propertyID)
  524. {
  525. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE:
  526. status = Get_WB_Mode(DeviceContext, &propertyData->Value);
  527. break;
  528. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_SPEED:
  529. status = Get_WB_Speed(DeviceContext, &propertyData->Value);
  530. break;
  531. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_DELAY:
  532. status = Get_WB_Delay(DeviceContext, &propertyData->Value);
  533. break;
  534. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_RED_GAIN:
  535. status = Get_WB_Red_Gain(DeviceContext, &propertyData->Value);
  536. break;
  537. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_BLUE_GAIN:
  538. status = Get_WB_Blue_Gain(DeviceContext, &propertyData->Value);
  539. break;
  540. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_CONTROL_SPEED:
  541. status = Get_AE_Control_Speed(DeviceContext, &propertyData->Value);
  542. break;
  543. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS:
  544. status = Get_AE_Flickerless(DeviceContext, &propertyData->Value);
  545. break;
  546. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE:
  547. status = Get_AE_Shutter_Mode(DeviceContext, &propertyData->Value);
  548. break;
  549. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED:
  550. status = Get_AE_Shutter_Speed(DeviceContext, &propertyData->Value);
  551. break;
  552. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_STATUS:
  553. status = Get_AE_Shutter_Status(DeviceContext, &propertyData->Value);
  554. break;
  555. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE:
  556. status = Get_AE_AGC_Mode(DeviceContext, &propertyData->Value);
  557. break;
  558. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC:
  559. status = Get_AE_AGC(DeviceContext, &propertyData->Value);
  560. break;
  561. case KSPROPERTY_PHILIPS_CUSTOM_PROP_DRIVERVERSION:
  562. status = Get_DriverVersion(DeviceContext, &propertyData->Value);
  563. break;
  564. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE:
  565. status = Get_Framerate(DeviceContext, &propertyData->Value);
  566. break;
  567. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATES_SUPPORTED:
  568. status = Get_Framerates_Supported(DeviceContext, &propertyData->Value);
  569. break;
  570. case KSPROPERTY_PHILIPS_CUSTOM_PROP_VIDEOFORMAT:
  571. status = Get_VideoFormat(DeviceContext, &propertyData->Value);
  572. break;
  573. case KSPROPERTY_PHILIPS_CUSTOM_PROP_SENSORTYPE:
  574. status = Get_SensorType(DeviceContext, &propertyData->Value);
  575. break;
  576. case KSPROPERTY_PHILIPS_CUSTOM_PROP_VIDEOCOMPRESSION:
  577. status = Get_VideoCompression(DeviceContext, &propertyData->Value);
  578. break;
  579. case KSPROPERTY_PHILIPS_CUSTOM_PROP_RELEASE_NUMBER:
  580. status = Get_Release_Number(DeviceContext, &propertyData->Value);
  581. break;
  582. case KSPROPERTY_PHILIPS_CUSTOM_PROP_VENDOR_ID:
  583. status = Get_Vendor_Id(DeviceContext, &propertyData->Value);
  584. break;
  585. case KSPROPERTY_PHILIPS_CUSTOM_PROP_PRODUCT_ID:
  586. status = Get_Product_Id(DeviceContext, &propertyData->Value);
  587. break;
  588. default:
  589. status = STATUS_NOT_SUPPORTED;
  590. }
  591. if (NT_SUCCESS(status))
  592. {
  593. pSrb->ActualBytesTransferred = sizeof(KSPROPERTY_PHILIPS_CUSTOM_PROP_S);
  594. propertyData->Capabilities = 0;
  595. }
  596. pSrb->Status = status;
  597. return status;
  598. }
  599. /*
  600. ** PHILIPSCAM_SetCustomProperty()
  601. **
  602. ** Arguments:
  603. **
  604. ** DeviceContext - driver context
  605. **
  606. ** Returns:
  607. **
  608. ** NT status completion code
  609. **
  610. ** Side Effects: none
  611. */
  612. NTSTATUS
  613. PHILIPSCAM_SetCustomProperty(
  614. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  615. PHW_STREAM_REQUEST_BLOCK pSrb
  616. )
  617. {
  618. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  619. pSrb->CommandData.PropertyInfo;
  620. PKSPROPERTY_PHILIPS_CUSTOM_PROP_S propertyData =
  621. streamPropertyDescr->PropertyInfo;
  622. ULONG propertyID = streamPropertyDescr->Property->Id;
  623. ULONG length, slength;
  624. PVOID pValue = NULL;
  625. NTSTATUS status = STATUS_SUCCESS;
  626. switch(propertyID)
  627. {
  628. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE:
  629. status = Set_WB_Mode(DeviceContext, propertyData->Value);
  630. break;
  631. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_SPEED:
  632. status = Set_WB_Speed(DeviceContext, propertyData->Value);
  633. break;
  634. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_DELAY:
  635. status = Set_WB_Delay(DeviceContext, propertyData->Value);
  636. break;
  637. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_RED_GAIN:
  638. status = Set_WB_Red_Gain(DeviceContext, propertyData->Value);
  639. break;
  640. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_BLUE_GAIN:
  641. status = Set_WB_Blue_Gain(DeviceContext, propertyData->Value);
  642. break;
  643. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_CONTROL_SPEED:
  644. status = Set_AE_Control_Speed(DeviceContext, propertyData->Value);
  645. break;
  646. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS:
  647. status = Set_AE_Flickerless(DeviceContext, propertyData->Value);
  648. break;
  649. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE:
  650. status = Set_AE_Shutter_Mode(DeviceContext, propertyData->Value);
  651. break;
  652. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED:
  653. status = Set_AE_Shutter_Speed(DeviceContext, propertyData->Value);
  654. break;
  655. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE:
  656. status = Set_AE_AGC_Mode(DeviceContext, propertyData->Value);
  657. break;
  658. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC:
  659. status = Set_AE_AGC(DeviceContext, propertyData->Value);
  660. break;
  661. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE:
  662. status = Set_Framerate(DeviceContext, propertyData->Value);
  663. break;
  664. case KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS:
  665. status = Set_Defaults(DeviceContext, propertyData->Value);
  666. break;
  667. default:
  668. status = STATUS_NOT_SUPPORTED;
  669. }
  670. pSrb->Status = status;
  671. return status;
  672. }
  673. /*
  674. ** PHILIPSCAM_GetFactoryProperty()
  675. **
  676. ** Arguments:
  677. **
  678. ** DeviceContext - driver context
  679. **
  680. ** Returns:
  681. **
  682. ** NT status completion code
  683. **
  684. ** Side Effects: none
  685. */
  686. NTSTATUS
  687. PHILIPSCAM_GetFactoryProperty(
  688. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  689. PHW_STREAM_REQUEST_BLOCK pSrb
  690. )
  691. {
  692. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  693. pSrb->CommandData.PropertyInfo;
  694. PKSPROPERTY_PHILIPS_FACTORY_PROP_S propertyData =
  695. streamPropertyDescr->PropertyInfo;
  696. ULONG flags = propertyData->Flags;
  697. ULONG propertyID = streamPropertyDescr->Property->Id;
  698. NTSTATUS status = STATUS_SUCCESS;
  699. ASSERT(streamPropertyDescr->PropertyOutputSize
  700. >= sizeof(KSPROPERTY_PHILIPS_FACTORY_PROP_S));
  701. RtlCopyMemory( propertyData, streamPropertyDescr->Property,
  702. sizeof( KSPROPERTY_PHILIPS_FACTORY_PROP_S ) );
  703. switch(propertyID)
  704. {
  705. case KSPROPERTY_PHILIPS_FACTORY_PROP_REGISTER_DATA:
  706. status = Get_RegisterData(DeviceContext, &propertyData->Value);
  707. break;
  708. default:
  709. status = STATUS_NOT_SUPPORTED;
  710. }
  711. if (NT_SUCCESS(status))
  712. {
  713. pSrb->ActualBytesTransferred = sizeof(KSPROPERTY_PHILIPS_FACTORY_PROP_S);
  714. propertyData->Capabilities = 0;
  715. }
  716. pSrb->Status = status;
  717. return status;
  718. }
  719. /*
  720. ** PHILIPSCAM_SetFactoryProperty()
  721. **
  722. ** Arguments:
  723. **
  724. ** DeviceContext - driver context
  725. **
  726. ** Returns:
  727. **
  728. ** NT status completion code
  729. **
  730. ** Side Effects: none
  731. */
  732. NTSTATUS
  733. PHILIPSCAM_SetFactoryProperty(
  734. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  735. PHW_STREAM_REQUEST_BLOCK pSrb
  736. )
  737. {
  738. PSTREAM_PROPERTY_DESCRIPTOR streamPropertyDescr =
  739. pSrb->CommandData.PropertyInfo;
  740. PKSPROPERTY_PHILIPS_FACTORY_PROP_S propertyData =
  741. streamPropertyDescr->PropertyInfo;
  742. ULONG propertyID = streamPropertyDescr->Property->Id;
  743. ULONG length, slength;
  744. PVOID pValue = NULL;
  745. NTSTATUS status = STATUS_SUCCESS;
  746. // RtlCopyMemory( propertyData, streamPropertyDescr->Property,
  747. // sizeof( KSPROPERTY_PHILIPS_FACTORY_PROP_S ) );
  748. switch(propertyID)
  749. {
  750. case KSPROPERTY_PHILIPS_FACTORY_PROP_REGISTER_ADDRESS:
  751. status = Set_RegisterAddress(DeviceContext, propertyData->Value);
  752. break;
  753. case KSPROPERTY_PHILIPS_FACTORY_PROP_REGISTER_DATA:
  754. status = Set_RegisterData(DeviceContext, propertyData->Value);
  755. break;
  756. case KSPROPERTY_PHILIPS_FACTORY_PROP_FACTORY_MODE:
  757. status = Set_Factory_Mode(DeviceContext, propertyData->Value);
  758. break;
  759. default:
  760. status = STATUS_NOT_SUPPORTED;
  761. }
  762. pSrb->Status = status;
  763. return status;
  764. }
  765. /*==============================================================================
  766. *
  767. * Function: PHILIPSCAM_GetVideoControlProperty
  768. *
  769. * Abstract:
  770. *
  771. * Arguments:
  772. *
  773. * Returns: NTSTATUS
  774. *
  775. * SideEffects: None
  776. *
  777. *============================================================================*/
  778. NTSTATUS
  779. PHILIPSCAM_GetVideoControlProperty(
  780. PPHILIPSCAM_DEVICE_CONTEXT pDc,
  781. PHW_STREAM_REQUEST_BLOCK pSrb)
  782. {
  783. NTSTATUS ntStatus = STATUS_SUCCESS;
  784. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  785. DWORD dwPropertyID = pSPD->Property->Id; // index of the property
  786. DWORD dwSize = pSPD->PropertyOutputSize; // size of data supplied
  787. LONGLONG FramePeriod[] = {
  788. NUM_100NANOSEC_UNITS_PERFRAME(1),
  789. 0x28B0AA , // 3.75 fps
  790. NUM_100NANOSEC_UNITS_PERFRAME(5),
  791. 0x145855 , // 7.5 fps
  792. NUM_100NANOSEC_UNITS_PERFRAME(10),
  793. NUM_100NANOSEC_UNITS_PERFRAME(12),
  794. NUM_100NANOSEC_UNITS_PERFRAME(15),
  795. NUM_100NANOSEC_UNITS_PERFRAME(20),
  796. NUM_100NANOSEC_UNITS_PERFRAME(24)
  797. };
  798. USHORT CIFFrameRatesList[] =
  799. {
  800. FRRATE375,
  801. FRRATE5,
  802. FRRATE75,
  803. FRRATE10,
  804. FRRATE12,
  805. FRRATE15
  806. };
  807. USHORT QCIFFrameRatesList[] =
  808. {
  809. FRRATE5,
  810. FRRATE75,
  811. FRRATE10,
  812. FRRATE12,
  813. FRRATE15,
  814. FRRATE20,
  815. FRRATE24
  816. };
  817. ULONG i;
  818. PHILIPSCAM_KdPrint(MAX_TRACE, ("enter GetVideoControlProperty\n"));
  819. switch(dwPropertyID)
  820. {
  821. case KSPROPERTY_VIDEOCONTROL_CAPS:
  822. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  823. break;
  824. case KSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE:
  825. {
  826. PKSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S pInputData =
  827. (PKSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S) pSPD->Property;
  828. PKSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S pOutputData =
  829. (PKSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S) pSPD->PropertyInfo;
  830. if (pInputData->StreamIndex != 0) {
  831. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  832. return ntStatus;
  833. }
  834. if (dwSize == 0)
  835. {
  836. pSrb->ActualBytesTransferred =
  837. sizeof(KSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S);
  838. ntStatus = pSrb->Status = STATUS_BUFFER_OVERFLOW;
  839. }
  840. else if (dwSize >=
  841. sizeof(KSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S))
  842. {
  843. pSrb->ActualBytesTransferred =
  844. sizeof(KSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S);
  845. pOutputData->CurrentActualFrameRate =
  846. FramePeriod[pDc->CamStatus.PictureFrameRate];
  847. for (i = FRRATE24; (i > FRRATEVGA)&&(pDc->FrrSupported[i] == FALSE); i--);
  848. pOutputData->CurrentMaxAvailableFrameRate = FramePeriod[i];
  849. ntStatus = pSrb->Status = STATUS_SUCCESS;
  850. }
  851. }
  852. break;
  853. case KSPROPERTY_VIDEOCONTROL_FRAME_RATES:
  854. {
  855. PKSPROPERTY_VIDEOCONTROL_FRAME_RATES_S pFrRInfo =
  856. (PKSPROPERTY_VIDEOCONTROL_FRAME_RATES_S) pSPD->Property;
  857. ULONG BytesNeeded;
  858. // First value of Framerate table (FRRATEVGA) disabled as selectable value.
  859. PKSMULTIPLE_ITEM pOutputBuf = (PKSMULTIPLE_ITEM) pSPD->PropertyInfo;
  860. LONGLONG * pDataPtr = (LONGLONG*) (pOutputBuf + 1);
  861. if (pFrRInfo->Dimensions.cx > QCIF_X)
  862. {
  863. BytesNeeded = sizeof(KSMULTIPLE_ITEM) +
  864. SIZEOF_ARRAY(CIFFrameRatesList) * sizeof(LONGLONG);
  865. }
  866. else
  867. {
  868. BytesNeeded = sizeof(KSMULTIPLE_ITEM) +
  869. SIZEOF_ARRAY(QCIFFrameRatesList) * sizeof(LONGLONG);
  870. }
  871. if (dwSize == 0)
  872. {
  873. pSrb->ActualBytesTransferred = BytesNeeded;
  874. ntStatus = pSrb->Status = STATUS_BUFFER_OVERFLOW;
  875. }
  876. else
  877. {
  878. if (dwSize >= BytesNeeded)
  879. {
  880. //framerate list depends on requested pict.size
  881. if (pFrRInfo->Dimensions.cx > QCIF_X)
  882. {
  883. //Use CIF Frame rate list
  884. pOutputBuf->Size = (SIZEOF_ARRAY(CIFFrameRatesList) * sizeof(LONGLONG));
  885. pOutputBuf->Count = SIZEOF_ARRAY(CIFFrameRatesList);
  886. for ( i=0 ; i < SIZEOF_ARRAY(CIFFrameRatesList) ; i++)
  887. {
  888. pDataPtr[i] = FramePeriod[CIFFrameRatesList[i]];
  889. }
  890. pSrb->ActualBytesTransferred = sizeof(KSMULTIPLE_ITEM) +
  891. SIZEOF_ARRAY(CIFFrameRatesList) * sizeof(LONGLONG);
  892. }
  893. else
  894. {
  895. // Use QCIF Frame rate list
  896. pOutputBuf->Size = (SIZEOF_ARRAY(QCIFFrameRatesList) * sizeof(LONGLONG));
  897. pOutputBuf->Count = SIZEOF_ARRAY(QCIFFrameRatesList);
  898. for ( i=0 ; i < SIZEOF_ARRAY(QCIFFrameRatesList) ; i++)
  899. {
  900. pDataPtr[i] = FramePeriod[QCIFFrameRatesList[i]];
  901. }
  902. pSrb->ActualBytesTransferred = sizeof(KSMULTIPLE_ITEM) +
  903. SIZEOF_ARRAY(QCIFFrameRatesList) * sizeof(LONGLONG);
  904. }
  905. ntStatus = pSrb->Status = STATUS_SUCCESS;
  906. }
  907. #if NOTACTIVE
  908. {
  909. pOutputBuf->Size = ((SIZEOF_ARRAY(FramePeriod)-1) * sizeof(LONGLONG));
  910. pOutputBuf->Count = SIZEOF_ARRAY(FramePeriod)-1;
  911. for ( i=1 ; i < SIZEOF_ARRAY(FramePeriod) ; i++)
  912. {
  913. pDataPtr[i-1] = FramePeriod[i];
  914. }
  915. pSrb->ActualBytesTransferred = sizeof(KSMULTIPLE_ITEM) +
  916. (SIZEOF_ARRAY(FramePeriod) - 1) * sizeof(LONGLONG);
  917. ntStatus = pSrb->Status = STATUS_SUCCESS;
  918. }
  919. #endif
  920. else
  921. {
  922. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  923. }
  924. }
  925. }
  926. break;
  927. case KSPROPERTY_VIDEOCONTROL_MODE:
  928. {
  929. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  930. }
  931. break;
  932. default:
  933. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  934. }
  935. return ntStatus;
  936. }
  937. /*==============================================================================
  938. *
  939. * Function: PHILIPSCAM_SetVideoControlProperty
  940. *
  941. * Abstract:
  942. *
  943. * Arguments:
  944. *
  945. * Returns: NTSTATUS
  946. *
  947. * SideEffects: None
  948. *
  949. *============================================================================*/
  950. NTSTATUS
  951. PHILIPSCAM_SetVideoControlProperty(
  952. PPHILIPSCAM_DEVICE_CONTEXT pDc,
  953. PHW_STREAM_REQUEST_BLOCK pSrb)
  954. {
  955. NTSTATUS ntStatus = STATUS_SUCCESS;
  956. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  957. DWORD dwPropertyID = pSPD->Property->Id; // index of the property
  958. PHILIPSCAM_KdPrint(MAX_TRACE, ("enter SetVideoControlProperty\n"));
  959. ASSERT (pSPD->PropertyInputSize >= sizeof (KSPROPERTY_VIDEOCONTROL_MODE_S));
  960. switch(dwPropertyID)
  961. case KSPROPERTY_VIDEOCONTROL_CAPS:
  962. case KSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE:
  963. case KSPROPERTY_VIDEOCONTROL_FRAME_RATES:
  964. case KSPROPERTY_VIDEOCONTROL_MODE:
  965. default:
  966. ntStatus = pSrb->Status = STATUS_NOT_SUPPORTED;
  967. return ntStatus;
  968. }
  969. /*===========================================================================*/
  970. NTSTATUS
  971. PHILIPSCAM_SetFormatFramerate(
  972. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext
  973. )
  974. /*===========================================================================*/
  975. {
  976. UCHAR Buffer[3]={0};
  977. ULONG BufferLength = sizeof(Buffer);
  978. NTSTATUS status = STATUS_SUCCESS;
  979. LONG hVideoFormat, hFramerate, hCompression;
  980. if ( (DeviceContext->CamStatus.PictureFormat == FORMATCIF) ||
  981. (DeviceContext->CamStatus.PictureFormat == FORMATSIF) ||
  982. (DeviceContext->CamStatus.PictureFormat == FORMATSSIF)||
  983. (DeviceContext->CamStatus.PictureFormat == FORMATSCIF) ){
  984. if (DeviceContext->CamStatus.PictureFrameRate == FRRATE375){
  985. DeviceContext->CamStatus.PictureCompressing = COMPRESSION0;
  986. }else{
  987. if (DeviceContext->CamStatus.ReleaseNumber >= SSI_CIF3){
  988. DeviceContext->CamStatus.PictureCompressing = COMPRESSION3;
  989. }else{
  990. DeviceContext->CamStatus.PictureCompressing = COMPRESSION4;
  991. }
  992. }
  993. }else{
  994. DeviceContext->CamStatus.PictureCompressing = COMPRESSION0;
  995. }
  996. status = Map_Framerate_Drv_to_KS(DeviceContext, &hFramerate);
  997. if (!NT_SUCCESS(status))
  998. return status;
  999. status = Map_VideoFormat_Drv_to_KS(DeviceContext, &hVideoFormat);
  1000. if (!NT_SUCCESS(status))
  1001. return status;
  1002. status = Map_VideoCompression_Drv_to_KS(DeviceContext, &hCompression);
  1003. if (!NT_SUCCESS(status))
  1004. return status;
  1005. Buffer[bFRAMERATE] = (BYTE)hFramerate;
  1006. Buffer[bVIDEOOUTPUTTYPE] = (BYTE)hVideoFormat;
  1007. Buffer[bCOMPRESSIONFACT] = (BYTE)hCompression;
  1008. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1009. SET_EP_STREAM_CTL, VIDEO_OUTPUT_CONTROL_FORMATTER, VIDEO_ENDPOINT,
  1010. Buffer, &BufferLength, SEND, NULL, NULL);
  1011. return status;
  1012. }
  1013. /*===========================================================================*/
  1014. NTSTATUS
  1015. PHILIPSCAM_GetSensorType(
  1016. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext
  1017. )
  1018. /*===========================================================================*/
  1019. {
  1020. UCHAR Buffer[1]={0};
  1021. ULONG BufferLength = sizeof(Buffer);
  1022. NTSTATUS status = STATUS_SUCCESS;
  1023. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1024. GET_STATUS_CTL, SENSOR_TYPE, VC_INTERFACE,
  1025. Buffer, &BufferLength, GET, NULL, NULL);
  1026. if (NT_SUCCESS(status))
  1027. DeviceContext->CamStatus.SensorType = Buffer[0];
  1028. return status;
  1029. }
  1030. /*===========================================================================*/
  1031. NTSTATUS
  1032. PHILIPSCAM_GetReleaseNumber(
  1033. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext
  1034. )
  1035. /*===========================================================================*/
  1036. {
  1037. UCHAR Buffer[2]={0};
  1038. ULONG BufferLength = sizeof(Buffer);
  1039. NTSTATUS status = STATUS_SUCCESS;
  1040. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1041. GET_STATUS_CTL, RELEASE_NUMBER, VC_INTERFACE,
  1042. Buffer, &BufferLength, GET, NULL, NULL);
  1043. if (NT_SUCCESS(status)) // ?? need to map to camera value ranges ??
  1044. {
  1045. DeviceContext->CamStatus.ReleaseNumber =
  1046. (((LONG)Buffer[1] << 8) | (LONG)Buffer[0]);
  1047. }
  1048. return status;
  1049. }
  1050. /*===========================================================================*/
  1051. static NTSTATUS
  1052. Get_Brightness(
  1053. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1054. PLONG pBrightness)
  1055. /*===========================================================================*/
  1056. {
  1057. UCHAR Buffer[1]={0};
  1058. ULONG BufferLength = sizeof(Buffer);
  1059. NTSTATUS status = STATUS_SUCCESS;
  1060. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1061. GET_LUM_CTL, BRIGHTNESS, VC_INTERFACE,
  1062. Buffer, &BufferLength, GET, NULL, NULL);
  1063. if (NT_SUCCESS(status))
  1064. (*pBrightness) = Buffer[0] * BRIGHTNESS_DELTA;
  1065. return status;
  1066. }
  1067. /*===========================================================================*/
  1068. static NTSTATUS
  1069. Set_Brightness(
  1070. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1071. LONG Brightness)
  1072. /*===========================================================================*/
  1073. {
  1074. UCHAR Buffer[1]={0};
  1075. ULONG BufferLength = sizeof(Buffer);
  1076. NTSTATUS status = STATUS_SUCCESS;
  1077. Buffer[0] = (UCHAR)(Brightness / BRIGHTNESS_DELTA);
  1078. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1079. SET_LUM_CTL, BRIGHTNESS, VC_INTERFACE,
  1080. Buffer, &BufferLength, SEND, NULL, NULL);
  1081. return status;
  1082. }
  1083. /*===========================================================================*/
  1084. static NTSTATUS
  1085. Get_Contrast(
  1086. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1087. PLONG pContrast)
  1088. /*===========================================================================*/
  1089. {
  1090. UCHAR Buffer[1]={0};
  1091. ULONG BufferLength = sizeof(Buffer);
  1092. NTSTATUS status = STATUS_SUCCESS;
  1093. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1094. GET_LUM_CTL, CONTRAST, VC_INTERFACE,
  1095. Buffer, &BufferLength, GET, NULL, NULL);
  1096. if (NT_SUCCESS(status))
  1097. (*pContrast) = Buffer[0] * CONTRAST_DELTA;
  1098. return status;
  1099. }
  1100. /*===========================================================================*/
  1101. static NTSTATUS
  1102. Set_Contrast(
  1103. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1104. LONG Contrast)
  1105. /*===========================================================================*/
  1106. {
  1107. UCHAR Buffer[1]={0};
  1108. ULONG BufferLength = sizeof(Buffer);
  1109. NTSTATUS status = STATUS_SUCCESS;
  1110. Buffer[0] = (UCHAR)(Contrast / CONTRAST_DELTA);
  1111. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1112. SET_LUM_CTL, CONTRAST, VC_INTERFACE,
  1113. Buffer, &BufferLength, SEND, NULL, NULL);
  1114. return status;
  1115. }
  1116. /*===========================================================================*/
  1117. static NTSTATUS
  1118. Get_Gamma(
  1119. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1120. PLONG pGamma)
  1121. /*===========================================================================*/
  1122. {
  1123. UCHAR Buffer[1]={0};
  1124. ULONG BufferLength = sizeof(Buffer);
  1125. NTSTATUS status = STATUS_SUCCESS;
  1126. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1127. GET_LUM_CTL, GAMMA, VC_INTERFACE,
  1128. Buffer, &BufferLength, GET, NULL, NULL);
  1129. if (NT_SUCCESS(status))
  1130. (*pGamma) = Buffer[0] * GAMMA_DELTA;
  1131. return status;
  1132. }
  1133. /*===========================================================================*/
  1134. static NTSTATUS
  1135. Set_Gamma(
  1136. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1137. LONG Gamma)
  1138. /*===========================================================================*/
  1139. {
  1140. UCHAR Buffer[1]={0};
  1141. ULONG BufferLength = sizeof(Buffer);
  1142. NTSTATUS status = STATUS_SUCCESS;
  1143. Buffer[0] = (UCHAR)(Gamma / GAMMA_DELTA);
  1144. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1145. SET_LUM_CTL, GAMMA, VC_INTERFACE,
  1146. Buffer, &BufferLength, SEND, NULL, NULL);
  1147. return status;
  1148. }
  1149. /*===========================================================================*/
  1150. static NTSTATUS
  1151. Get_ColorEnable(
  1152. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1153. PLONG pColorEnable)
  1154. /*===========================================================================*/
  1155. {
  1156. UCHAR Buffer[1]={0};
  1157. ULONG BufferLength = sizeof(Buffer);
  1158. NTSTATUS status = STATUS_SUCCESS;
  1159. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1160. GET_CHROM_CTL, COLOR_MODE, VC_INTERFACE,
  1161. Buffer, &BufferLength, GET, NULL, NULL);
  1162. if (NT_SUCCESS(status))
  1163. {
  1164. if (Buffer[0] ==(UCHAR)0)
  1165. (*pColorEnable) = COLORENABLE_MIN;
  1166. else
  1167. (*pColorEnable) = COLORENABLE_MAX;
  1168. }
  1169. return status;
  1170. }
  1171. /*===========================================================================*/
  1172. static NTSTATUS
  1173. Set_ColorEnable(
  1174. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1175. LONG ColorEnable)
  1176. /*===========================================================================*/
  1177. {
  1178. UCHAR Buffer[1]={0};
  1179. ULONG BufferLength = sizeof(Buffer);
  1180. NTSTATUS status = STATUS_SUCCESS;
  1181. if (ColorEnable == COLORENABLE_MIN)
  1182. Buffer[0] = (UCHAR)0;
  1183. else
  1184. Buffer[0] = (UCHAR)0xff;
  1185. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1186. SET_CHROM_CTL, COLOR_MODE, VC_INTERFACE,
  1187. Buffer, &BufferLength, SEND, NULL, NULL);
  1188. return status;
  1189. }
  1190. /*===========================================================================*/
  1191. static NTSTATUS
  1192. Get_BackLight_Compensation(
  1193. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1194. PLONG pBackLight_Compensation)
  1195. /*===========================================================================*/
  1196. {
  1197. UCHAR Buffer[1]={0};
  1198. ULONG BufferLength = sizeof(Buffer);
  1199. NTSTATUS status = STATUS_SUCCESS;
  1200. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1201. GET_LUM_CTL, BACK_LIGHT_COMPENSATION, VC_INTERFACE,
  1202. Buffer, &BufferLength, GET, NULL, NULL);
  1203. if (NT_SUCCESS(status))
  1204. {
  1205. if (Buffer[0] ==(UCHAR)0)
  1206. (*pBackLight_Compensation) = BACKLIGHT_COMPENSATION_MIN;
  1207. else
  1208. (*pBackLight_Compensation) = BACKLIGHT_COMPENSATION_MAX;
  1209. }
  1210. return status;
  1211. }
  1212. /*===========================================================================*/
  1213. static NTSTATUS
  1214. Set_BackLight_Compensation(
  1215. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1216. LONG BackLight_Compensation)
  1217. /*===========================================================================*/
  1218. {
  1219. UCHAR Buffer[1]={0};
  1220. ULONG BufferLength = sizeof(Buffer);
  1221. NTSTATUS status = STATUS_SUCCESS;
  1222. if (BackLight_Compensation == BACKLIGHT_COMPENSATION_MIN)
  1223. Buffer[0] = (UCHAR)0;
  1224. else
  1225. Buffer[0] = (UCHAR)0xff;
  1226. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1227. SET_LUM_CTL, BACK_LIGHT_COMPENSATION, VC_INTERFACE,
  1228. Buffer, &BufferLength, SEND, NULL, NULL);
  1229. return status;
  1230. }
  1231. /*===========================================================================*/
  1232. static NTSTATUS
  1233. Get_WB_Mode(
  1234. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1235. PLONG pWB_Mode)
  1236. /*===========================================================================*/
  1237. {
  1238. UCHAR Buffer[1]={0};
  1239. ULONG BufferLength = sizeof(Buffer);
  1240. NTSTATUS status = STATUS_SUCCESS;
  1241. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1242. GET_CHROM_CTL, WB_MODE, VC_INTERFACE,
  1243. Buffer, &BufferLength, GET, NULL, NULL);
  1244. if (NT_SUCCESS(status))
  1245. (*pWB_Mode) = Buffer[0];
  1246. return status;
  1247. }
  1248. /*===========================================================================*/
  1249. static NTSTATUS
  1250. Set_WB_Mode(
  1251. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1252. LONG WB_Mode)
  1253. /*===========================================================================*/
  1254. {
  1255. UCHAR Buffer[1]={0};
  1256. ULONG BufferLength = sizeof(Buffer);
  1257. NTSTATUS status = STATUS_SUCCESS;
  1258. /*
  1259. * switch to new mode
  1260. */
  1261. Buffer[0] = (UCHAR)WB_Mode;
  1262. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1263. SET_CHROM_CTL, WB_MODE, VC_INTERFACE,
  1264. Buffer, &BufferLength, SEND, NULL, NULL);
  1265. if (!NT_SUCCESS(status))
  1266. return status;
  1267. return status;
  1268. }
  1269. /*===========================================================================*/
  1270. static NTSTATUS
  1271. Get_WB_Speed(
  1272. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1273. PLONG pWB_Speed)
  1274. /*===========================================================================*/
  1275. {
  1276. UCHAR Buffer[1]={0};
  1277. ULONG BufferLength = sizeof(Buffer);
  1278. NTSTATUS status = STATUS_SUCCESS;
  1279. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1280. GET_CHROM_CTL, AWB_CONTROL_SPEED, VC_INTERFACE,
  1281. Buffer, &BufferLength, GET, NULL, NULL);
  1282. if (NT_SUCCESS(status))
  1283. (*pWB_Speed) = Buffer[0] * WB_SPEED_DELTA;
  1284. return status;
  1285. }
  1286. /*===========================================================================*/
  1287. static NTSTATUS
  1288. Set_WB_Speed(
  1289. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1290. LONG WB_Speed)
  1291. /*===========================================================================*/
  1292. {
  1293. UCHAR Buffer[1]={0};
  1294. ULONG BufferLength = sizeof(Buffer);
  1295. NTSTATUS status = STATUS_SUCCESS;
  1296. Buffer[0] = (UCHAR)(WB_Speed / WB_SPEED_DELTA);
  1297. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1298. SET_CHROM_CTL, AWB_CONTROL_SPEED, VC_INTERFACE,
  1299. Buffer, &BufferLength, SEND, NULL, NULL);
  1300. return status;
  1301. }
  1302. /*===========================================================================*/
  1303. static NTSTATUS
  1304. Get_WB_Delay(
  1305. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1306. PLONG pWB_Delay)
  1307. /*===========================================================================*/
  1308. {
  1309. UCHAR Buffer[1]={0};
  1310. ULONG BufferLength = sizeof(Buffer);
  1311. NTSTATUS status = STATUS_SUCCESS;
  1312. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1313. GET_CHROM_CTL, AWB_CONTROL_DELAY, VC_INTERFACE,
  1314. Buffer, &BufferLength, GET, NULL, NULL);
  1315. if (NT_SUCCESS(status))
  1316. (*pWB_Delay) = Buffer[0] * WB_DELAY_DELTA;
  1317. return status;
  1318. }
  1319. /*===========================================================================*/
  1320. static NTSTATUS
  1321. Set_WB_Delay(
  1322. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1323. LONG WB_Delay)
  1324. /*===========================================================================*/
  1325. {
  1326. UCHAR Buffer[1]={0};
  1327. ULONG BufferLength = sizeof(Buffer);
  1328. NTSTATUS status = STATUS_SUCCESS;
  1329. Buffer[0] = (UCHAR)(WB_Delay / WB_DELAY_DELTA);
  1330. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1331. SET_CHROM_CTL, AWB_CONTROL_DELAY, VC_INTERFACE,
  1332. Buffer, &BufferLength, SEND, NULL, NULL);
  1333. return status;
  1334. }
  1335. /*===========================================================================*/
  1336. static NTSTATUS
  1337. Get_WB_Red_Gain(
  1338. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1339. PLONG pWB_Red_Gain)
  1340. /*===========================================================================*/
  1341. {
  1342. UCHAR Buffer[1]={0};
  1343. ULONG BufferLength = sizeof(Buffer);
  1344. NTSTATUS status = STATUS_SUCCESS;
  1345. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1346. GET_CHROM_CTL, RED_GAIN, VC_INTERFACE,
  1347. Buffer, &BufferLength, GET, NULL, NULL);
  1348. if (NT_SUCCESS(status))
  1349. (*pWB_Red_Gain) = Buffer[0] * WB_RED_GAIN_DELTA;
  1350. return status;
  1351. }
  1352. /*===========================================================================*/
  1353. static NTSTATUS
  1354. Set_WB_Red_Gain(
  1355. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1356. LONG WB_Red_Gain)
  1357. /*===========================================================================*/
  1358. {
  1359. UCHAR Buffer[1]={0};
  1360. ULONG BufferLength = sizeof(Buffer);
  1361. NTSTATUS status = STATUS_SUCCESS;
  1362. Buffer[0] = (UCHAR)(WB_Red_Gain / WB_RED_GAIN_DELTA);
  1363. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1364. SET_CHROM_CTL, RED_GAIN, VC_INTERFACE,
  1365. Buffer, &BufferLength, SEND, NULL, NULL);
  1366. return status;
  1367. }
  1368. /*===========================================================================*/
  1369. static NTSTATUS
  1370. Get_WB_Blue_Gain(
  1371. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1372. PLONG pWB_Blue_Gain)
  1373. /*===========================================================================*/
  1374. {
  1375. UCHAR Buffer[1]={0};
  1376. ULONG BufferLength = sizeof(Buffer);
  1377. NTSTATUS status = STATUS_SUCCESS;
  1378. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1379. GET_CHROM_CTL, BLUE_GAIN, VC_INTERFACE,
  1380. Buffer, &BufferLength, GET, NULL, NULL);
  1381. if (NT_SUCCESS(status))
  1382. (*pWB_Blue_Gain) = Buffer[0] * WB_BLUE_GAIN_DELTA;
  1383. return status;
  1384. }
  1385. /*===========================================================================*/
  1386. static NTSTATUS
  1387. Set_WB_Blue_Gain(
  1388. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1389. LONG WB_Blue_Gain)
  1390. /*===========================================================================*/
  1391. {
  1392. UCHAR Buffer[1] = {0};
  1393. ULONG BufferLength = sizeof(Buffer);
  1394. NTSTATUS status = STATUS_SUCCESS;
  1395. Buffer[0] = (UCHAR)(WB_Blue_Gain / WB_BLUE_GAIN_DELTA);
  1396. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1397. SET_CHROM_CTL, BLUE_GAIN, VC_INTERFACE,
  1398. Buffer, &BufferLength, SEND, NULL, NULL);
  1399. return status;
  1400. }
  1401. /*===========================================================================*/
  1402. static NTSTATUS
  1403. Get_AE_Control_Speed(
  1404. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1405. PLONG pAE_Control_Speed)
  1406. /*===========================================================================*/
  1407. {
  1408. UCHAR Buffer[1] = {0};
  1409. ULONG BufferLength = sizeof(Buffer);
  1410. NTSTATUS status = STATUS_SUCCESS;
  1411. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1412. GET_LUM_CTL, AE_CONTROL_SPEED, VC_INTERFACE,
  1413. Buffer, &BufferLength, GET, NULL, NULL);
  1414. if (NT_SUCCESS(status))
  1415. (*pAE_Control_Speed) = Buffer[0] * AE_CONTROL_SPEED_DELTA;
  1416. return status;
  1417. }
  1418. /*===========================================================================*/
  1419. static NTSTATUS
  1420. Set_AE_Control_Speed(
  1421. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1422. LONG AE_Control_Speed)
  1423. /*===========================================================================*/
  1424. {
  1425. UCHAR Buffer[1]={0};
  1426. ULONG BufferLength = sizeof(Buffer);
  1427. NTSTATUS status = STATUS_SUCCESS;
  1428. Buffer[0] = (UCHAR)(AE_Control_Speed / AE_CONTROL_SPEED_DELTA);
  1429. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1430. SET_LUM_CTL, AE_CONTROL_SPEED, VC_INTERFACE,
  1431. Buffer, &BufferLength, SEND, NULL, NULL);
  1432. return status;
  1433. }
  1434. /*===========================================================================*/
  1435. static NTSTATUS
  1436. Get_AE_Flickerless(
  1437. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1438. PLONG pAE_Flickerless)
  1439. /*===========================================================================*/
  1440. {
  1441. UCHAR Buffer[1] = {0};
  1442. ULONG BufferLength = sizeof(Buffer);
  1443. NTSTATUS status = STATUS_SUCCESS;
  1444. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1445. GET_LUM_CTL, FLICKERLESS, VC_INTERFACE,
  1446. Buffer, &BufferLength, GET, NULL, NULL);
  1447. if (NT_SUCCESS(status))
  1448. {
  1449. if (Buffer[0] == (UCHAR)0)
  1450. (*pAE_Flickerless) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS_OFF;
  1451. else
  1452. (*pAE_Flickerless) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS_ON;
  1453. }
  1454. return status;
  1455. }
  1456. /*===========================================================================*/
  1457. static NTSTATUS
  1458. Set_AE_Flickerless(
  1459. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1460. LONG AE_Flickerless)
  1461. /*===========================================================================*/
  1462. {
  1463. UCHAR Buffer[1]={0};
  1464. ULONG BufferLength = sizeof(Buffer);
  1465. NTSTATUS status = STATUS_SUCCESS;
  1466. if (AE_Flickerless == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS_OFF)
  1467. Buffer[0] = (UCHAR)0;
  1468. else
  1469. Buffer[0] = (UCHAR)0xff;
  1470. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1471. SET_LUM_CTL, FLICKERLESS, VC_INTERFACE,
  1472. Buffer, &BufferLength, SEND, NULL, NULL);
  1473. return status;
  1474. }
  1475. /*===========================================================================*/
  1476. static NTSTATUS
  1477. Get_AE_Shutter_Mode(
  1478. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1479. PLONG pAE_Shutter_Mode)
  1480. /*===========================================================================*/
  1481. {
  1482. UCHAR Buffer[1]={0};
  1483. ULONG BufferLength = sizeof(Buffer);
  1484. NTSTATUS status = STATUS_SUCCESS;
  1485. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1486. GET_LUM_CTL, SHUTTER_MODE, VC_INTERFACE,
  1487. Buffer, &BufferLength, GET, NULL, NULL);
  1488. if (NT_SUCCESS(status))
  1489. {
  1490. if (Buffer[0] == (UCHAR)0)
  1491. (*pAE_Shutter_Mode) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO;
  1492. else
  1493. (*pAE_Shutter_Mode) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED;
  1494. }
  1495. return status;
  1496. }
  1497. /*===========================================================================*/
  1498. static NTSTATUS
  1499. Set_AE_Shutter_Mode(
  1500. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1501. LONG AE_Shutter_Mode)
  1502. /*===========================================================================*/
  1503. {
  1504. UCHAR Buffer[1]={0};
  1505. ULONG BufferLength = sizeof(Buffer);
  1506. NTSTATUS status = STATUS_SUCCESS;
  1507. if (AE_Shutter_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO)
  1508. Buffer[0] = (UCHAR)0;
  1509. else
  1510. Buffer[0] = (UCHAR)0xff;
  1511. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1512. SET_LUM_CTL, SHUTTER_MODE, VC_INTERFACE,
  1513. Buffer, &BufferLength, SEND, NULL, NULL);
  1514. return status;
  1515. }
  1516. /*===========================================================================*/
  1517. static NTSTATUS
  1518. Get_AE_Shutter_Speed(
  1519. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1520. PLONG pAE_Shutter_Speed)
  1521. /*===========================================================================*/
  1522. {
  1523. UCHAR Buffer[2]={0};
  1524. ULONG BufferLength = sizeof(Buffer);
  1525. NTSTATUS status = STATUS_SUCCESS;
  1526. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1527. GET_LUM_CTL, PRESET_SHUTTER, VC_INTERFACE,
  1528. Buffer, &BufferLength, GET, NULL, NULL);
  1529. if (NT_SUCCESS(status)) // ?? need to map to camera value ranges ??
  1530. {
  1531. (*pAE_Shutter_Speed) = (LONG)Buffer[0];
  1532. }
  1533. return status;
  1534. }
  1535. /*===========================================================================*/
  1536. static NTSTATUS
  1537. Set_AE_Shutter_Speed(
  1538. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1539. LONG AE_Shutter_Speed)
  1540. /*===========================================================================*/
  1541. {
  1542. UCHAR Buffer[2]={0};
  1543. ULONG BufferLength = sizeof(Buffer);
  1544. NTSTATUS status = STATUS_SUCCESS;
  1545. // ?? need to map to camera value ranges ??
  1546. Buffer[0] = (UCHAR)(AE_Shutter_Speed);
  1547. // status field always equal in set command
  1548. Buffer[1] = (UCHAR)KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_STATUS_EQUAL;
  1549. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1550. SET_LUM_CTL, PRESET_SHUTTER, VC_INTERFACE,
  1551. Buffer, &BufferLength, SEND, NULL, NULL);
  1552. return status;
  1553. }
  1554. /*===========================================================================*/
  1555. static NTSTATUS
  1556. Get_AE_Shutter_Status(
  1557. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1558. PLONG pAE_Shutter_Status)
  1559. /*===========================================================================*/
  1560. {
  1561. UCHAR Buffer[2]={0};
  1562. ULONG BufferLength = sizeof(Buffer);
  1563. NTSTATUS status = STATUS_SUCCESS;
  1564. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1565. GET_LUM_CTL, PRESET_SHUTTER, VC_INTERFACE,
  1566. Buffer, &BufferLength, GET, NULL, NULL);
  1567. if (NT_SUCCESS(status)) // ?? need to map to camera value ranges ??
  1568. {
  1569. (*pAE_Shutter_Status) = (LONG)Buffer[1];
  1570. }
  1571. return status;
  1572. }
  1573. /*===========================================================================*/
  1574. static NTSTATUS
  1575. Get_AE_AGC_Mode(
  1576. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1577. PLONG pAE_AGC_Mode)
  1578. /*===========================================================================*/
  1579. {
  1580. UCHAR Buffer[1]={0};
  1581. ULONG BufferLength = sizeof(Buffer);
  1582. NTSTATUS status = STATUS_SUCCESS;
  1583. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1584. GET_LUM_CTL, AGC_MODE, VC_INTERFACE,
  1585. Buffer, &BufferLength, GET, NULL, NULL);
  1586. if (NT_SUCCESS(status))
  1587. {
  1588. if (Buffer[0] == (UCHAR)0)
  1589. (*pAE_AGC_Mode) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_AUTO;
  1590. else
  1591. (*pAE_AGC_Mode) = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED;
  1592. }
  1593. return status;
  1594. }
  1595. /*===========================================================================*/
  1596. static NTSTATUS
  1597. Set_AE_AGC_Mode(
  1598. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1599. LONG AE_AGC_Mode)
  1600. /*===========================================================================*/
  1601. {
  1602. UCHAR Buffer[1] = {0};
  1603. ULONG BufferLength = sizeof(Buffer);
  1604. NTSTATUS status = STATUS_SUCCESS;
  1605. if (AE_AGC_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_AUTO)
  1606. Buffer[0] = (UCHAR)0;
  1607. else
  1608. Buffer[0] = (UCHAR)0xff;
  1609. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1610. SET_LUM_CTL, AGC_MODE, VC_INTERFACE,
  1611. Buffer, &BufferLength, SEND, NULL, NULL);
  1612. return status;
  1613. }
  1614. /*===========================================================================*/
  1615. static NTSTATUS
  1616. Get_AE_AGC(
  1617. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1618. PLONG pAE_AGC)
  1619. /*===========================================================================*/
  1620. {
  1621. UCHAR Buffer[1]={0};
  1622. ULONG BufferLength = sizeof(Buffer);
  1623. NTSTATUS status = STATUS_SUCCESS;
  1624. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1625. GET_LUM_CTL, PRESET_AGC, VC_INTERFACE,
  1626. Buffer, &BufferLength, GET, NULL, NULL);
  1627. if (NT_SUCCESS(status))
  1628. (*pAE_AGC) = Buffer[0] * AE_AGC_DELTA;
  1629. return status;
  1630. }
  1631. /*===========================================================================*/
  1632. static NTSTATUS
  1633. Set_AE_AGC(
  1634. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1635. LONG AE_AGC)
  1636. /*===========================================================================*/
  1637. {
  1638. UCHAR Buffer[1]={0};
  1639. ULONG BufferLength = sizeof(Buffer);
  1640. NTSTATUS status = STATUS_SUCCESS;
  1641. Buffer[0] = (UCHAR)(AE_AGC / AE_AGC_DELTA);
  1642. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1643. SET_LUM_CTL, PRESET_AGC, VC_INTERFACE,
  1644. Buffer, &BufferLength, SEND, NULL, NULL);
  1645. return status;
  1646. }
  1647. /*===========================================================================*/
  1648. static NTSTATUS
  1649. Get_DriverVersion(
  1650. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1651. PLONG pDriverVersion)
  1652. /*===========================================================================*/
  1653. {
  1654. NTSTATUS status = STATUS_SUCCESS;
  1655. (*pDriverVersion) = DRIVERVERSION; //DeviceContext->DriverVersion;
  1656. return status;
  1657. }
  1658. /*===========================================================================*/
  1659. static NTSTATUS
  1660. Get_Framerate(
  1661. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1662. PLONG pFramerate)
  1663. /*===========================================================================*/
  1664. {
  1665. NTSTATUS status = STATUS_SUCCESS;
  1666. status = Map_Framerate_Drv_to_KS(DeviceContext, pFramerate);
  1667. return status;
  1668. }
  1669. /*===========================================================================*/
  1670. static NTSTATUS
  1671. Set_Framerate(
  1672. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1673. LONG Framerate)
  1674. /*===========================================================================*/
  1675. {
  1676. NTSTATUS status = STATUS_SUCCESS;
  1677. status = Map_Framerate_KS_to_Drv(DeviceContext, Framerate);
  1678. if (!NT_SUCCESS(status))
  1679. return status;
  1680. status = PHILIPSCAM_SetFormatFramerate(DeviceContext);
  1681. return status;
  1682. }
  1683. /*===========================================================================*/
  1684. static NTSTATUS
  1685. Get_Framerates_Supported(
  1686. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1687. PLONG pFramerates_Supported)
  1688. /*===========================================================================*/
  1689. {
  1690. NTSTATUS status = STATUS_SUCCESS;
  1691. int i;
  1692. (*pFramerates_Supported) = 0x0;
  1693. for (i = 0; i < 9; i++)
  1694. {
  1695. if (DeviceContext->FrrSupported[i])
  1696. (*pFramerates_Supported) |= (0x1 << i);
  1697. }
  1698. return status;
  1699. }
  1700. /*===========================================================================*/
  1701. static NTSTATUS
  1702. Get_VideoFormat(
  1703. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1704. PLONG pVideoFormat)
  1705. /*===========================================================================*/
  1706. {
  1707. NTSTATUS status = STATUS_SUCCESS;
  1708. status = Map_VideoFormat_Drv_to_KS(DeviceContext, pVideoFormat);
  1709. return status;
  1710. }
  1711. /*===========================================================================*/
  1712. static NTSTATUS
  1713. Get_SensorType(
  1714. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1715. PLONG pSensorType)
  1716. /*===========================================================================*/
  1717. {
  1718. NTSTATUS status = STATUS_SUCCESS;
  1719. (*pSensorType) = DeviceContext->CamStatus.SensorType;
  1720. return status;
  1721. }
  1722. /*===========================================================================*/
  1723. static NTSTATUS
  1724. Get_VideoCompression(
  1725. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1726. PLONG pVideoCompression)
  1727. /*===========================================================================*/
  1728. {
  1729. NTSTATUS status = STATUS_SUCCESS;
  1730. status = Map_VideoCompression_Drv_to_KS(DeviceContext, pVideoCompression);
  1731. return status;
  1732. }
  1733. /*===========================================================================*/
  1734. static NTSTATUS
  1735. Set_Defaults(
  1736. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1737. LONG Command)
  1738. /*===========================================================================*/
  1739. {
  1740. NTSTATUS status = STATUS_SUCCESS;
  1741. switch(Command)
  1742. {
  1743. case KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_RESTORE_USER:
  1744. status = PHILIPSCAM_Defaults_Restore_User(DeviceContext);
  1745. break;
  1746. case KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_SAVE_USER:
  1747. status = PHILIPSCAM_Defaults_Save_User(DeviceContext);
  1748. break;
  1749. case KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_RESTORE_FACTORY:
  1750. status = PHILIPSCAM_Defaults_Restore_Factory(DeviceContext);
  1751. break;
  1752. default:
  1753. status = STATUS_NOT_SUPPORTED;
  1754. }
  1755. return status;
  1756. }
  1757. /*===========================================================================*/
  1758. static NTSTATUS
  1759. Get_Release_Number(
  1760. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1761. PLONG pRelease_Number)
  1762. /*===========================================================================*/
  1763. {
  1764. NTSTATUS status = STATUS_SUCCESS;
  1765. (*pRelease_Number) = DeviceContext->CamStatus.ReleaseNumber;
  1766. return status;
  1767. }
  1768. /*===========================================================================*/
  1769. static NTSTATUS
  1770. Get_Vendor_Id(
  1771. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1772. PLONG pVendor_Id)
  1773. /*===========================================================================*/
  1774. {
  1775. NTSTATUS status = STATUS_SUCCESS;
  1776. LONG lVendor_Id_Hsb, lVendor_Id_Lsb;
  1777. // set to factorymode
  1778. status = Set_Factory_Mode(DeviceContext, 0x6d);
  1779. if (status != STATUS_SUCCESS)
  1780. return status;
  1781. // set LSB address
  1782. status = Set_RegisterAddress(DeviceContext, 0x1A5);
  1783. if (status != STATUS_SUCCESS)
  1784. goto Get_Vendor_Id_Err;
  1785. // get LSB of vendor id
  1786. status = Get_RegisterData(DeviceContext, &lVendor_Id_Lsb);
  1787. if (status != STATUS_SUCCESS)
  1788. goto Get_Vendor_Id_Err;
  1789. // set HSB address
  1790. status = Set_RegisterAddress(DeviceContext, 0x1A6);
  1791. if (status != STATUS_SUCCESS)
  1792. goto Get_Vendor_Id_Err;
  1793. // get HSB of vendor id
  1794. status = Get_RegisterData(DeviceContext, &lVendor_Id_Hsb);
  1795. if (status != STATUS_SUCCESS)
  1796. goto Get_Vendor_Id_Err;
  1797. // revert to normal operation
  1798. Set_Factory_Mode(DeviceContext, 0x0);
  1799. // compose vendor id from lsb and hsb
  1800. (*pVendor_Id) = ((lVendor_Id_Hsb & 0xff) << 8) | (lVendor_Id_Lsb & 0xff);
  1801. return status;
  1802. Get_Vendor_Id_Err:
  1803. // revert to normal operation
  1804. Set_Factory_Mode(DeviceContext, 0x0);
  1805. return status;
  1806. }
  1807. /*===========================================================================*/
  1808. static NTSTATUS
  1809. Get_Product_Id(
  1810. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext,
  1811. PLONG pProduct_Id)
  1812. /*===========================================================================*/
  1813. {
  1814. NTSTATUS status = STATUS_SUCCESS;
  1815. LONG lProduct_Id_Hsb, lProduct_Id_Lsb;
  1816. // set to factorymode
  1817. status = Set_Factory_Mode(DeviceContext, 0x6d);
  1818. if (status != STATUS_SUCCESS)
  1819. return status;
  1820. // set LSB address
  1821. status = Set_RegisterAddress(DeviceContext, 0x1A7);
  1822. if (status != STATUS_SUCCESS)
  1823. goto Get_Product_Id_Err;
  1824. // get LSB of Product id
  1825. status = Get_RegisterData(DeviceContext, &lProduct_Id_Lsb);
  1826. if (status != STATUS_SUCCESS)
  1827. goto Get_Product_Id_Err;
  1828. // set HSB address
  1829. status = Set_RegisterAddress(DeviceContext, 0x1A8);
  1830. if (status != STATUS_SUCCESS)
  1831. goto Get_Product_Id_Err;
  1832. // get HSB of Product id
  1833. status = Get_RegisterData(DeviceContext, &lProduct_Id_Hsb);
  1834. if (status != STATUS_SUCCESS)
  1835. goto Get_Product_Id_Err;
  1836. // revert to normal operation
  1837. Set_Factory_Mode(DeviceContext, 0x0);
  1838. // compose Product id from lsb and hsb
  1839. (*pProduct_Id) = ((lProduct_Id_Hsb & 0xff) << 8) | (lProduct_Id_Lsb & 0xff);
  1840. return status;
  1841. Get_Product_Id_Err:
  1842. // revert to normal operation
  1843. Set_Factory_Mode(DeviceContext, 0x0);
  1844. return status;
  1845. }
  1846. /*===========================================================================*/
  1847. static NTSTATUS
  1848. Get_RegisterData(
  1849. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  1850. PLONG pValue)
  1851. /*===========================================================================*/
  1852. {
  1853. UCHAR Buffer[1]={0};
  1854. ULONG BufferLength = sizeof(Buffer);
  1855. NTSTATUS status = STATUS_SUCCESS;
  1856. status = PHILPCAM_ControlVendorCommand(pDeviceContext,
  1857. GET_FACTORY_CTL, (USHORT)Address, FACTORY_INTERFACE,
  1858. Buffer, &BufferLength, GET, NULL, NULL);
  1859. if (NT_SUCCESS(status))
  1860. (*pValue) = Buffer[0];
  1861. return status;
  1862. }
  1863. /*===========================================================================*/
  1864. static NTSTATUS
  1865. Set_RegisterAddress(
  1866. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  1867. LONG AddressToSet)
  1868. /*===========================================================================*/
  1869. {
  1870. NTSTATUS status = STATUS_SUCCESS;
  1871. // swap high/low byte of address
  1872. Address = HIBYTE(AddressToSet) | (LOBYTE(AddressToSet) << 8);
  1873. return status;
  1874. }
  1875. /*===========================================================================*/
  1876. static NTSTATUS
  1877. Set_RegisterData(
  1878. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  1879. LONG Value)
  1880. /*===========================================================================*/
  1881. {
  1882. UCHAR Buffer[1]={0};
  1883. ULONG BufferLength = sizeof(Buffer);
  1884. NTSTATUS status = STATUS_SUCCESS;
  1885. Buffer[0] = (BYTE)Value;
  1886. status = PHILPCAM_ControlVendorCommand(pDeviceContext,
  1887. SET_FACTORY_CTL, (USHORT)Address, FACTORY_INTERFACE,
  1888. Buffer, &BufferLength, SEND, NULL, NULL);
  1889. return status;
  1890. }
  1891. /*===========================================================================*/
  1892. static NTSTATUS
  1893. Set_Factory_Mode(
  1894. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  1895. LONG Factory_Mode)
  1896. /*===========================================================================*/
  1897. {
  1898. UCHAR Buffer[1]={0};
  1899. ULONG BufferLength = sizeof(Buffer);
  1900. NTSTATUS status = STATUS_SUCCESS;
  1901. Buffer[0] = (UCHAR)Factory_Mode;
  1902. status = PHILPCAM_ControlVendorCommand(pDeviceContext,
  1903. SET_STATUS_CTL, FACTORY_MODE, VC_INTERFACE,
  1904. Buffer, &BufferLength, SEND, NULL, NULL);
  1905. return status;
  1906. }
  1907. /*===========================================================================*/
  1908. static NTSTATUS
  1909. PHILIPSCAM_Defaults_Restore_User(
  1910. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext)
  1911. /*===========================================================================*/
  1912. {
  1913. NTSTATUS status = STATUS_SUCCESS;
  1914. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1915. SET_STATUS_CTL, RESTORE_USER_DEFAULTS, VC_INTERFACE,
  1916. NULL, 0, SEND, NULL, NULL);
  1917. // restore all driver defaults
  1918. if (NT_SUCCESS(status))
  1919. status = PHILIPSCAM_RestoreDriverDefaults(DeviceContext);
  1920. return status;
  1921. }
  1922. /*===========================================================================*/
  1923. static NTSTATUS
  1924. PHILIPSCAM_Defaults_Save_User(
  1925. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext)
  1926. /*===========================================================================*/
  1927. {
  1928. NTSTATUS status = STATUS_SUCCESS;
  1929. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1930. SET_STATUS_CTL, SAVE_USER_DEFAULTS, VC_INTERFACE,
  1931. NULL, 0, SEND, NULL, NULL);
  1932. return status;
  1933. }
  1934. /*===========================================================================*/
  1935. static NTSTATUS
  1936. PHILIPSCAM_Defaults_Restore_Factory(
  1937. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext)
  1938. /*===========================================================================*/
  1939. {
  1940. NTSTATUS status = STATUS_SUCCESS;
  1941. status = PHILPCAM_ControlVendorCommand(DeviceContext,
  1942. SET_STATUS_CTL, RESTORE_FACTORY_DEFAULTS, VC_INTERFACE,
  1943. NULL, 0, SEND, NULL, NULL);
  1944. // restore all driver defaults
  1945. if (NT_SUCCESS(status))
  1946. status = PHILIPSCAM_RestoreDriverDefaults(DeviceContext);
  1947. return status;
  1948. }
  1949. /*===========================================================================*/
  1950. static NTSTATUS
  1951. PHILIPSCAM_RestoreDriverDefaults(
  1952. PPHILIPSCAM_DEVICE_CONTEXT DeviceContext)
  1953. /*===========================================================================*/
  1954. {
  1955. NTSTATUS ntStatus, status = STATUS_SUCCESS;
  1956. ntStatus = Get_Brightness(DeviceContext, &Brightness_Default);
  1957. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1958. return STATUS_DEVICE_NOT_CONNECTED;
  1959. else
  1960. status |= ntStatus;
  1961. ntStatus = Get_Contrast(DeviceContext, &Contrast_Default);
  1962. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1963. return STATUS_DEVICE_NOT_CONNECTED;
  1964. else
  1965. status |= ntStatus;
  1966. ntStatus = Get_Gamma(DeviceContext, &Gamma_Default);
  1967. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1968. return STATUS_DEVICE_NOT_CONNECTED;
  1969. else
  1970. status |= ntStatus;
  1971. ntStatus = Get_ColorEnable(DeviceContext, &ColorEnable_Default);
  1972. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1973. return STATUS_DEVICE_NOT_CONNECTED;
  1974. else
  1975. status |= ntStatus;
  1976. ntStatus = Get_BackLight_Compensation(DeviceContext, &BackLight_Compensation_Default);
  1977. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1978. return STATUS_DEVICE_NOT_CONNECTED;
  1979. else
  1980. status |= ntStatus;
  1981. ntStatus = Get_WB_Mode(DeviceContext, &WB_Mode_Default);
  1982. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1983. return STATUS_DEVICE_NOT_CONNECTED;
  1984. else
  1985. status |= ntStatus;
  1986. ntStatus = Get_WB_Speed(DeviceContext, &WB_Speed_Default);
  1987. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1988. return STATUS_DEVICE_NOT_CONNECTED;
  1989. else
  1990. status |= ntStatus;
  1991. ntStatus = Get_WB_Delay(DeviceContext, &WB_Delay_Default);
  1992. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1993. return STATUS_DEVICE_NOT_CONNECTED;
  1994. else
  1995. status |= ntStatus;
  1996. ntStatus = Get_WB_Red_Gain(DeviceContext, &WB_Red_Gain_Default);
  1997. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  1998. return STATUS_DEVICE_NOT_CONNECTED;
  1999. else
  2000. status |= ntStatus;
  2001. ntStatus = Get_WB_Blue_Gain(DeviceContext, &WB_Blue_Gain_Default);
  2002. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2003. return STATUS_DEVICE_NOT_CONNECTED;
  2004. else
  2005. status |= ntStatus;
  2006. ntStatus = Get_AE_Control_Speed(DeviceContext, &AE_Control_Speed_Default);
  2007. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2008. return STATUS_DEVICE_NOT_CONNECTED;
  2009. else
  2010. status |= ntStatus;
  2011. ntStatus = Get_AE_Flickerless(DeviceContext, &AE_Flickerless_Default);
  2012. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2013. return STATUS_DEVICE_NOT_CONNECTED;
  2014. else
  2015. status |= ntStatus;
  2016. ntStatus = Get_AE_Shutter_Mode(DeviceContext, &AE_Shutter_Mode_Default);
  2017. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2018. return STATUS_DEVICE_NOT_CONNECTED;
  2019. else
  2020. status |= ntStatus;
  2021. ntStatus = Get_AE_Shutter_Speed(DeviceContext, &AE_Shutter_Speed_Default);
  2022. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2023. return STATUS_DEVICE_NOT_CONNECTED;
  2024. else
  2025. status |= ntStatus;
  2026. ntStatus = Get_AE_AGC_Mode(DeviceContext, &AE_AGC_Mode_Default);
  2027. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2028. return STATUS_DEVICE_NOT_CONNECTED;
  2029. else
  2030. status |= ntStatus;
  2031. ntStatus = Get_AE_AGC(DeviceContext, &AE_AGC_Default);
  2032. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2033. return STATUS_DEVICE_NOT_CONNECTED;
  2034. else
  2035. status |= ntStatus;
  2036. ntStatus = Get_Framerate(DeviceContext, &Framerate_Default);
  2037. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2038. return STATUS_DEVICE_NOT_CONNECTED;
  2039. else
  2040. status |= ntStatus;
  2041. ntStatus = Get_VideoFormat(DeviceContext, &VideoFormat_Default);
  2042. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2043. return STATUS_DEVICE_NOT_CONNECTED;
  2044. else
  2045. status |= ntStatus;
  2046. ntStatus = Get_VideoCompression(DeviceContext, &VideoCompression_Default);
  2047. if (STATUS_DEVICE_NOT_CONNECTED == ntStatus)
  2048. return STATUS_DEVICE_NOT_CONNECTED;
  2049. else
  2050. status |= ntStatus;
  2051. // hack; not all defaults are accesible yet, thus
  2052. // status will be FAIL
  2053. // this must be removed when all supported
  2054. status = STATUS_SUCCESS;
  2055. return status;
  2056. }
  2057. /*===========================================================================*/
  2058. static NTSTATUS Map_Framerate_Drv_to_KS(
  2059. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2060. PLONG pFramerate)
  2061. /*===========================================================================*/
  2062. {
  2063. NTSTATUS status = STATUS_SUCCESS;
  2064. static BYTE Map_PHFRAMERATE_To_SSI[] =
  2065. {
  2066. FRAMERATE_VGA,
  2067. FRAMERATE_375,
  2068. FRAMERATE_5,
  2069. FRAMERATE_75,
  2070. FRAMERATE_10,
  2071. FRAMERATE_12,
  2072. FRAMERATE_15,
  2073. FRAMERATE_20,
  2074. FRAMERATE_24,
  2075. };
  2076. if (pDeviceContext->CamStatus.PictureFrameRate < 0 ||
  2077. pDeviceContext->CamStatus.PictureFrameRate >= 9)
  2078. return STATUS_INVALID_PARAMETER;
  2079. (*pFramerate) =
  2080. Map_PHFRAMERATE_To_SSI[pDeviceContext->CamStatus.PictureFrameRate];
  2081. return status;
  2082. }
  2083. /*===========================================================================*/
  2084. static NTSTATUS Map_Framerate_KS_to_Drv(
  2085. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2086. LONG Framerate)
  2087. /*===========================================================================*/
  2088. {
  2089. NTSTATUS status = STATUS_SUCCESS;
  2090. switch(Framerate)
  2091. {
  2092. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_VGA:
  2093. pDeviceContext->CamStatus.PictureFrameRate = FRRATEVGA;
  2094. break;
  2095. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_375:
  2096. pDeviceContext->CamStatus.PictureFrameRate = FRRATE375;
  2097. break;
  2098. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_5:
  2099. pDeviceContext->CamStatus.PictureFrameRate = FRRATE5;
  2100. break;
  2101. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_75:
  2102. pDeviceContext->CamStatus.PictureFrameRate = FRRATE75;
  2103. break;
  2104. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_10:
  2105. pDeviceContext->CamStatus.PictureFrameRate = FRRATE10;
  2106. break;
  2107. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_12:
  2108. pDeviceContext->CamStatus.PictureFrameRate = FRRATE12;
  2109. break;
  2110. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_15:
  2111. pDeviceContext->CamStatus.PictureFrameRate = FRRATE15;
  2112. break;
  2113. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_20:
  2114. pDeviceContext->CamStatus.PictureFrameRate = FRRATE20;
  2115. break;
  2116. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_24:
  2117. pDeviceContext->CamStatus.PictureFrameRate = FRRATE24;
  2118. break;
  2119. default:
  2120. status = STATUS_INVALID_PARAMETER;
  2121. }
  2122. PHILIPSCAM_KdPrint (MIN_TRACE, ("Picture Frame Rate = %d\n",
  2123. pDeviceContext->CamStatus.PictureFrameRate));
  2124. return status;
  2125. }
  2126. /*===========================================================================*/
  2127. static NTSTATUS Map_VideoFormat_Drv_to_KS(
  2128. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2129. PLONG pVideoFormat)
  2130. /*===========================================================================*/
  2131. {
  2132. NTSTATUS status = STATUS_SUCCESS;
  2133. static BYTE Map_PHFORMAT_To_SSI[] =
  2134. {// SSI (camera) STREAM (UserInterface)
  2135. CIF_FORMAT, // FORMATCIF
  2136. QCIF_FORMAT, // FORMATQCIF
  2137. SQCIF_FORMAT, // FORMATSQCIF
  2138. SQCIF_FORMAT, // FORMATQQCIF
  2139. VGA_FORMAT, // FORMATVGA
  2140. CIF_FORMAT, // FORMATSIF
  2141. CIF_FORMAT, // FORMATSSIF
  2142. QCIF_FORMAT, // FORMATQSIF
  2143. SQCIF_FORMAT, // FORMATSQSIF
  2144. CIF_FORMAT, // FORMATSCIF
  2145. };
  2146. if (pDeviceContext->CamStatus.PictureFormat < FORMATCIF ||
  2147. pDeviceContext->CamStatus.PictureFormat > FORMATSCIF)
  2148. return STATUS_INVALID_PARAMETER;
  2149. (*pVideoFormat) =
  2150. Map_PHFORMAT_To_SSI[pDeviceContext->CamStatus.PictureFormat];
  2151. return status;
  2152. }
  2153. /*===========================================================================*/
  2154. static NTSTATUS Map_VideoCompression_Drv_to_KS(
  2155. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2156. PLONG pVideoCompression)
  2157. /*===========================================================================*/
  2158. {
  2159. NTSTATUS status = STATUS_SUCCESS;
  2160. static BYTE Map_PHCOMPRESSION_To_SSI[] =
  2161. {
  2162. UNCOMPRESSED,
  2163. COMPRESSED_3,
  2164. COMPRESSED_4
  2165. };
  2166. if (pDeviceContext->CamStatus.PictureCompressing < 0 ||
  2167. pDeviceContext->CamStatus.PictureCompressing > 2)
  2168. return STATUS_INVALID_PARAMETER;
  2169. (*pVideoCompression) =
  2170. Map_PHCOMPRESSION_To_SSI[pDeviceContext->CamStatus.PictureCompressing];
  2171. return status;
  2172. }
  2173. /*===========================================================================*/
  2174. //static VOID
  2175. //PHILIPSCAM_TimeoutDPC(
  2176. // PKDPC Dpc,
  2177. // PVOID DeferredContext,
  2178. // PVOID SystemArgument1,
  2179. // PVOID SystemArgument2
  2180. // )
  2181. /*===========================================================================*/
  2182. //{
  2183. // bTimerExpired = TRUE;
  2184. //}
  2185. /*===========================================================================*/
  2186. static NTSTATUS
  2187. PHILPCAM_ControlVendorCommand(
  2188. PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2189. UCHAR Request,
  2190. USHORT Value,
  2191. USHORT Index,
  2192. PVOID Buffer,
  2193. PULONG BufferLength,
  2194. BOOLEAN GetData,
  2195. PCOMMAND_COMPLETE_FUNCTION CommandComplete,
  2196. PVOID CommandContext)
  2197. /*===========================================================================*/
  2198. {
  2199. NTSTATUS status = STATUS_SUCCESS;
  2200. LARGE_INTEGER SystemTimeCurrent = {0};
  2201. LARGE_INTEGER SystemTimeStart = {0};
  2202. KeQuerySystemTime(&SystemTimeStart);
  2203. while(1)
  2204. {
  2205. status = USBCAMD_ControlVendorCommand(
  2206. pDeviceContext,
  2207. Request,
  2208. Value,
  2209. Index,
  2210. Buffer,
  2211. BufferLength,
  2212. GetData,
  2213. CommandComplete,
  2214. CommandContext);
  2215. if (NT_SUCCESS(status) || STATUS_DEVICE_NOT_CONNECTED == status)
  2216. break;
  2217. KeQuerySystemTime(&SystemTimeCurrent);
  2218. if ((SystemTimeCurrent.QuadPart - SystemTimeStart.QuadPart) > (10000 * WAIT_FOR_COMPLETION))
  2219. break;
  2220. }
  2221. return status;
  2222. }
  2223. /*===========================================================================*/
  2224. //static NTSTATUS
  2225. //PHILPCAM_ControlVendorCommand(
  2226. // PPHILIPSCAM_DEVICE_CONTEXT pDeviceContext,
  2227. // UCHAR Request,
  2228. // USHORT Value,
  2229. // USHORT Index,
  2230. // PVOID Buffer,
  2231. // PULONG BufferLength,
  2232. // BOOLEAN GetData,
  2233. // PCOMMAND_COMPLETE_FUNCTION CommandComplete,
  2234. // PVOID CommandContext)
  2235. /*===========================================================================*/
  2236. //{
  2237. // NTSTATUS status = STATUS_SUCCESS;
  2238. // int i;
  2239. // KTIMER TimeoutTimer;
  2240. // KDPC TimeoutDpc;
  2241. // LARGE_INTEGER dueTime;
  2242. // bTimerExpired = FALSE;
  2243. // start timer
  2244. // KeInitializeTimer(&TimeoutTimer);
  2245. // KeInitializeDpc(&TimeoutDpc,
  2246. // PHILIPSCAM_TimeoutDPC,
  2247. // CurrentpSrb->Irp);
  2248. // dueTime.QuadPart = -10000 * WAIT_FOR_COMPLETION;
  2249. // KeSetTimer(&TimeoutTimer,
  2250. // dueTime,
  2251. // &TimeoutDpc);
  2252. // while(!bTimerExpired)
  2253. // {
  2254. // status = USBCAMD_ControlVendorCommand(
  2255. // pDeviceContext,
  2256. // Request,
  2257. // Value,
  2258. // Index,
  2259. // Buffer,
  2260. // BufferLength,
  2261. // GetData,
  2262. // CommandComplete,
  2263. // CommandContext);
  2264. /* if (NT_SUCCESS(status))
  2265. break;*/
  2266. // }
  2267. // KeCancelTimer(&TimeoutTimer);
  2268. // return status;
  2269. //}