The question says it all -- does the camera "know" how far the subject is from the lens, i.e. what is the current exact focus distance set at the lens?
Many (possibly most) modern SLR lens systems return focus setting data to the camera.
Potentially the precision of data returned could be high - something better than 1% of range would be possible and meaningful with modern systems.
However, it appears that most if not all systems use a simple gray-coded* system with perhaps 16 steps. Number of steps varies with manufacturer and even with lens model.
A Gray code is a (usually but not essentially) binary code in which only one bit changes at each position change. This means that if the position oscillates to and fro at the boundary that erroneous codes cannot be sent. In a normal binary code, where 2 or more bits may change at once, if one changing bit alters before another due to mechanical tolerances or contact bounce then completely erroneous codes may be sent in error.
Std binary code At the 3 to 4 boundary 3 bits change at once. If any of these were early or late in occurring many illegal codes could result
Out of my head Gray-code
I have purposefully NOT followed what may be a most logical sequence.
A few brand specific samples - more anon:
Claim here that the Canon EF 50mm f/1.4 USM only uses a 2 bit = 4 position code. - interesting discussion with some relevance.
Minolta / Sony A mount system lenses that I have inspected use a simple grey-coded mechanical distance encoder with 4 bit / 16 position precision.
Nikon: Here is a nice Nikon discussion with specifc 16 stage gray coding information for one lens, plus some circuitry and a lot of associated material.
Gray codes for an example lens:
Here a4 digit code is returned wit 1 = open circuit and 0 = contact shorted to ground.
Adding gray-coded sensors to manual Nikon lenses to allow operation with more modern bodies.
Example rotary gray code pattern. This is to gray code a knob or dial but lens focus rotation uses the same style of pattern. There are numerous different possible gray codes.
Excellent gray-code discussion with specific reference to len focusing.
DIY Nikon lens protocol converter - upgrade old or incompatible lenses.](http://photo.net/nikon-camera-forum/00956N)
Canon gray-code patent February 2012 !!!](http://www.freepatentsonline.com/y2012/0032068.html) and PDF here - may or may not be lens related.
Yes for most camera systems:
This depends on both the camera and lens, both must support communication of such information.
Nikon introduced the feature with their "D" lenses (later "G" lenses can do it as well). According to Nikon's glossary, the following bodies can use that information: F6, F5, F100, F90X, F80, F75, F70, F65, F60, F55, F50, PRONEA S, PRONEA 600i, D2 series, D1 series, D100 and D70s/D70. I suspect this list is outdated and should include more recent models.
Canon E-TTL II capable bodies and some EF lenses also communicate focusing distance; there is no indication of this feature in lens model name.
All Pentax auto-focus lenses and SLRs since early 1990s can communicate distance information, according to Roland Mabo.